else if(count1)
{
count = count==4? 3: count;
while(x=0xlengthy=0ylengthgrid[x][y]==0count4)
{
count=count+1;
x=x-displace_x;
y=y-displace_y;
}
if(count==4)
setMark(locX+displace_x, locY+displace_y);
else if(direction!=nil)
gobangAI5_2();
}
else if(direction!=nil)
gobangAI5_2();
}
private boolean gobang_SpaceAI(int x, int y) /* 璸衡逞缁?フ?竚 */
{
int space=0;
do
{
space=space+1;
x=x+displace_x;
y=y+displace_y;
}while(x=0xlengthy=0ylengthgrid[x][y]==0space4);
if(space+count=5) /* 逞缁?フ场だΤ硈絬ぇ?? */
return true;
else
{
space=0;
x=locX-displace_x;
y=locY-displace_y;
while(x=0xlengthy=0ylengthgrid[x][y]==0space4)
{
space=space+1;
x=x-displace_x;
y=y-displace_y;
}
if(space+count=5) /* 逞缁?フ场だΤ硈絬ぇ?? */
return true;
else
return false;
}
}
public void ThreadStart()
{
new Thread(this).start();
}
private void setMark(int x, int y)
{
steps.add(grids[x][y]);
grids[x][y].setValue(-1);
WinCheck();
turn=true;
}
/* 璸衡?ê?よ?Τ?隔 */
private void setMark2(int x, int y)
{
int space=0, temp_x=x, temp_y=y;
do
{
space=space+1;
temp_x=temp_x+displace_x;
temp_y=temp_y+displace_y;
}while(temp_x=0temp_xlengthtemp_y=0temp_ylengthgrid[temp_x][temp_y]==0space4);
if(space+step=5)
setMark(x, y);
else
setMark(x-(step+1)*displace_x, y-(step+1)*displace_y); /* э?癸翴 */
}
public void run()
{
try
{
switch(game_state)
{
case Start: Thread.sleep(2000);
dialog.show();
game_state=Playing;
repaint();
break;
case End: repaint();
Thread.sleep(1500);
ReStart();
repaint();
break;
}
}
catch(InterruptedException ex)
{
}
}
public void paint(Graphics g)
{
super.paint(g);
switch(game_state)
{
case Start: g.drawString("2005.7 by Yu Lin Tao", 91, 240);
g.setFont(font);
g.setColor(Color.BLUE);
g.drawString("Gobang", 112, 120);
g.drawImage(title, 134, 135, this);
break;
case Playing:
case End:
g.drawString("?产: 筿福:", 105, 40);
g.drawImage(black, 132, 30, this);
g.drawImage(white, 182, 30, this);
if(winner!=0)
{
g.setFont(font);
g.setColor(Color.RED);
message = winner==1? "?墓?":"?块?";
g.drawString(message, 120, 185);
}
break;
}
}
public void undo()
{
if(steps.size()0)
{
for(int i=0; i2; i++)
{
((Grid)steps.get(steps.size()-1)).Initial();
steps.remove(steps.size()-1);
}
}
}
private void Save()
{
String str;
try
{
File file = new File("innings.men");
file.createNewFile();
BufferedWriter write = new BufferedWriter(new FileWriter(file));
for(int i=0; isteps.size(); i++)
{
str=(((Grid)steps.get(i)).getLocX())+","+(((Grid)steps.get(i)).getLocY())+","+(((Grid)steps.get(i)).getValue());
write.write(str);
write.newLine();
}
write.close();
}
catch(Exception ex)
{
}
}
private void Load()
{
try
{
String[] step_array;
String str;
File file = new File("innings.men");
if(!file.exists())
{
JOptionPane.showMessageDialog(null, "⊿Τ?郎");
return;
}
BufferedReader read = new BufferedReader(new FileReader(file));
ReStart();
while(read.ready())
{
str=read.readLine();
step_array=str.split(",");
推荐阅读
- 保皇直播技巧,保皇游戏直播
- 云从科技新增ChatGPT概念,云从科技是什么公司
- 毕业设计模仿现有的网站吗,毕业设计论文去网上模仿
- 即时战略类游戏发展史小说,即时战略类的游戏
- linux命令逻辑符号 linux命令符号解释
- 电商如何发液体快递,液体怎么发国际快递
- 会展小程序开发功能,会展软件应用
- 无人直播图片动漫,无人直播效果怎么样
- php抓取首页数据 php获取当前页面url