游戏开发论坛

 找回密码
 立即注册
搜索
楼主: lgb521

帮改下程序(三子棋)~万分感谢!

[复制链接]

0

主题

386

帖子

400

积分

中级会员

Rank: 3Rank: 3

积分
400
QQ
发表于 2008-6-19 16:38:00 | 显示全部楼层

Re: Re:帮改下程序(三子棋)~万分感谢!

yinzhijian: Re:帮改下程序(三子棋)~万分感谢!

还是blueicexfx比较实在  



什么意思啊。。。

187

主题

6490

帖子

6491

积分

论坛元老

团长

Rank: 8Rank: 8

积分
6491
发表于 2008-6-19 20:29:00 | 显示全部楼层

Re:帮改下程序(三子棋)~万分感谢!

include(libwinform.lib);
include(libwinformstyle.lib);
int bytPlayerTurn; //0=NoGame, 1=PlayerOne, 2=PlayerTwo;
int intP1Score,intP2Score;
int i;
string Status[0..8];
procedure main;
int intWS;
  createwindow(WF_Form,"frmMain");
  frmMain.Move((Screen_Width-5000)/2,(Screen_Height-3800)/2,5000,3800);
  intWS:=GetWindowStyle(frmMain.hwnd);
  frmMain.Caption:="Tic-Tac-Toe";
  intWS:=intWS-WS_SIZEBOX;
  SetWindowStyle(frmMain.hwnd,intWS);
  createwindow(WF_PictureBox,"ResBlank","frmMain");
  LoadPicture("resBlank.gif");
  frmMain.ResBlank.ReceivePicture(&quoticture");
  createwindow(WF_PictureBox,"ResX","frmMain");
  LoadPicture("resX.gif");
  frmMain.ResX.ReceivePicture("Picture");
  createwindow(WF_PictureBox,"ResO","frmMain");
  LoadPicture("resO.gif");
  frmMain.ResO.ReceivePicture("Picture");
  createwindow(WF_PictureBox,"Square0","frmMain");
  createwindow(WF_PictureBox,"Square1","frmMain");
  createwindow(WF_PictureBox,"Square2","frmMain");
  createwindow(WF_PictureBox,"Square3","frmMain");
  createwindow(WF_PictureBox,"Square4","frmMain");
  createwindow(WF_PictureBox,"Square5","frmMain");
  createwindow(WF_PictureBox,"Square6","frmMain");
  createwindow(WF_PictureBox,"Square7","frmMain");
  createwindow(WF_PictureBox,"Square8","frmMain");
  frmMain.Square0.Move(1,0,1000,1000);
  frmMain.Square1.Move(1008,0,1000,1000);
  frmMain.Square2.Move(2016,0,1000,1000);
  frmMain.Square3.Move(1,1008,1000,1000);
  frmMain.Square4.Move(1008,1008,1000,1000);
  frmMain.Square5.Move(2016,1008,1000,1000);
  frmMain.Square6.Move(1,2016,1000,1000);
  frmMain.Square7.Move(1008,2016,1000,1000);
  frmMain.Square8.Move(2016,2016,1000,1000);
  frmMain.Square0.BorderStyle:=0;
  frmMain.Square1.BorderStyle:=0;
  frmMain.Square2.BorderStyle:=0;
  frmMain.Square3.BorderStyle:=0;
  frmMain.Square4.BorderStyle:=0;
  frmMain.Square5.BorderStyle:=0;
  frmMain.Square6.BorderStyle:=0;
  frmMain.Square7.BorderStyle:=0;
  frmMain.Square8.BorderStyle:=0;
  frmMain.Square8.BorderStyle:=0;
  call ClearSquares;
  frmMain.Square0.Visible:=1;
  frmMain.Square1.Visible:=1;
  frmMain.Square2.Visible:=1;
  frmMain.Square3.Visible:=1;
  frmMain.Square4.Visible:=1;
  frmMain.Square5.Visible:=1;
  frmMain.Square6.Visible:=1;
  frmMain.Square7.Visible:=1;
  frmMain.Square8.Visible:=1;
  createwindow(WF_Label,"lblP1","frmMain");
  frmMain.lblP1.Move(3300,200,1000,300);
  frmMain.lblP1.Caption:="Player One";
  frmMain.lblP1.Visible:=1;
  createwindow(WF_Label,"lblP2","frmMain");
  frmMain.lblP2.Move(3300,700,1000,300);
  frmMain.lblP2.Caption:="Player Two";
  frmMain.lblP2.Visible:=1;
  createwindow(WF_Label,"lblP1Score","frmMain");
  frmMain.lblP1Score.Move(4300,200,1000,300);
  frmMain.lblP1Score.Caption:="0";
  frmMain.lblP1Score.Visible:=1;
  createwindow(WF_Label,"lblP2Score","frmMain");
  frmMain.lblP2Score.Move(4300,700,1000,300);
  frmMain.lblP2Score.Caption:="0";
  frmMain.lblP2Score.Visible:=1;
  createwindow(WF_Button,"cmdNewGame","frmMain");
  frmMain.cmdNewGame.Move(3300,2000,1000,400);
  frmMain.cmdNewGame.Caption:="New Game";
  frmMain.cmdNewGame.Visible:=1;
  createwindow(WF_Button,"cmdExit","frmMain");
  frmMain.cmdExit.Move(3300,2500,1000,400);
  frmMain.cmdExit.Caption:="Exit";
  frmMain.cmdExit.Visible:=1;
  Redraw(frmMain.hwnd);
  bytPlayerTurn:=0;
  intP1Score:=0;
  intP2Score:=0;
  frmMain.Show;
endprocedure;
procedure frmMain.Square0_Click;
  call NowSquareClick(0);
endprocedure;
procedure frmMain.Square1_Click;
  call NowSquareClick(1);
endprocedure;
procedure frmMain.Square2_Click;
  call NowSquareClick(2);
endprocedure;
procedure frmMain.Square3_Click;
  call NowSquareClick(3);
endprocedure;
procedure frmMain.Square4_Click;
  call NowSquareClick(4);
endprocedure;
procedure frmMain.Square5_Click;
  call NowSquareClick(5);
endprocedure;
procedure frmMain.Square6_Click;
  call NowSquareClick(6);
endprocedure;
procedure frmMain.Square7_Click;
  call NowSquareClick(7);
endprocedure;
procedure frmMain.Square8_Click;
  call NowSquareClick(8);
endprocedure;
procedure NowSquareClick(int Index);
int flag;
  if(bytPlayerTurn=0);messagebox("No Game is in progress at this time.");exit;endif;
  if(bytPlayerTurn=1);
    if(Status[Index]<>"");messagebox("This spot is already taken.");exit;endif;
    Status[Index]:="X";
    PaintSquare(Index,"X");
    flag:=CheckWin("X");
    if(CheckWin("X")=1);
      messagebox("Player One is the winner!");
      intP1Score:=intP1Score+1;
      frmMain.lblP1Score.Caption:=intP1Score;
      bytPlayerTurn:=0;
      exit;
    endif;
    bytPlayerTurn:=2;
  else;
    if(Status[Index]<>"");messagebox("This spot is already taken.");exit;endif;
    Status[Index]:="O";
    PaintSquare(Index,"O");
    if(CheckWin("O")=1);
      messagebox("Player Two is the winner!");
      intP2Score:=intP2Score+1;
      frmMain.lblP2Score.Caption:=intP2Score;
      bytPlayerTurn:=0;
      exit;
    endif;
    bytPlayerTurn:=1;
  endif;
endprocedure;
procedure PaintSquare(int Index,string CharToPaint);
  if(CharToPaint="X");
    frmMain.ResX.SendPicture("Picture");
  else;
    frmMain.ResO.SendPicture("Picture");
  endif;
  switch(Index);
    case(0);frmMain.Square0.ReceivePicture("Picture");break;
    case(1);frmMain.Square1.ReceivePicture("Picture");break;
    case(2);frmMain.Square2.ReceivePicture("Picture");break;
    case(3);frmMain.Square3.ReceivePicture("Picture");break;
    case(4);frmMain.Square4.ReceivePicture("Picture");break;
    case(5);frmMain.Square5.ReceivePicture("Picture");break;
    case(6);frmMain.Square6.ReceivePicture("Picture");break;
    case(7);frmMain.Square7.ReceivePicture("Picture");break;
    case(8);frmMain.Square8.ReceivePicture("Picture");break;
  endswitch;
endprocedure;
procedure CheckWin(string strLetter);
  if((Status[0]=strLetter)&&(Status[1]=strLetter)&&(Status[2]=strLetter));
    return(1);exit;
  endif;
  if((Status[3]=strLetter)&&(Status[4]=strLetter)&&(Status[5]=strLetter));
    return(1);exit;
  endif;
  if((Status[6]=strLetter)&&(Status[7]=strLetter)&&(Status[8]=strLetter));
    return(1);exit;
  endif;
  if((Status[0]=strLetter)&&(Status[3]=strLetter)&&(Status[6]=strLetter));
    return(1);exit;
  endif;
  if((Status[1]=strLetter)&&(Status[4]=strLetter)&&(Status[7]=strLetter));
    return(1);exit;
  endif;
  if((Status[2]=strLetter)&&(Status[5]=strLetter)&&(Status[8]=strLetter));
    return(1);exit;
  endif;
  if((Status[0]=strLetter)&&(Status[4]=strLetter)&&(Status[8]=strLetter));
    return(1);exit;
  endif;
  if((Status[2]=strLetter)&&(Status[4]=strLetter)&&(Status[6]=strLetter));
    return(1);exit;
  endif;
  return(0);
endprocedure;
procedure frmMain.cmdNewGame_Click;
  call ClearSquares;
  bytPlayerTurn:=1;
endprocedure;
procedure ClearSquares;
  frmMain.ResBlank.SendPicture("Picture");
  frmMain.Square0.ReceivePicture("Picture");
  frmMain.Square1.ReceivePicture("Picture");
  frmMain.Square2.ReceivePicture("Picture");
  frmMain.Square3.ReceivePicture("Picture");
  frmMain.Square4.ReceivePicture("Picture");
  frmMain.Square5.ReceivePicture("Picture");
  frmMain.Square6.ReceivePicture("Picture");
  frmMain.Square7.ReceivePicture("Picture");
  frmMain.Square8.ReceivePicture("Picture");
  for(i:=0,i<=8,i:=i+1);Status:="";next;
endprocedure;
procedure frmMain.cmdExit_Click;
  end;
endprocedure;

187

主题

6490

帖子

6491

积分

论坛元老

团长

Rank: 8Rank: 8

积分
6491
发表于 2008-6-19 20:30:00 | 显示全部楼层

Re:帮改下程序(三子棋)~万分感谢!

倒计时很简单。

人工智能嘛??有中间先占中间,没中间就想办法连成两个,有机会连三个的优先。

61

主题

1429

帖子

1430

积分

金牌会员

Rank: 6Rank: 6

积分
1430
发表于 2008-6-19 20:36:00 | 显示全部楼层

Re: Re:帮改下程序(三子棋)~万分感谢!

Miu.C: Re:帮改下程序(三子棋)~万分感谢!

include(libwinform.lib);
include(libwinformstyle.lib);
int bytPlayerTurn; //0=NoGame, 1=PlayerOne,...


这是什么垃圾呀!

187

主题

6490

帖子

6491

积分

论坛元老

团长

Rank: 8Rank: 8

积分
6491
发表于 2008-6-19 20:40:00 | 显示全部楼层

Re: Re: Re:帮改下程序(三子棋)~万分感谢!

使命召唤: Re: Re:帮改下程序(三子棋)~万分感谢!



这是什么垃圾呀!

我已经把这个应用到我的游戏中了哦~~~


int Answer;
int OriginalIndex;
procedure WelcomeBoard_Lookinto;
  messagebox("欢迎来到脚本系统测试地图","这张地图专为测试Afflatus",
"脚本系统而作","这张地图","涉及了控制这个游戏","的各个方面","使用方向键移动",
"在需要测试的项目前","按调查键即可测试该项目","Afflatus是完全免费","和开放源代码的","欢迎您在您的游戏中使用",
"Afflatus作为脚本系统","帮助您更高效地进行","游戏开发工作","有问题请联系我","我的邮件是",
"pokemon1024@hotmail.com","谢谢");
endprocedure;
procedure SpiritTestBoard_Lookinto;
  messagebox("这里是精灵控制测试区");
endprocedure;
procedure SpiritTest01_Lookinto;
  Answer:=Menu("是否开始精灵方向测试?","是","否");
  if(Answer=1);
    messagebox("你将看到一个女孩转动身体");
    Girl04.Position:=365;
    Girl04.Visible:=True;
    Girl04.Direction:=Aff_Up;Sleep(1);
    Girl04.Direction:=Aff_Left;Sleep(1);
    Girl04.Direction:=Aff_Down;Sleep(1);
    Girl04.Direction:=Aff_Right;Sleep(1);
    Girl04.Direction:=Aff_Up;Sleep(1);
    Girl04.Visible:=False;
    Girl04.PosX:=-1;
    Girl04.PosY:=-1;
  endif;
endprocedure;
procedure SpiritTest02_Lookinto;
  Answer:=Menu("是否开始精灵走动测试?","是","否");
  if(Answer=1);
    messagebox("你将看到一个女孩走动");
    Girl04.Move(13,11);
    Girl04.Visible:=True;
    Girl04.Direction:=Aff_Down;Girl04.Step(2);
    Girl04.Direction:=Aff_Right;Girl04.Step(2);
    Girl04.Direction:=Aff_Up;Girl04.Step(2);
    Girl04.Direction:=Aff_Left;Girl04.Step(5);
    Girl04.Direction:=Aff_Down;Girl04.Step(2);
    Girl04.Direction:=Aff_Right;Girl04.Step(2);
    Girl04.Direction:=Aff_Up;Girl04.Step(2);
    Girl04.Direction:=Aff_Right;Girl04.Step(1);
    Girl04.Visible:=False;
    Girl04.Move(-1,-1);
  endif;
endprocedure;
procedure SpiritTest03_Lookinto;
  Answer:=Menu("是否开始多精灵走动测试?","是","否");
  if(Answer=1);
    messagebox("你将看到一个男孩和一个女孩走动");
    Girl04.Move(10,11);
    Boy01.Move(13,11);
    Girl04.Visible:=True;
    Boy01.Visible:=True;
    Girl04.Direction:=Aff_Down;Boy01.Direction:=Aff_Down;
    MoveSpirits(2,"Girl04","Boy01");
    Girl04.Direction:=Aff_Right;Boy01.Direction:=Aff_Right;
    MoveSpirits(2,"Girl04","Boy01");
    Girl04.Direction:=Aff_Up;Boy01.Direction:=Aff_Up;
    MoveSpirits(2,"Girl04","Boy01");
    Girl04.Direction:=Aff_Left;Boy01.Direction:=Aff_Left;
    MoveSpirits(2,"Girl04","Boy01");
    Girl04.Visible:=False;
    Boy01.Visible:=False;
    Girl04.Move(-1,-1);
    Boy01.Move(-1,-1);
  endif;
endprocedure;
procedure SpiritTest04_Lookinto;
  Answer:=Menu("是否开始精灵Tip测试?","是","否");
  if(Answer=1);
    messagebox("你将看到自己头上的感叹号");
    Leader.Tip;
    messagebox("你将看到一个女孩头上的感叹号");
    Girl04.Move(12,11);
    Girl04.Direction:=Aff_Down;
    Girl04.Visible:=True;
    Girl04.Tip;
    Girl04.Visible:=False;
    Girl04.Move(-1,-1);
  endif;
endprocedure;
procedure SpiritTest05_Lookinto;
  Answer:=Menu("是否开始精灵顺序脚本测试?","开始","停止");
  if(Answer=1);
    FatBoy01.Move(10,10);
    FatBoy01.Reset;
    FatBoy01.Visible:=True;
    FatBoy01.Enabled:=True;
  else;
    FatBoy01.Move(-1,-1);
    FatBoy01.Visible:=False;
    FatBoy01.Enabled:=False;
  endif;
endprocedure;
procedure SpiritTest06_Lookinto;
  Answer:=Menu("是否开始精灵随机脚本测试?","开始","停止");
  if(Answer=1);
    DrOak.Move(13,12);
    DrOak.Visible:=True;
    DrOak.Enabled:=True;
  else;
    DrOak.Move(-1,-1);
    DrOak.Visible:=False;
    DrOak.Enabled:=False;
  endif;
endprocedure;
procedure SpiritTest07_Lookinto;
  Answer:=Menu("是否开始角色模型变化测试?","变成女孩","变成男孩","结束");
  if(Answer=1);
    Leader.Model:="Kyouko";
  endif;
  if(Answer=2);
    Leader.Model:="Rebooto";
  endif;
endprocedure;
procedure FatBoy01_Lookinto;
  messagebox("如果测试结果正确","我应该绕着这里走");
endprocedure;
procedure DrOak_Lookinto;
  messagebox("如果测试结果正确","我应该随机走动");
endprocedure;
procedure TileTestBoard_Lookinto;
  messagebox("这里是地形控制测试区");
endprocedure;
procedure TileTest01_Lookinto;
  Answer:=Menu("是否开始Tile变化测试1?","开始","恢复","结束");
  if(Answer=1);
    messagebox("你将看到怪兽球变成石头");
    OriginalIndex:=Mark01.BG1;
    Mark01.BG1:=Stone.Index;
  endif;
  if(Answer=2);
    if(Mark01.BG1<>Stone.Index);
      messagebox("已经是怪兽球了");
    else;
      messagebox("你将看到石头变回怪兽球");
      Mark01.BG1:=OriginalIndex;
    endif;
  endif;
endprocedure;
procedure TileTest02_Lookinto;
  Answer:=Menu("是否开始Tile变化测试2?","开始","恢复","结束");
  if(Answer=1);
    messagebox("你将看到怪兽球旁的盆景");
    Mark01.BG2:=Tree01.Index;
    Mark02.BG1:=Tree02.Index;
    Mark02.Collision:=True;
  endif;
  if(Answer=2);
    if(Mark01.BG2=0);
      messagebox("已经清除盆景了");
    else;
      messagebox("怪兽球上面的盆景将会消失");
      Mark01.BG2:=0;
      Mark02.BG1:=0;
      Mark02.Collision:=False;
    endif;
  endif;
endprocedure;
procedure TileTest03_Lookinto;
  Answer:=Menu("是否开始地形碰撞控制测试?","开始","恢复","结束");
  if(Answer=1);
    messagebox("怪兽球将可以通过");
    Mark01.Collision:=False;
  endif;
  if(Answer=2);
    messagebox("怪兽球将不可以通过");
    Mark01.Collision:=True;
  endif;
endprocedure;
procedure TileTest04_Lookinto;
  Answer:=Menu("是否开始地形动画播放测试?","是","否");
  if(Answer=1);
    Refresh;
    Mark01.PlayAnimation(1,"OpenDoor01");
  endif;
endprocedure;
procedure Mark01_Walkon;
  messagebox("正站在怪兽球上面");
endprocedure;
procedure GeneralTestBoard_Lookinto;
  messagebox("这里是常规项目测试区");
endprocedure;
procedure GeneralTest01_Lookinto;
  Answer:=Menu("是否进行图片输出测试?","是","否");
  if(Answer=1);
    messagebox("你将看到一张图片","按调查键这张图片才会消失");
    PaintPicture("gfx001",0);
    Refresh;
    messagebox("你将看到一张图片","这张图片保留到下一个对话框");
    PaintPicture("gfx001",-1);
    messagebox("看到了吗?","这张图片保留到了这个对话框","作为这次对话的背景");
    messagebox("你将看到一张图片","这张图片保留3秒钟");
    PaintPicture("gfx001",3);
    messagebox("测试结束");
  endif;
endprocedure;
procedure GeneralTest02_Lookinto;
string TextLine;
  Answer:=Menu("是否进行变量测试?","是","否");
  if(Answer=1);
    TextLine:=inputbox("请输入一个字符串","默认字符串");
    messagebox("你输入的是:"TextLine);
    TextLine:=inputbox("请输入一个表达式","(2+3)*2/5");
    TextLine:=CalcExpression(TextLine);
    messagebox("计算的结果是:"TextLine);
  endif;
endprocedure;
procedure GeneralTest03_Lookinto;
  Answer:=Menu("是否开始延迟特性测试?","是","否");
  if(Answer=1);
    messagebox("请和我一起读秒","从1开始数到5","每秒钟数一下","开始");
    messageboxdelay("1",1);
    messageboxdelay("2",1);
    messageboxdelay("3",1);
    messageboxdelay("4",1);
    messageboxdelay("5",1);
    messagebox("结束");
  endif;
endprocedure;
procedure GeneralTest04_Lookinto;
  Answer:=Menu("是否开始预设变量测试?","是","否");
  if(Answer=1);
    messagebox("现在的时间是:"Time,"现在的日期是:"Date);
  endif;
endprocedure;

0

主题

386

帖子

400

积分

中级会员

Rank: 3Rank: 3

积分
400
QQ
发表于 2008-6-19 21:41:00 | 显示全部楼层

Re: 帮改下程序(三子棋)~万分感谢!

Miu.C没做平局检测。。。。。

187

主题

6490

帖子

6491

积分

论坛元老

团长

Rank: 8Rank: 8

积分
6491
发表于 2008-6-19 22:07:00 | 显示全部楼层

Re: Re: 帮改下程序(三子棋)~万分感谢!

blueicexfx: Re: 帮改下程序(三子棋)~万分感谢!

Miu.C没做平局检测。。。。。

的确。

平局的时候只需要按重新开始游戏就可以了。

26

主题

537

帖子

537

积分

高级会员

Rank: 4

积分
537
发表于 2008-6-20 16:56:00 | 显示全部楼层

Re: Re:帮改下程序(三子棋)~万分感谢!

Miu.C: Re:帮改下程序(三子棋)~万分感谢!

倒计时很简单。

人工智能嘛??有中间先占中间,没中间就想办法连成两个,有机会连三个的优先。


你这次序有问题,应先判断是否存在赢点,有则选之;其次判断是否存在输点,有则堵之;第三才是有中间先占中间,没中间就想办法连成两个,还有第四、第五...
人工智能设计好了,三子棋电脑应永远不输

187

主题

6490

帖子

6491

积分

论坛元老

团长

Rank: 8Rank: 8

积分
6491
发表于 2008-6-20 18:11:00 | 显示全部楼层

Re: Re: Re:帮改下程序(三子棋)~万分感谢!

系统崩溃: Re: Re:帮改下程序(三子棋)~万分感谢!



你这次序有问题,应先判断是否存在赢点,有则选之;其次判断是否存在输点,有则堵之;第三才是有中间先占中间,没中间就想办法连成两个,还有第四、第五...
人工智能设计好了,三子棋电脑应永远不输

对!对!!!

O?X
O?X
???

电脑:O
人:X
电脑应该先选择连成一条才对。

还是您心思缜密。 [em5]

29

主题

475

帖子

483

积分

中级会员

Rank: 3Rank: 3

积分
483
发表于 2008-6-22 00:17:00 | 显示全部楼层

Re:帮改下程序(三子棋)~万分感谢!

三子棋我可是高手,哈哈
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-22 04:49

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表