//
// Game2 2002/02/10 by ONOZATO Takehisa
//
// 石の並べ替え(おしどりの遊び)
//
//
//
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Game2 extends Applet implements MouseListener,ItemListener,ActionListener{
Image ofs; Graphics ofsGrf; //オフスクリーン
int ofsWidth=600; int ofsHeight=160;
Color ofsBG=new Color(255,239,223); //背景色
Choice cho; //選択メニュー
int choLeft=40; int choTop=20;
int choWidth=70; int choHeight=25;
String choList[]={" n = 3 "," n = 4 ",
" n = 5 "," n = 6 "," n = 7 "};
//選択項目
int choIndex;
Button btn; //ボタン
int btnLeft=150; int btnTop=20;
int btnWidth=60; int btnHeight=20;
String btnCaption="reset";
int LWidth=3; //セルの枠線
int CellLeft=40; int CellTop=80; //セル
int CellWidth=30; int CellHeight=30;
int nStone; int nCell; //各石の個数,セルの個数
int step; //手数
int CellState[]=new int[17]; //セルの状態 0:空 1:赤 2:白
int emptyCell; //空のセルの番号(左側)
public void init() {
choIndex=0; //初期値
nStone=choIndex+3; nCell=2*nStone+2;
step=0; emptyCell=2*nStone+1; //初期状態設定
CellState[emptyCell]=0; CellState[emptyCell+1]=0;
for(int i=1; i<=nStone; i++){
CellState[2*i-1]=1; CellState[2*i]=2;
}
ofs=createImage(ofsWidth,ofsHeight); ofsGrf=ofs.getGraphics();
cho=new Choice(); //選択メニュー
for(int i=0; iCellTop && y=1 && j