不感觉不难,用drawgrid,棋盘的子数组来存储,然后遍厉

解决方案 »

  1.   

    It is very difficuty for me
      

  2.   

    也给我一份
    [email protected]
      

  3.   

    To   madyak (学习)  :1、要求是写算法,还是直接写程序在计算机上实现?
    2、要求多长时间完成???
      

  4.   

    我也想要一份,我刚开始学
    [email protected]
      

  5.   

    delphi盒子的斑竹的作品,拿来大家参考一下。
    (是两个人下,不是和电脑下。如果能和电脑下……可就麻烦多了)unit main;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ComCtrls, ScktComp, Grids, Menus, StdCtrls;type
      Tmainform = class(TForm)
        DrawGrid1: TDrawGrid;
        procedure FormCreate(Sender: TObject);
        procedure DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
          Rect: TRect; State: TGridDrawState);
        procedure DrawGrid1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
      private
        { Private declarations }
        Tag:array[0..18,0..18]of integer;
        {0 for none,1 for black,2 for white}
        IsBlack:boolean;
      public
        { Public declarations }
        function IsWin(IsBlack:boolean):boolean; //whether win
      end;var
      mainform: Tmainform;implementation{$R *.DFM}function Tmainform.IsWin(IsBlack:boolean):boolean;
    label exit1;
    var
      i,j:integer;
      wtag:integer;
    begin
      IsWin:=false;
      if IsBlack then
        wtag:=1 else
        wtag:=2;
      for i:=0 to 18 do
        for j:=0 to 14 do
        begin
          {是否有行连成}
          if (i<15)
          and(Tag[i,j]=wtag)
          and(Tag[i+1,j]=wtag)
          and(Tag[i+2,j]=wtag)
          and(Tag[i+3,j]=wtag)
          and(Tag[i+4,j]=wtag)
          then
          begin
            IsWin:=True;
            goto exit1;
          end;
          {是否有列连成}
          if (Tag[i,j]=wtag)
          and(Tag[i,j+1]=wtag)
          and(Tag[i,j+2]=wtag)
          and(Tag[i,j+3]=wtag)
          and(Tag[i,j+4]=wtag)
          then
          begin
            IsWin:=True;
            goto exit1;
          end;
          {是否有主对角线连成}
          if (i<15)
          and(Tag[i,j]=wtag)
          and(Tag[i+1,j+1]=wtag)
          and(Tag[i+2,j+2]=wtag)
          and(Tag[i+3,j+3]=wtag)
          and(Tag[i+4,j+4]=wtag)
          then
          begin
            IsWin:=True;
            goto exit1;
          end;
          {是否有副对角线连成}
          if (Tag[i,j]=wtag)
          and(Tag[i-1,j+1]=wtag)
          and(Tag[i-2,j+2]=wtag)
          and(Tag[i-3,j+3]=wtag)
          and(Tag[i-4,j+4]=wtag)
          then
          begin
            IsWin:=True;
            goto exit1;
          end;
        end;
      exit1:
    end;procedure Tmainform.FormCreate(Sender: TObject);
    var
      i,j:integer;
    begin
      for i:=0 to 18 do
        for j:=0 to 18 do
        begin
          Tag[i,j]:=0;
        end;
      IsBlack:=true;
      DrawGrid1.Canvas.Pen.Color :=clBlack;
      DrawGrid1.Canvas.Brush.Color :=clBlack;
    end;procedure Tmainform.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      DrawGrid1.Canvas.Pen.Color :=clBlack;
      DrawGrid1.Canvas.Brush.Color :=clBlack;
      if tag[acol,arow]=1 then
        DrawGrid1.Canvas.Ellipse(acol*21,arow*21,(acol+1)*21,(arow+1)*21)
        else if tag[acol,arow]=2 then
          DrawGrid1.Canvas.Arc(acol*21,arow*21,(acol+1)*21,(arow+1)*21,acol*21,arow*21,acol*21,arow*21)
          else
          begin
            DrawGrid1.Canvas.Pen.Color :=clWhite;
            DrawGrid1.Canvas.Brush.Color :=clWhite;
            DrawGrid1.Canvas.Ellipse(acol*21,arow*21,(acol+1)*21,(arow+1)*21);
          end;
    end;procedure Tmainform.DrawGrid1MouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    var
      col,row:integer;
      i,j:integer;
    begin
      DrawGrid1.Canvas.Pen.Color :=clBlack;
      DrawGrid1.Canvas.Brush.Color :=clBlack;
      DrawGrid1.MouseToCell(x,y,col,row);
      if tag[col,row]=0 then
      begin
        if IsBlack then
        begin
          DrawGrid1.Canvas.Ellipse(col*21,row*21,(col+1)*21,(row+1)*21);
          tag[col,row]:=1;
        end else
        begin
          DrawGrid1.Canvas.Arc(col*21,row*21,(col+1)*21,(row+1)*21,col*21,row*21,col*21,row*21);
          tag[col,row]:=2;
        end;
        if IsWin(IsBlack) then
        begin
          if IsBlack then
            if MessageDlg('黑不垃圾的赢了',mtInformation,[mbOK],0)=mrOK then
            begin
              for i:=0 to 18 do
                for j:=0 to 18 do
                begin
                  tag[i,j]:=0;
                end;
              DrawGrid1.Invalidate;
            end;
          if not IsBlack then
            if MessageDlg('白猪赢了',mtInformation,[mbOK],0)=mrOK then
            begin
              for i:=0 to 18 do
                for j:=0 to 18 do
                begin
                  tag[i,j]:=0;
                end;
              DrawGrid1.Invalidate;
            end;
          end;
          IsBlack:=not IsBlack;
        end;
    end;end.
      

  6.   

    此题要求:用他们单位的电脑,在8个小时内完成,中间有一个小时时间在他们单位吃饭。其间不得离开现场,除了Delphi自带的在线帮助外,不得查阅任何资料!
      

  7.   

    我以前主要用Delphi做数据据库。除了最常见的算法熟悉外。很少研究这之类的算法。本人不是计算机专业科班出身。这道题我感觉是太难了!
      

  8.   

    我想看看源码!谢谢了
    [email protected]
      

  9.   

    我做了了一个局域网五子棋对战游戏,出现了问题,源代码在此,请各位调试,校正错误!该帖子在http://www.csdn.net/expert/topic/633/633325.xml?temp=.9411127
      

  10.   

    我也要一份
    [email protected]谢了
      

  11.   

    如果把这个问题理解成人工智能的话,
    没有点理论和实践,8小时完成这个题目相当有难度。
    (个人觉得,理应还有其他渠道解决这个问题,
    不知道出题目的公司是哪里的?如若在MSDN上看到这个
    问题,希望多多指教  ...... )
    我在大四的时候做过中国象棋的人机博弈程序,
    我有十成把握,我8个小时一定作不完。
    对这个问题,我是有完成它的思路,但是很多很烦琐的
    东西,相当费时费劲的。---------------------------------
    其实网上大把的中国象棋、五子棋、国际象棋
    人机博弈的程序,到搜索引擎上搜索一下。
    我有别人用    C  写的中国象棋(下载后,我从未认真看过),
    当然也有我用  VB 写的中国象棋,有需要的话 。 。 。