LucyAndLily/ 0040750 0064137 0000144 00000000000 07274261120 0012677 5 ustar 00res fac 0000256 0000012 LucyAndLily/README 0100644 0064137 0000144 00000002231 07274261356 0013572 0 ustar 00res fac 0000256 0000012
The subdirectory LL1 contains the game Lucy And Lily
The subdirectory LL2 contains the sequel Lucy and Lily II
I'll explain how to run the program in LL1. The
discussion for LL2 is entirely similar.
First, go into LL1.
This directory contains the files test1.java and test1.html.
I think that these files will work on any system that
has a java compiler. I am running it on a sparc workstation,
which uses Solaris 7.
To compile the code type
javac test1.java
The compiler may give you a warning about using
"deprecated commands". You can safely ignore this.
To run the code, type
appletviewer test1.html
There is a line near the top of the file
which has the line SIZE=440. If you change
this line you can change the overall size of
the playing board. You should make corresponding
changes in the dimensions listed in the
test1.html file. A little experimentation should
help you determine suitable dimensions. All
of this may screw up the text a bit...
All the code is meant for your personal use only. Public
use of the code (for instance, posting it on the web)
is a violation of the copyright.
LucyAndLily/LL1/ 0040755 0064137 0000144 00000000000 07274261425 0013304 5 ustar 00res fac 0000256 0000012 LucyAndLily/LL1/test1.html 0100644 0064137 0000144 00000000263 07274261114 0015223 0 ustar 00res fac 0000256 0000012
source code
~
~
~
LucyAndLily/LL1/test1.java 0100644 0064137 0000144 00000057170 07274261114 0015211 0 ustar 00res fac 0000256 0000012 import java.applet.Applet;
import java.awt.event.*;
import java.awt.*;
public class test1 extends Applet {
GridBagLayout game;
GridBagConstraints c;
PlayingBoard B1,B2;
ViewCanvas B3,B4;
Canvas B12;
ButtonCanvas BC;
TextCanvas B5;
Panel P1,P2,P12;
Color BACK=Color.black;
int SIZE;
public void init() {
game=new GridBagLayout();
c=new GridBagConstraints();
c.gridwidth=GridBagConstraints.REMAINDER;
setLayout(game);
setBackground(Color.black);
/*****************/
/*****************/
SIZE=440;
/*****************/
/*****************/
P1=new Panel();
P2=new Panel();
B1=new PlayingBoard(SIZE,1);
B2=new PlayingBoard(SIZE,2);
B12=new Canvas();
B3=new ViewCanvas(SIZE,B1);
B5=new TextCanvas(SIZE);
B4=new ViewCanvas(SIZE,B2);
BC=new ButtonCanvas(SIZE,B1,B2,B3,B4,B5);
B1.resize(SIZE,SIZE);
B2.resize(SIZE,SIZE);
B3.resize((int)(SIZE/2),(int)(SIZE/2));
B5.resize(100+SIZE,(int)(SIZE/2));
B4.resize((int)(SIZE/2),(int)(SIZE/2));
B12.resize(1,SIZE);
BC.resize(100,SIZE);
B12.setBackground(Color.blue);
B1.setBackground(BACK);
B2.setBackground(BACK);
B1.setBackground(BACK);
B2.setBackground(BACK);
B3.setBackground(BACK);
B5.setBackground(new Color(0,0,100));
B4.setBackground(BACK);
P1.setBackground(Color.blue);
P2.setBackground(Color.blue);
BC.setBackground(new Color(0,0,100));
B1=B1.addControl(B2);
B2=B2.addControl(B1);
B1=B1.addRecord(B3);
B2=B2.addRecord(B4);
P1.add(B1);
P1.add(BC);
P1.add(B2);
P2.add(B3);
P2.add(B5);
P2.add(B4);
c.ipady=-5;
game.setConstraints(P1,c);
c.ipady=0;
game.setConstraints(P2,c);
add(P1);
add(P2);
}
}
class ListenSquare {
int x,y,w,h;
Color C;
String S;
int v;
ListenSquare(int x,int y,int w,int h,Color C,String S,int v) {
this.x=x;
this.y=y;
this.h=h;
this.w=w;
this.C=C;
this.S=S;
this.v=v;
}
void render(Graphics g) {
g.setColor(C);
g.fillRect(x,y,w,h);
g.drawRect(x,y,w,h);
g.setColor(Color.black);
g.setFont(new Font("TimesRoman",Font.PLAIN,13));
g.drawString(S,x+5,y+13);
}
int inside(Point p) {
int test=0;
if((p.x>x)&&(p.xy)&&(p.ySIZE/24) {
B1.P=B1.P.scale(1.0/1.1);
B2.P=B2.P.scale(1.0/1.1);
B1.GP=B1.GP.scale(1.0/1.1);
B2.GP=B2.GP.scale(1.0/1.1);
B1.repaint();
B2.repaint();
B3.repaint();
B4.repaint();
}
}
if(L[10].inside(y)==1) {
if(B5.panel>1) {
--B5.panel;
B5.repaint();
}
}
if(L[11].inside(y)==1) {
++B5.panel;
if(B5.panel==13) B5.panel=1;
B5.repaint();
}
}
}
class ViewCanvas extends Canvas implements MouseListener,MouseMotionListener {
Canvas C;
int tx,ty,rx,ry;
int SIZE;
PlayingBoard X;
ViewCanvas(int SIZE,PlayingBoard X) {
C=new Canvas();
this.C=C;
this.SIZE=SIZE;
tx=0;
ty=0;
rx=0;
ry=0;
this.X=X;
addMouseListener(this);
addMouseMotionListener(this);
}
public void paint(Graphics g) {
if(X.P.hide==0) {
int x1,y1,x2,y2;
x2=(int)(X.P.c.x/10.0);
y2=(int)(X.P.c.y/10.0);
g.setColor(Color.yellow);
g.setColor(Color.red);
g.drawOval((int)(SIZE/4-1),(int)(SIZE/4-1),2,2);
g.setColor(Color.yellow);
g.translate((int)(SIZE/4),(int)(SIZE/4));
g.drawOval(x2-2,y2-2,4,4);
g.translate(tx,ty);
g.setColor(Color.cyan);
g.drawRect(-SIZE/20,-SIZE/20,SIZE/10,SIZE/10);
g.translate(-tx,-ty);
}
}
public void mouseClicked(MouseEvent e) {
e.consume();
if(X.P.hide==0) {
tx=e.getX()-(int)(SIZE/4);
ty=e.getY()-(int)(SIZE/4);
X.tx=(int)(SIZE/2)-10*tx;
X.ty=(int)(SIZE/2)-10*ty;
repaint();
this.X.repaint(); }
}
public void mouseReleased(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseDragged(MouseEvent e) {}
public void mouseMoved(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
}
class PlayingBoard extends Canvas implements MouseListener, MouseMotionListener {
int SIZE;
Complex cen,cen2;
PlayingBoard control;
ViewCanvas record;
PolyFlip P,GP;
int k;
int tx,ty;
int shadow,history;
PlayingBoard(int SIZE,int k) {
this.SIZE=SIZE;
this.k=k;
Color[] C=new Color[10];
Color[] GC=new Color[10];
for(int i=0;i<=6;++i) GC[i]=Color.blue;
C[0]=Color.red;
C[4]=Color.yellow;
C[1]=Color.orange;
C[3]=Color.cyan;
C[2]=Color.magenta;
cen=new Complex();
cen.x=0;
cen.y=0;
cen2=new Complex();
cen2.x=0;
cen2.y=0;
P=new PolyFlip(0,SIZE/10,k,5,cen,0,0,0,C);
GP=new PolyFlip(0.0,SIZE/10,k,5,cen2,0,0,0,GC);
addMouseListener(this);
addMouseMotionListener(this);
tx=(int)(SIZE/2);
ty=(int)(SIZE/2);
history=-1;
shadow=-1;
}
public void paint(Graphics g) {
if(P.hide==0) {
g.translate(tx,ty);
GP.render(g,Color.white);
P.render(g,Color.white);
if(shadow>-1) P.shadow_render(g,shadow);
}
}
public void mouseDragged(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {
Point y=new Point();
e.consume();
y.x=e.getX()-tx;
y.y=e.getY()-ty;
int val=P.inside(y);
if(val>=0) {
P=P.flip(val);
shadow=-1;
control.shadow=-1;
control.P=control.P.flip(val);
repaint();
control.repaint();
record.repaint();
control.record.repaint();
}
}
public void mouseMoved(MouseEvent e) {
Point y=new Point();
e.consume();
y.x=e.getX()-tx;
y.y=e.getY()-ty;
int val=P.inside(y);
if(history!=val) {
shadow=val;
history=val;
control.shadow=val;
repaint();
control.repaint();
}
}
public void mouseExited(MouseEvent e) {
int val=-1;
shadow=val;
history=val;
control.shadow=val;
repaint();
control.repaint();
}
PlayingBoard addControl(PlayingBoard X) {
PlayingBoard Y;
Y=this;
Y.control=X;
return(Y);
}
PlayingBoard addRecord(ViewCanvas X) {
PlayingBoard Y;
Y=this;
Y.record=X;
return(Y);
}
}
class Complex {
double x,y;
Complex() {
this.x=x;
this.y=y;
}
}
class ListenTriangle {
Polygon P;
ListenTriangle(Polygon P) {
this.P=P;
}
int inside(Point p)
{
int x1,x2,x3,y1,y2,y3;
int v1x,v1y,v2x,v2y;
int A1,A2,A3;
int value;
Polygon Q;
Q=this.P;
x1=Q.xpoints[0];
x2=Q.xpoints[1];
x3=Q.xpoints[2];
y1=Q.ypoints[0];
y2=Q.ypoints[1];
y3=Q.ypoints[2];
v1x=p.x-x1;
v1y=p.y-y1;
v2x=p.x-x2;
v2y=p.y-y2;
A3=v1x*v2y-v1y*v2x;
v1x=p.x-x2;
v1y=p.y-y2;
v2x=p.x-x3;
v2y=p.y-y3;
A1=v1x*v2y-v1y*v2x;
v1x=p.x-x3;
v1y=p.y-y3;
v2x=p.x-x1;
v2y=p.y-y1;
A2=v1x*v2y-v1y*v2x;
value=0;
if((A1<0)&&(A2<0)&&(A3<0)) value=1;
if((A1>0)&&(A2>0)&&(A3>0)) value=1;
return(value);
}
}
class PolyFlip {
Color[] C;
Complex c;
double r1,r2;
int mode;
int hide;
int angle;
int k,n;
PolyFlip(double r1,double r2,int k,int n,Complex c,int hide,int mode,int angle,Color[] C) {
this.k=k;
this.n=n;
this.r1=r1;
this.r2=r2;
this.c=c;
this.mode=mode;
this.hide=hide;
this.angle=angle;
this.C=C;
hide=0;
}
PolyFlip scale(double d) {
PolyFlip Q=this;
Q.c.x=d*Q.c.x;
Q.c.y=d*Q.c.y;
Q.r1=d*Q.r1;
Q.r2=d*Q.r2;
return(Q);
}
void render(Graphics g,Color C) {
double x1,x2,x3,y1,y2,y3,x4,y4,x5,y5;
int i,m;
double ii,nn;
Polygon P=new Polygon();
for(i=0;i-1) {
if(this.mode==0) {
ii=i*this.k;
nn=this.n;
x=this.r2*Math.cos(2.0*Math.PI*(this.angle+ii)/nn);
y=this.r2*Math.sin(2.0*Math.PI*(this.angle+ii)/nn);
len=2*Math.cos(Math.PI/nn);
Q.c.x=Q.c.x+len*x;
Q.c.y=Q.c.y-len*y;
Q.angle=this.angle+2*this.k*i;
}
if(this.mode==1) {
ii=-i*this.k;
nn=this.n;
x=this.r2*Math.cos(2.0*Math.PI*(this.angle+ii)/nn);
y=this.r2*Math.sin(2.0*Math.PI*(this.angle+ii)/nn);
len=2*Math.cos(Math.PI/nn);
Q.c.x=Q.c.x-len*x;
Q.c.y=Q.c.y+len*y;
Q.angle=-2*this.k*i+this.angle;
}
Q.mode=1-this.mode;
}
return(Q);
}
int random_integer() {
double ran,ii,nn;
int tn=this.n;
int i;
int m;
m=tn-1;
ran=Math.random();
ran=ran-Math.floor(ran);
for(i=1;i300) g.setFont(new Font("TimesRoman",Font.PLAIN,15));
for(int i=1;i<=8;++i) {
g.drawString(S[i],65,15+i*SIZE/20);
}
if(panel==1) g.drawString("1",SIZE+80,SIZE/2-8);
if(panel==2) g.drawString("2",SIZE+80,SIZE/2-8);
if(panel==3) g.drawString("3",SIZE+80,SIZE/2-8);
if(panel==4) g.drawString("4",SIZE+80,SIZE/2-8);
if(panel==5) g.drawString("5",SIZE+80,SIZE/2-8);
if(panel==6) g.drawString("6",SIZE+80,SIZE/2-8);
if(panel==7) g.drawString("7",SIZE+80,SIZE/2-8);
if(panel==8) g.drawString("8",SIZE+80,SIZE/2-8);
if(panel==9) g.drawString("9",SIZE+80,SIZE/2-8);
if(panel==10) g.drawString("10",SIZE+80,SIZE/2-8);
if(panel==11) g.drawString("11",SIZE+80,SIZE/2-8);
if(panel==12) g.drawString("12",SIZE+80,SIZE/2-8);
}
TextCanvas control1(PlayingBoard X) {
TextCanvas Y=this;
Y.control1=X;
return(Y);
}
TextCanvas control2(PlayingBoard X) {
TextCanvas Y=this;
Y.control2=X;
return(Y);
}
}
;
nn=this.n;
x1=this.c.x;
y1=this.c.y;
x2=x1+this.r2*Math.cos(2.0*Math.PI*(this.angle+ii-.5)/nn-Math.PI*this.mode);
y2=y1-this.r2*Math.sin(2.0*Math.PI*(this.angle+ii-.5)/nn-Math.PI*this.mode);
x3=x1+this.r2*Math.cos(2.0*Math.PI*(this.angle+ii+.5)/nn-Math.PI*this.mode);
y3=y1-this.r2*Math.sin(2.0*Math.PI*(this.angle+ii+.5)/nn-Math.PI*this.mLucyAndLily/LL2/ 0040755 0064137 0000144 00000000000 07274261451 0013304 5 ustar 00res fac 0000256 0000012 LucyAndLily/LL2/test1.html 0100644 0064137 0000144 00000000257 07274261134 0015231 0 ustar 00res fac 0000256 0000012
source code
~
~
~
LucyAndLily/LL2/test1.java 0100644 0064137 0000144 00000071156 07274261134 0015214 0 ustar 00res fac 0000256 0000012 import java.applet.Applet;
import java.awt.event.*;
import java.awt.*;
public class test1 extends Applet {
PlayCanvas P;
ViewCanvas V;
Canvas X;
Canvas T;
GridBagLayout game;
GridBagConstraints c;
int[] PIECE=new int[10];
double[] SIZE=new double[10];
Color[] COLOR=new Color[30];
Color[]VCOLOR=new Color[50];
double[] VSIZE=new double[10];
public void init() {
PIECE[0]=2;
PIECE[1]=1;
PIECE[2]=2;
PIECE[3]=5;
SIZE[0]=780;
SIZE[1]=190;
SIZE[2]=0;
SIZE[3]=30;
VSIZE[0]=110;
VSIZE[1]=100;
VSIZE[2]=20;
VCOLOR[0]=Color.red;
VCOLOR[1]=Color.blue;
VCOLOR[2]=Color.cyan;
VCOLOR[3]=Color.yellow;
VCOLOR[10]=Color.black;
VCOLOR[11]=new Color(220,220,220);
VCOLOR[12]=Color.blue;
VCOLOR[13]=new Color(10,70,120);
VCOLOR[20]=Color.white;
VCOLOR[21]=Color.black;
VCOLOR[22]=Color.white;
VCOLOR[23]=Color.white;
VCOLOR[30]=new Color(80,80,80);
VCOLOR[31]=Color.white;
VCOLOR[32]=Color.blue.darker();
VCOLOR[33]=new Color(20,90,160);
COLOR[0]=Color.blue.brighter();
COLOR[1]=Color.blue.darker();
COLOR[2]=Color.red.brighter();
COLOR[3]=Color.red.darker();
COLOR[4]=Color.green.brighter();
COLOR[5]=Color.green.darker();
COLOR[6]=Color.magenta;
COLOR[7]=Color.magenta.darker();
COLOR[8]=Color.cyan;
COLOR[9]=Color.cyan.darker();
COLOR[10]=Color.yellow;
COLOR[11]=Color.yellow.darker();
COLOR[12]=new Color(100,100,255);
COLOR[13]=new Color(100,50,50);
game=new GridBagLayout();
c=new GridBagConstraints();
setLayout(game);
P=new PlayCanvas(SIZE,PIECE,COLOR);
V=new ViewCanvas(VSIZE,VCOLOR,P);
X=new Canvas();
X.resize(10,10);
P=P.addView(V);
P.setBackground(Color.black);
V.setBackground(Color.black);
setBackground(Color.blue);
add(V);
add(X);
add(P);
}
}
class PlayCanvas extends Canvas implements MouseListener,MouseMotionListener {
PolyFlip[] P=new PolyFlip[10];
Complex[] z=new Complex[10];
double SIZE[];
int PIECE[];
Color COLOR[];
int listen;
ViewCanvas V;
int AXIS;
int history;
int shadow;
PlayCanvas(double[] SIZE,int[] PIECE, Color[] COLOR) {
addMouseListener(this);
addMouseMotionListener(this);
this.SIZE=SIZE;
this.PIECE=PIECE;
this.COLOR=COLOR;
int side=PIECE[PIECE[0]+1];
int i;
for(i=1;i<10;++i) {
z[i]=new Complex();
z[i]=z[i].ZERO();
}
for(i=1;i<=PIECE[0];++i) {
P[i]=new PolyFlip(SIZE[2],SIZE[3],PIECE[i],side,z[i],0,0,0,COLOR);
}
listen=-1;
history=-5;
shadow=-1;
AXIS=0;
this.resize((int)(SIZE[0]),(int)(SIZE[0]));
}
public void paint(Graphics g) {
int i;
int x,y;
x=(int)(V.MOVE.x*SIZE[1]/V.SIZE[2]);
y=(int)(V.MOVE.y*SIZE[1]/V.SIZE[2]);
g.setColor(V.COLOR[20+V.BACK]);
g.drawRect(0,0,2*(int)(SIZE[1])-1,2*(int)(SIZE[1])-1);
g.translate((int)(SIZE[1]),(int)(SIZE[1]));
g.translate(-x,-y);
/*markers*/
if((AXIS==0)||(AXIS==2)) P[1].goal_render(g,V.COLOR[30+V.BACK]);
if((AXIS==1)||(AXIS==2)) {
g.setColor(V.COLOR[20+V.BACK]);
g.drawLine(-2000,0,2000,0);
g.drawLine(0,-2000,0,2000);
}
/*****************/
/*pieces*/
if((shadow>-1)&&(V.shadow_option==1)) {
for(i=1;i<=PIECE[0];++i) this.P[i].shadow_render(g,shadow,V.COLOR[20+V.BACK]);
}
for(i=1;i<=PIECE[0];++i) this.P[PIECE[0]+1-i].render(g,V.COLOR[20+V.BACK]);
/********/
g.setColor(V.COLOR[20+V.BACK]);
g.translate(-(int)(SIZE[1]),-(int)(SIZE[1]));
g.translate(x,y);
g.drawRect(0,0,2*(int)(SIZE[1])-1,2*(int)(SIZE[1])-1);
g.setColor(Color.blue);
g.fillRect((int)(2*SIZE[1]),0,(int)(SIZE[0]-2*SIZE[1]),(int)(SIZE[0]));
g.fillRect(0,(int)(2*SIZE[1]),(int)(SIZE[0]),(int)(SIZE[0]-2*SIZE[1]));
}
public void mouseDragged(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseEntered(MouseEvent e) { history=-3;}
public void mouseExited(MouseEvent e) {
shadow=-1;
repaint(0,0,(int)(2*SIZE[1]),(int)(2*SIZE[1]));
}
public void mouseReleased(MouseEvent e) {
shadow=-1;
if(listen>-1) repaint(0,0,(int)(2*SIZE[1]),(int)(2*SIZE[1]));
}
public void mouseClicked(MouseEvent e) {
int i;
e.consume();
Point p=new Point();
int x=(int)(V.MOVE.x*SIZE[1]/V.SIZE[2]);
int y=(int)(V.MOVE.y*SIZE[1]/V.SIZE[2]);
p.x=x+e.getX()-(int)(SIZE[1]);
p.y=y+e.getY()-(int)(SIZE[1]);
this.listen=this.P[1].inside(p);
for(i=2;i<=PIECE[0];++i) {
if(this.listen==-1) this.listen=this.P[i].inside(p);
}
p.x=e.getX()-(int)(SIZE[1]);
p.y=e.getY()-(int)(SIZE[1]);
if((p.x>SIZE[1])||(p.y>SIZE[1])) listen=-1;
for(i=1;i<=PIECE[0];++i) this.P[i]=this.P[i].flip(this.listen);
if(listen>=0) {
repaint(0,0,(int)(2*SIZE[1]),(int)(2*SIZE[1]));
V.repaint(2,2,(int)(2*V.SIZE[1]-4),(int)(2*V.SIZE[1]-4)); }
}
public void mouseMoved(MouseEvent e) {
int i;
e.consume();
Point p=new Point();
int x=(int)(V.MOVE.x*SIZE[1]/V.SIZE[2]);
int y=(int)(V.MOVE.y*SIZE[1]/V.SIZE[2]);
p.x=x+e.getX()-(int)(SIZE[1]);
p.y=y+e.getY()-(int)(SIZE[1]);
if(V.shadow_option==1) {
this.listen=this.P[1].inside(p);
for(i=2;i<=PIECE[0];++i) {
if(this.listen==-1) this.listen=this.P[i].inside(p);
}
p.x=e.getX()-(int)(SIZE[1]);
p.y=e.getY()-(int)(SIZE[1]);
if((p.x>SIZE[1])||(p.y>SIZE[1])) listen=-1;
if(listen!=history) {
shadow=listen;
history=listen;
repaint(1,1,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
}
}
PlayCanvas addView(ViewCanvas Y) {
PlayCanvas X=this;
X.V=Y;
return(X);
}
PlayCanvas reconfigure(int side) {
PlayCanvas Q=this;
if(side==5) {
Q.PIECE[0]=2;
Q.PIECE[1]=1;
Q.PIECE[2]=2;
Q.PIECE[3]=5;
}
if(side==6) {
Q.PIECE[0]=1;
Q.PIECE[1]=1;
Q.PIECE[2]=6;
}
if(side==7) {
Q.PIECE[0]=3;
Q.PIECE[1]=1;
Q.PIECE[2]=2;
Q.PIECE[3]=3;
Q.PIECE[4]=7;
}
if(side==8) {
Q.PIECE[0]=2;
Q.PIECE[1]=1;
Q.PIECE[2]=3;
Q.PIECE[3]=8;
}
if(side==9) {
Q.PIECE[0]=3;
Q.PIECE[1]=1;
Q.PIECE[2]=2;
Q.PIECE[3]=4;
Q.PIECE[4]=9;
}
if(side==10) {
Q.PIECE[0]=2;
Q.PIECE[1]=1;
Q.PIECE[2]=3;
Q.PIECE[3]=10;
}
if(side==11) {
Q.PIECE[0]=5;
Q.PIECE[1]=1;
Q.PIECE[2]=2;
Q.PIECE[3]=3;
Q.PIECE[4]=4;
Q.PIECE[5]=5;
Q.PIECE[6]=11;
}
if(side==12) {
Q.PIECE[0]=2;
Q.PIECE[1]=1;
Q.PIECE[2]=5;
Q.PIECE[3]=12;
}
if(side==13) {
Q.PIECE[0]=6;
Q.PIECE[1]=1;
Q.PIECE[2]=2;
Q.PIECE[3]=3;
Q.PIECE[4]=4;
Q.PIECE[5]=5;
Q.PIECE[6]=6;
Q.PIECE[7]=13;
}
SIZE[2]=Q.P[1].r1;
SIZE[3]=Q.P[1].r2;
int i;
for(i=1;i<=Q.PIECE[0];++i) {
Q.P[i]=new PolyFlip(SIZE[2],SIZE[3],PIECE[i],side,Q.z[i].ZERO(),0,0,0,COLOR);
}
return(Q);
}
}
class ViewCanvas extends Canvas implements MouseListener,MouseMotionListener {
double SIZE[];
Color COLOR[];
PlayCanvas P;
int listen;
int BACK;
Point MOVE=new Point();
int words;
int history;
int shadow_option;
String[] S;
ViewCanvas(double[] SIZE,Color COLOR[],PlayCanvas P) {
this.SIZE=SIZE;
this.COLOR=COLOR;
this.P=P;
addMouseListener(this);
addMouseMotionListener(this);
this.resize((int)(2*SIZE[1]+SIZE[1]/5),(int)(P.SIZE[0]));
setBackground(Color.black);
listen=-1;
BACK=0;
MOVE.x=0;
MOVE.y=0;
S=new String[5];
S[1]="Move the cursor over any part of";
S[2]="the control panel and you can read";
S[3]="here how that part functions";
words=1;
history=-4;
shadow_option=1;
}
public void paint(Graphics g) {
int i;
int[] s=new int[11];
s[1]=(int)(SIZE[1]);
s[2]=(int)(SIZE[1]/5);
s[3]=(int)(SIZE[2]);
s[4]=(int)(s[2]/2);
s[5]=(int)(s[2]/4);
g.setColor(Color.blue);
g.fillRect(0,2*s[1]+s[2],(int)(P.SIZE[0]),(int)(P.SIZE[0]));
/*wordbox*/
g.fillRect(0,2*s[1]+s[2]+5,2*s[1]+s[2]-6,3*s[2]);
g.setColor(Color.white);
g.setFont(new Font("TimesRoman",Font.PLAIN,15));
g.drawString(S[1],15,2*s[1]+s[2]+30);
g.drawString(S[2],15,2*s[1]+s[2]+45);
g.drawString(S[3],15,2*s[1]+s[2]+60);
/**********/
/*title*/
g.setColor(Color.yellow);
g.fillRect(0,3*s[1],2*s[1]+s[2]-1,4*s[2]);
g.setColor(Color.orange);
g.fillRect(0,3*s[1]+2*s[2],2*s[1]+s[2]-1,2*s[2]);
g.setColor(Color.black);
g.drawRect(0,3*s[1],2*s[1]+s[2]-1,4*s[2]);
g.setFont(new Font("TimesRoman",Font.PLAIN,30));
g.setColor(Color.black);
g.drawString("Lucy and Lily II",10,3*s[1]+30);
g.setFont(new Font("TimesRoman",Font.PLAIN,15));
g.drawString("c 2000 Rich Schwartz",37,3*s[1]+67);
g.drawOval(35,3*s[1]+57,12,12);
/**********/
g.setColor(COLOR[20+BACK]);
if(P.AXIS!=3) g.drawOval(s[1]-1,s[1]-1,2,2);
g.translate((int)(SIZE[1]),(int)(SIZE[1]));
g.translate(MOVE.x,MOVE.y);
g.setColor(COLOR[BACK]);
g.drawRect(-s[3],-s[3],2*s[3],2*s[3]);
g.translate(-MOVE.x,-MOVE.y);
for(i=1;i<=this.P.PIECE[0];++i) {
g.setColor(COLOR[20+BACK]);
int x=(int)(P.P[i].c.x*SIZE[2]/P.SIZE[1]);
int y=(int)(P.P[i].c.y*SIZE[2]/P.SIZE[1]);
if(P.P[i].hide==0) g.drawOval(x-2,y-2,4,4);
}
g.translate(-(int)(SIZE[1]),-(int)(SIZE[1]));
/*buttons*/
g.setColor(Color.cyan.darker());
g.fillRect(0,2*s[1],2*s[1],s[2]);
g.setColor(Color.yellow);
g.fillRect(2*s[1],0,s[2]-1,2*s[1]);
g.setColor(Color.yellow);
for(i=0;i<=4;++i) g.fillRect(i*s[2],2*s[1],s[2],s[2]);
g.setColor(Color.cyan);
for(i=4;i<=3+P.PIECE[0];++i) g.fillRect(i*s[2],2*s[1],s[2],s[2]);
g.setColor(Color.black);
for(i=0;i<=3+P.PIECE[0];++i) g.drawRect(i*s[2],2*s[1],s[2],s[2]);
g.setColor(Color.cyan);
g.fillRect(2*s[1],0,s[2],3*s[2]);
g.setColor(Color.green.brighter());
g.fillRect(2*s[1],3*s[2],s[2],4*s[2]);
g.setColor(Color.yellow);
g.fillRect(2*s[1],9*s[2],s[2],2*s[2]);
g.setColor(Color.black);
for(i=0;i<=10;++i) g.drawRect(2*s[1],i*s[2],s[2],s[2]);
g.setColor(COLOR[20+BACK]);
g.drawRect(0,0,2*s[1],2*s[1]);
g.setColor(Color.black);
g.drawRect(0,2*s[1],2*s[1]+s[2],s[2]-1);
g.drawRect(2*s[1],0,s[2]-1,2*s[1]+s[2]);
/**************/
/*button icons*/
g.setColor(Color.black);
for(i=1;i<=P.PIECE[0];++i) {
if(P.P[i].hide==0) g.drawOval((3+i)*s[2]+s[4]-2,2*s[1]+s[4]-2,4,4);
}
/*************/
g.drawOval(s[5],2*s[1]+s[5],s[4],s[4]);
/***************/
g.drawLine(s[2]+s[5],2*s[1]+s[5],s[2]+s[5],2*s[1]+s[4]);
g.drawLine(s[2]+s[5],2*s[1]+s[5],s[2]+s[4],2*s[1]+s[5]);
g.drawLine(s[2]+s[5],2*s[1]+s[5],s[2]+s[4],2*s[1]+s[4]);
/*******************/
g.drawLine(2*s[2]+s[4],2*s[1]+s[4],2*s[2]+s[5],2*s[1]+s[4]);
g.drawLine(2*s[2]+s[4],2*s[1]+s[4],2*s[2]+s[4],2*s[1]+s[5]);
g.drawLine(2*s[2]+s[5],2*s[1]+s[5],2*s[2]+s[4],2*s[1]+s[4]);
/********************/
g.translate(3*s[2],2*s[1]);
g.fillRect(s[5],+s[5]-2,s[4],s[5]+2);
g.drawRect(s[5],+s[5]-2,s[4],s[4]+3);
g.translate(-3*s[2],-2*s[1]);
/****************/
g.drawLine(2*s[1]+s[5],s[4]+2,2*s[1]+s[5]+s[4],s[4]+2);
g.drawLine(2*s[1]+s[5],s[4]-2,2*s[1]+s[5]+s[4],s[4]-2);
/****************/
g.drawLine(2*s[1]+s[4],s[2]+s[5],2*s[1]+s[4],s[2]+s[4]+s[5]);
g.drawLine(2*s[1]+s[5],s[2]+s[4],2*s[1]+s[5]+s[4],s[2]+s[4]);
/****************/
g.drawLine(2*s[1]+s[5],2*s[2]+s[4],2*s[1]+s[5]+s[4],2*s[2]+s[4]);
/***************/
g.translate(2*s[1],7*s[2]);
g.drawLine(s[5],s[4],s[5]+s[4],s[4]);
g.drawLine(s[4],s[5],s[4],s[5]+s[4]);
g.drawOval(s[4]-2,s[4]-2,4,4);
g.translate(-2*s[1],-7*s[2]);
g.translate(2*s[1],8*s[2]);
g.setColor(COLOR[10+BACK]);
g.fillRect(s[5],s[5],s[4],s[4]);
g.setColor(Color.black);
g.drawRect(s[5],s[5],s[4],s[4]);
g.translate(-2*s[1],-8*s[2]);
/****************/
g.drawRect(2*s[1]+s[5]-2,-s[2]+2*s[1]+s[5]-2,s[4]+4,s[4]+4);
g.drawLine(2*s[1]+s[4],-s[2]+2*s[1]+s[4],2*s[1]+s[4]+s[5]-1,-s[2]+2*s[1]+s[4]+s[5]-1);
g.drawLine(2*s[1]+s[4],-s[2]+2*s[1]+s[4],2*s[1]+s[4],-s[2]+2*s[1]+s[4]+s[5]-1);
g.drawLine(2*s[1]+s[4],-s[2]+2*s[1]+s[4],2*s[1]+s[4]+s[5]-1,-s[2]+2*s[1]+s[4]);
/****************/
g.translate(2*s[1],10*s[2]);
g.drawRect(s[5]-2,s[5]-2,s[4]+4,s[4]+4);
g.drawLine(s[4],s[4],s[4]+s[5]-1,s[4]+s[5]-1);
g.drawLine(s[4],s[4]+s[5]-1,s[4]+s[5]-1,s[4]+s[5]-1);
g.drawLine(s[4]+s[5]-1,s[4],+s[4]+s[5]-1,s[4]+s[5]-1);
g.translate(-2*s[1],-10*s[2]);
}
public void mouseDragged(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {
e.consume();
Point p=new Point();
p.x=e.getX();
p.y=e.getY();
int listen=0;
int i,sid;
sid=P.PIECE[P.PIECE[0]+1];
for(i=0;i<10;++i) {
if((p.y>2*SIZE[1])&&(p.x>i*SIZE[1]/5)&&(p.x<=(i+1)*SIZE[1]/5)) listen=i+1;
}
for(i=0;i<11;++i) {
if((p.x>2*SIZE[1])&&(p.y>i*SIZE[1]/5)&&(p.y<=(i+1)*SIZE[1]/5)) listen=i+11;
}
if(p.y>2.2*SIZE[1]) listen=-1;
p.x=e.getX()-(int)(SIZE[1]);
p.y=e.getY()-(int)(SIZE[1]);
if(listen==0) { MOVE=p; repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1]));}
if(listen==1) {
for(i=1;i<=P.PIECE[0];++i) P.P[i]=P.P[i].ring();
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1]));
}
if(listen==2) {
for(i=1;i<=P.PIECE[0];++i) P.P[i]=P.P[i].scale(1.0/0.9);
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1]));
}
if(listen==3) {
for(i=1;i<=P.PIECE[0];++i) P.P[i]=P.P[i].scale(0.9);
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1]));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
if(listen==4) {
int m;
int j,k;
shadow_option=1-shadow_option;
}
if((listen>=5)&&(listen<5+P.PIECE[0])) {
P.P[listen-4]=P.P[listen-4].hide();
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1]));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2.2*SIZE[1]-2));
}
if(listen==11) {
P=P.reconfigure(sid);
MOVE.x=0;
MOVE.y=0;
repaint(2,2,(int)(2.2*SIZE[1]-2),(int)(2.2*SIZE[1]-2));
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1]));
}
if(listen==12) {
if(sid<13) { P=P.reconfigure(sid+1);
MOVE.x=0;
MOVE.y=0;
repaint(2,2,(int)(2.2*SIZE[1]-2),(int)(2.2*SIZE[1]-2));
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1])); }
}
if(listen==13) {
if(sid>5) { P=P.reconfigure(sid-1);
MOVE.x=0;
MOVE.y=0;
repaint(2,2,(int)(2.2*SIZE[1]-2),(int)(2.2*SIZE[1]-2));
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1])); }
}
if(listen==14) {
int m;
int j,k;
for(k=1;k<=1;++k) {
m=P.P[1].random_integer();
for(j=1;j<=P.PIECE[0];++j) P.P[j]=P.P[j].flip(m);
P.repaint(0,0,(int)(2*P.SIZE[1]+21),(int)(2*P.SIZE[1]+21));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
}
if(listen==15) {
int m;
int j,k;
for(k=1;k<=5;++k) {
m=P.P[1].random_integer();
for(j=1;j<=P.PIECE[0];++j) P.P[j]=P.P[j].flip(m);
P.repaint(0,0,(int)(2*P.SIZE[1]+21),(int)(2*P.SIZE[1]+21));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
}
if(listen==16) {
int m;
int j,k;
for(k=1;k<=20;++k) {
m=P.P[1].random_integer();
for(j=1;j<=P.PIECE[0];++j) P.P[j]=P.P[j].flip(m);
P.repaint(0,0,(int)(2*P.SIZE[1]+21),(int)(2*P.SIZE[1]+21));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
}
if(listen==17) {
int m;
int j,k;
for(k=1;k<=50;++k) {
m=P.P[1].random_integer();
for(j=1;j<=P.PIECE[0];++j) P.P[j]=P.P[j].flip(m);
P.repaint(0,0,(int)(2*P.SIZE[1]+21),(int)(2*P.SIZE[1]+21));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
}
if(listen==18) {
P.AXIS=P.AXIS+1;
if(P.AXIS==4) P.AXIS=0;
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1]));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
if(listen==19) {
++BACK;
if(BACK==4)BACK=0;
setBackground(COLOR[10+BACK]);
P.setBackground(COLOR[10+BACK]);
P.repaint(0,0,(int)(2*P.SIZE[1]),(int)(2*P.SIZE[1]));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
if(listen==20) {
if(P.SIZE[1]>SIZE[1]+11) {
P.SIZE[1]=P.SIZE[1]-20;
P.repaint(0,0,(int)(2*P.SIZE[1]+41),(int)(2*P.SIZE[1]+41));
repaint(2,2,(int)(2*SIZE[1]-2),(int)(2*SIZE[1]-2));
}
}
if(listen==21) {
if(P.SIZE[1]=2*SIZE[1])&&(p.x>=i*SIZE[1]/5)&&(p.x<=(i+1)*SIZE[1]/5)) listen=i+1;
}
for(i=0;i<11;++i) {
if((p.x>=2*SIZE[1])&&(p.y>=i*SIZE[1]/5)&&(p.y<=(i+1)*SIZE[1]/5)) listen=i+11;
}
if(p.y>2.2*SIZE[1]) listen=-1;
if((listen==-1)&&(history!=listen))
{
S[1]="Move the cursor over any part of";
S[2]="the control panel and you can read";
S[3]="here how that part functions";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==0)&&(history!=listen))
{
S[1]="Viewport: records in miniature";
S[2]="the positions of the polygons.";
S[3]="";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==1)&&(history!=listen)) {
S[1]="";
S[2]="changes polygon style";
S[3]="";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==2)&&(history!=listen)) {
S[1]="";
S[2]="enlarges polygons";
S[3]="";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==3)&&(history!=listen)) {
S[1]="";
S[2]="shrinks polygons";
S[3]="";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==4)&&(history!=listen)) {
S[1]="";
S[2]="turns shadow option on/off";
S[3]="";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen>=5)&&(listen<=10)&&(history!=listen)) {
if(P.PIECE[0]>listen-5) {
S[1]="hide or uncover the polygon";
S[2]="bound to this button";
S[3]="";
}
if(P.PIECE[0]<=listen-5) {
S[1]="";
S[2]="no function";
S[3]="";
}
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==11)&&(history!=listen)) {
S[1]="reset game";
S[2]="";
S[3]="";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==12)&&(history!=listen)) {
S[1]="reset game and increase number";
S[2]="of sides of the polygons.";
S[3]="maximum is 13.";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==13)&&(history!=listen)) {
S[1]="reset game and decrease number";
S[2]="of sides of the polygons.";
S[3]="minimum is 5.";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==14)&&(history!=listen)) {
S[1]="Make 1 random move.";
S[2]="Start a new game by clicking";
S[3]="this button.";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==15)&&(history!=listen)) {
S[1]="Make 5 random moves.";
S[2]="Start a new game by clicking";
S[3]="this button.";history=listen;
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
}
if((listen==16)&&(history!=listen)) {
S[1]="Make 20 random moves.";
S[2]="Start a new game by clicking";
S[3]="this button.";history=listen;
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
}
if((listen==17)&&(history!=listen)) {
S[1]="Make 50 random moves.";
S[2]="Start a new game by clicking";
S[3]="this button.";history=listen;
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
}
if((listen==18)&&(history!=listen)) {
S[1]="Turns coordinate axes and";
S[2]="origin marker on and off.";
S[3]="Cycles through 4 options.";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==19)&&(history!=listen)) {
S[1]="";
S[2]="change background color";
S[3]="";
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
history=listen;
}
if((listen==20)&&(history!=listen)) {
S[1]="";
S[2]="shrink playing board";
S[3]="";history=listen;
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
}
if((listen==21)&&(history!=listen)) {
S[1]="";
S[2]="enlarge playing board";
S[3]="";history=listen;
repaint(6,(int)(2.2*SIZE[1]+7),(int)(2.2*SIZE[1]+6),(int)(3*SIZE[1]/5-1));
}
}
}
}
class ListenTriangle {
Polygon P;
ListenTriangle(Polygon P) {
this.P=P;
}
int inside(Point p)
{
int x1,x2,x3,y1,y2,y3;
int v1x,v1y,v2x,v2y;
int A1,A2,A3;
int value;
Polygon Q;
Q=this.P;
x1=Q.xpoints[0];
x2=Q.xpoints[1];
x3=Q.xpoints[2];
y1=Q.ypoints[0];
y2=Q.ypoints[1];
y3=Q.ypoints[2];
v1x=p.x-x1;
v1y=p.y-y1;
v2x=p.x-x2;
v2y=p.y-y2;
A3=v1x*v2y-v1y*v2x;
v1x=p.x-x2;
v1y=p.y-y2;
v2x=p.x-x3;
v2y=p.y-y3;
A1=v1x*v2y-v1y*v2x;
v1x=p.x-x3;
v1y=p.y-y3;
v2x=p.x-x1;
v2y=p.y-y1;
A2=v1x*v2y-v1y*v2x;
value=0;
if((A1<0)&&(A2<0)&&(A3<0)) value=1;
if((A1>0)&&(A2>0)&&(A3>0)) value=1;
return(value);
}
}
class Complex {
double x,y;
Complex() {
this.x=x;
this.y=y;
}
Complex ZERO() {
Complex z=new Complex();
z.x=0.0;
z.y=0.0;
return(z);
}
}
class PolyFlip {
Color[] C;
Complex c;
double r1,r2;
int mode;
int hide;
int angle;
int k,n;
PolyFlip(double r1,double r2,int k,int n,Complex c,int hide,int mode,int angle,Color[] C) {
this.k=k;
this.n=n;
this.r1=r1;
this.r2=r2;
this.c=c;
this.mode=mode;
this.hide=hide;
this.angle=angle;
this.C=C;
hide=0;
}
void render(Graphics g,Color C) {
double x1,x2,x3,y1,y2,y3,x4,y4,x5,y5;
int i,m;
double ii,nn;
Polygon P=new Polygon();
for(i=0;i-1) {
if(this.mode==0) {
ii=i*this.k;
nn=this.n;
x=this.r2*Math.cos(2.0*Math.PI*(this.angle+ii)/nn);
y=this.r2*Math.sin(2.0*Math.PI*(this.angle+ii)/nn);
len=2*Math.cos(Math.PI/nn);
Q.c.x=Q.c.x+len*x;
Q.c.y=Q.c.y-len*y;
Q.angle=this.angle+2*this.k*i;
}
if(this.mode==1) {
ii=-i*this.k;
nn=this.n;
x=this.r2*Math.cos(2.0*Math.PI*(this.angle+ii)/nn);
y=this.r2*Math.sin(2.0*Math.PI*(this.angle+ii)/nn);
len=2*Math.cos(Math.PI/nn);
Q.c.x=Q.c.x-len*x;
Q.c.y=Q.c.y+len*y;
Q.angle=-2*this.k*i+this.angle;
}
Q.mode=1-this.mode;
}
return(Q);
}
PolyFlip scale(double d) {
PolyFlip Q=this;
Q.c.x=d*Q.c.x;
Q.c.y=d*Q.c.y;
Q.r1=d*Q.r1;
Q.r2=d*Q.r2;
return(Q);
}
PolyFlip ring() {
PolyFlip Q=this;
Q.r1=Q.r1+.25*Q.r2;
if(Q.r1>.9*Q.r2) Q.r1=0;
return(Q);
}
int random_integer() {
double ran,ii,nn;
int tn=this.n;
int i;
int m;
m=tn-1;
ran=Math.random();
ran=ran-Math.floor(ran);
for(i=1;i=5)&&(listen<=10)&&(history!=listen)) {
if(P.PIECE[0]>listen-5) {
S[1]="hide or uncover