⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.txt

📁 有很多不足,需要在次修改!特别是算法和有点弱,要用需要好好考虑!
💻 TXT
📖 第 1 页 / 共 2 页
字号:
  begin   
      /////////////此处做得比较差,但我不想动脑了   
      if   whocontrol=0   then   exit;   
      if   (x>(16*30+10))or(x<16)or(y>(16*30+10))or(y<16)then   exit;   
      i:=(x   div   30)+((x   mod   30)div   15);   
      j:=(y   div   30)+((y   mod   30)div   15);   
      if   (i<1)or(i>15)or(j<1)or(j>15)or(canvas.Pixels[i*30,j*30]=clwhite)   
          or(canvas.Pixels[i*30,j*30]=clblack)   then   exit;   
      //////////////////////////////   
      loc[i,j]:=whocontrol;   
      with   canvas   do   
      begin   
          if   whocontrol=1   then   
          begin   
              Pen.Color:=clblack;   
              Brush.Color:=clblack;   
          end   
          else   if   whocontrol=2   then   
          begin   
              Pen.Color:=clwhite;   
              Brush.Color:=clwhite;   
          end;   
          Ellipse(i*30-14,j*30-14,i*30+14,j*30+14);   
      end;   
      i:=haswin(i,j);   
      if   i<>0   then   
      begin   
          showmessage('player   '+inttostr(i)+'   is   win!');   
          whocontrol:=0;   
          exit;   
      end;   
      whocontrol:=(whocontrol   mod   2)+1;   
  end;   
    
  function   TForm1.hasWin(x,   y:   integer):   integer;   
  var   
      i,j:integer;   
  begin   
      result:=0;   
      for   i:=x-4   to   x+4   do   
          for   j:=y-4   to   y+4   do   
          begin   
              if(i>0)and(i<12)and(loc[i,y]<>0)and(loc[i,y]=loc[i+1,y])   
                  and(loc[i,y]=loc[i+2,y])and(loc[i,y]=loc[i+3,y])   
                  and(loc[i,y]=loc[i+4,y])then   
              begin   
                  result:=whocontrol;   
                  exit;   
              end;   
              ///////////////////////////   
              if(j>0)and(j<12)and(not(loc[x,j]=0))and(loc[x,j]=loc[x,j+1])   
                  and(loc[x,j]=loc[x,j+2])and(loc[x,j]=loc[x,j+3])   
                  and(loc[x,j]=loc[x,j+4])then   
              begin   
                  result:=whocontrol;   
                  exit;   
              end;   
              ////////////////////////////   
              if(i>0)and(j>0)and(i<12)and(j<12)and(loc[i,j]<>0)   
                  and(loc[i,j]=loc[i+1,j+1])and(loc[i,j]=loc[i+2,j+2])   
                  and(loc[i,j]=loc[i+3,j+3])and(loc[i,j]=loc[i+4,j+4])then   
              begin   
                  result:=whocontrol;   
                  exit;   
              end;   
              /////////////////////////////   
              if(i>=5)and(j<12)and(i<16)and(j>0)and(loc[i,j]<>0)and   
                  (loc[i,j]=loc[i-1,j+1])and(loc[i,j]=loc[i-2,j+2])and   
                  (loc[i,j]=loc[i-3,j+3])and(loc[i,j]=loc[i-4,j+4])then   
              begin   
                  result:=whocontrol;   
                  exit;   
              end;   
          end;   
      ////////////////////////   
      if   threecount(x,y)=2   then   
          result:=(whocontrol   mod   2)+1;   
  end;   
    
  function   TForm1.threecount(x,   y:   integer):   integer;   
  begin   
      //////////////////////////三三未做   
      result:=0;   
  end;   
    
  end.   
  
Top


  unit   Unit1;   
    
  interface   
    
  uses   
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,   
      Dialogs,printers,   StdCtrls,   ExtCtrls,   Menus;   
    
  type   
      TForm1   =   class(TForm)   
          Button1:   TButton;   
          Button2:   TButton;   
          procedure   FormPaint(Sender:   TObject);   
          procedure   FormCreate(Sender:   TObject);   
          procedure   Button1Click(Sender:   TObject);   
          procedure   FormMouseDown(Sender:   TObject;   Button:   TMouseButton;   
              Shift:   TShiftState;   X,   Y:   Integer);   
      private   
          {   Private   declarations   }   
          function   hasWin(x,y:integer):integer;   
          function   threecount(x,y:integer):integer;   
      public   
          {   Public   declarations   }   
          loc:array[1..15,1..15]of   integer;   
          whocontrol:integer;//0   is   none,,,,1   is   black,,,,2   is   white;   
      end;   
    
  var   
      Form1:   TForm1;   
    
  implementation   
    
  {$R   *.dfm}   
    
  procedure   TForm1.FormPaint(Sender:   TObject);   
  var   
      i,j:integer;   
  begin   
      with   canvas   do   
      begin   
          Pen.Color:=clred;   
          Brush.Color:=color;   
          for   i:=1   to   15   do   
          begin   
              MoveTo(i*30,30);   
              LineTo(i*30,15*30);   
              TextOut(i*30-5,5,inttostr(i));   
              ////////////////////////////////////   
              MoveTo(30,i*30);   
              LineTo(15*30,i*30);   
              TextOut(5,i*30-5,inttostr(i));   
          end;   
          Brush.Color:=clred;   
          Ellipse(8*30-7,8*30-7,8*30+7,8*30+7);   
          for   i:=1   to   15   do   
              for   j:=1   to   15   do   
              begin   
                  if   loc[i,j]=1   then   
                  begin   
                      Pen.Color:=clblack;   
                      Brush.Color:=clblack;   
                      Ellipse(i*30-14,j*30-14,i*30+14,j*30+14);   
                  end   
                  else   if   loc[i,j]=2   then   
                  begin   
                      Pen.Color:=clwhite;   
                      Brush.Color:=clwhite;   
                      Ellipse(i*30-14,j*30-14,i*30+14,j*30+14);   
                  end;   
              end;   
      end;   
  end;   
    
  procedure   TForm1.FormCreate(Sender:   TObject);   
  begin   
      left:=(screen.Width-width)div   2;   
      top:=(screen.Height-height)div   2;   
      ////////////   
      self.Button1Click(sender);   
  end;   
    
  procedure   TForm1.Button1Click(Sender:   TObject);   
  var   
      i,j:integer;   
  begin   
      WhoControl:=1;//black;   
      for   i:=1   to   15   do   
          for   j:=1   to   15   do   
              loc[i,j]:=0;   
      self.Refresh;   
  end;   
    
  procedure   TForm1.FormMouseDown(Sender:   TObject;   Button:   TMouseButton;   
      Shift:   TShiftState;   X,   Y:   Integer);   
  var   
      i,j:integer;   
  begin   
      /////////////此处做得比较差,但我不想动脑了   
      if   whocontrol=0   then   exit;   
      if   (x>(16*30+10))or(x<16)or(y>(16*30+10))or(y<16)then   exit;   
      i:=(x   div   30)+((x   mod   30)div   15);   
      j:=(y   div   30)+((y   mod   30)div   15);   
      if   (i<1)or(i>15)or(j<1)or(j>15)or(canvas.Pixels[i*30,j*30]=clwhite)   
          or(canvas.Pixels[i*30,j*30]=clblack)   then   exit;   
      //////////////////////////////   
      loc[i,j]:=whocontrol;   
      with   canvas   do   
      begin   
          if   whocontrol=1   then   
          begin   
              Pen.Color:=clblack;   
              Brush.Color:=clblack;   
          end   
          else   if   whocontrol=2   then   
          begin   
              Pen.Color:=clwhite;   
              Brush.Color:=clwhite;   
          end;   
          Ellipse(i*30-14,j*30-14,i*30+14,j*30+14);   
      end;   
      i:=haswin(i,j);   
      if   i<>0   then   
      begin   
          showmessage('player   '+inttostr(i)+'   is   win!');   
          whocontrol:=0;   
          exit;   
      end;   
      whocontrol:=(whocontrol   mod   2)+1;   
  end;   
    
  function   TForm1.hasWin(x,   y:   integer):   integer;   
  var   
      i,j:integer;   
  begin   
      result:=0;   
      for   i:=x-4   to   x+4   do   
          for   j:=y-4   to   y+4   do   
          begin   
              if(i>0)and(i<12)and(loc[i,y]<>0)and(loc[i,y]=loc[i+1,y])   
                  and(loc[i,y]=loc[i+2,y])and(loc[i,y]=loc[i+3,y])   
                  and(loc[i,y]=loc[i+4,y])then   
              begin   
                  result:=whocontrol;   
                  exit;   
              end;   
              ///////////////////////////   
              if(j>0)and(j<12)and(not(loc[x,j]=0))and(loc[x,j]=loc[x,j+1])   
                  and(loc[x,j]=loc[x,j+2])and(loc[x,j]=loc[x,j+3])   
                  and(loc[x,j]=loc[x,j+4])then   
              begin   
                  result:=whocontrol;   
                  exit;   
              end;   
              ////////////////////////////   
              if(i>0)and(j>0)and(i<12)and(j<12)and(loc[i,j]<>0)   
                  and(loc[i,j]=loc[i+1,j+1])and(loc[i,j]=loc[i+2,j+2])   
                  and(loc[i,j]=loc[i+3,j+3])and(loc[i,j]=loc[i+4,j+4])then   
              begin   
                  result:=whocontrol;   
                  exit;   
              end;   
              /////////////////////////////   
              if(i>=5)and(j<12)and(i<16)and(j>0)and(loc[i,j]<>0)and   
                  (loc[i,j]=loc[i-1,j+1])and(loc[i,j]=loc[i-2,j+2])and   
                  (loc[i,j]=loc[i-3,j+3])and(loc[i,j]=loc[i-4,j+4])then   
              begin   
                  result:=whocontrol;   
                  exit;   
              end;   
          end;   
      ////////////////////////   
      if   threecount(x,y)=2   then   
          result:=(whocontrol   mod   2)+1;   
  end;   
    
  function   TForm1.threecount(x,   y:   integer):   integer;   
  begin   
      //////////////////////////三三未做   
      result:=0;   
  end;   
    
  end.   
  
Top
  
    
  unit   Unit1;   
    
  interface   
    
  uses   
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,   
      Dialogs,printers,   StdCtrls,   ExtCtrls,   Menus;   
    
  type   
      TForm1   =   class(TForm)   
          Button1:   TButton;   
          Button2:   TButton;   
          procedure   FormPaint(Sender:   TObject);   
          procedure   FormCreate(Sender:   TObject);   
          procedure   Button1Click(Sender:   TObject);   
          procedure   FormMouseDown(Sender:   TObject;   Button:   TMouseButton;   
              Shift:   TShiftState;   X,   Y:   Integer);   
      private   
          {   Private   declarations   }   
          function   hasWin(x,y:integer):integer;   
          function   threecount(x,y:integer):integer;   
      public   
          {   Public   declarations   }   
          loc:array[1..15,1..15]of   integer;   
          whocontrol:integer;//0   is   none,,,,1   is   black,,,,2   is   white;   
      end;   
    
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -