Develop and Download Open Source Software

Browse Subversion Repository

Diff of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 24 by yamat0jp, Sun Jul 19 01:35:48 2015 UTC revision 25 by yamat0jp, Mon Jul 20 00:50:13 2015 UTC
# Line 17  type Line 17  type
17    TEffectData = record    TEffectData = record
18      X, Y: integer;      X, Y: integer;
19      Left, Top: integer;      Left, Top: integer;
     Stone: TStoneType;  
20    end;    end;
21    
22    TGridData = array [0 .. Count - 1] of array [0 .. Count - 1] of TStoneType;    TGridData = array [0 .. Count - 1] of array [0 .. Count - 1] of TStoneType;
# Line 135  function TStoneGrid.CalScore(Stone: TSto Line 134  function TStoneGrid.CalScore(Stone: TSto
134  var  var
135    i, j: integer;    i, j: integer;
136  begin  begin
137      result:=0;
138    if CanSetStone(Stone, X, Y, true) = true then    if CanSetStone(Stone, X, Y, true) = true then
139    begin    begin
140        if Stone = stEffect then
141          Stone:=FEffectStone;
142      case Stone of      case Stone of
143        stBlack:        stBlack:
144          Stone := stWhite;          Stone := stWhite;
145        stWhite:        stWhite:
146          Stone := stBlack;          Stone := stBlack;
147        stEffect:        else
148          Stone := FEffectStone;          Exit;
149      end;      end;
     result := 0;  
150      for i := 0 to Count - 1 do      for i := 0 to Count - 1 do
151        for j := 0 to Count - 1 do        for j := 0 to Count - 1 do
152          if CanSetStone(Stone, i, j, false) = true then          if CanSetStone(Stone, i, j, false) = true then
153            inc(result);            inc(result);
     FStrings := FBuffer[FTurnIndex];  
   end  
   else  
   begin  
     FStrings := FBuffer[FTurnIndex];  
     result := -1;  
154    end;    end;
155      FStrings := FBuffer[FTurnIndex];
156  end;  end;
157    
158  function TStoneGrid.CanSetStone(Stone: TStoneType; X, Y: integer;  function TStoneGrid.CanSetStone(Stone: TStoneType; X, Y: integer;
# Line 197  var Line 193  var
193                  New(q);                  New(q);
194                  q^.Left := X + m * j;                  q^.Left := X + m * j;
195                  q^.Top := Y + n * j;                  q^.Top := Y + n * j;
                 q^.Stone := Stone;  
196                  q^.X := 0;                  q^.X := 0;
197                  q^.Y := 0;                  q^.Y := 0;
198                  FList.Add(q);                  FList.Add(q);
# Line 317  begin Line 312  begin
312        end        end
313        else        else
314        begin        begin
315          SetStrings(p^.Left, p^.Top, p^.Stone);          SetStrings(p^.Left, p^.Top, FEffectStone);
316          Dispose(p);          Dispose(p);
317          FList[i] := nil;          FList[i] := nil;
318        end;        end;
# Line 343  function TStoneGrid.NextStone(Stone: TSt Line 338  function TStoneGrid.NextStone(Stone: TSt
338  var  var
339    i, j, m, n: integer;    i, j, m, n: integer;
340  begin  begin
341    n := -1;    n := 0;
342    for i := 0 to Count - 1 do    for i := 0 to Count - 1 do
343      for j := 0 to Count - 1 do      for j := 0 to Count - 1 do
344      begin      begin
345        m := CalScore(Stone, i, j);        m := CalScore(Stone, i, j);
346        if (n = -1) or ((m > -1) and (n > m)) then        if ((n = 0)and(m > 0)) or ((0 < m) and (m < n)) then
347        begin        begin
348          n := m;          n := m;
349          result := Point(i, j);          result := Point(i, j);
350        end;        end;
351      end;      end;
352    if n = -1 then    if n = 0 then
353      result := Point(-1, -1);      result := Point(-1, -1);
354  end;  end;
355    
# Line 371  begin Line 366  begin
366    for i := 0 to FList.Count - 1 do    for i := 0 to FList.Count - 1 do
367    begin    begin
368      p := FList[i];      p := FList[i];
369      if p^.Stone = stBlack then      if FEffectStone = stBlack then
370        s := Form1.Image1.Bitmap        s := Form1.Image1.Bitmap
371      else      else
372        s := Form1.Image2.Bitmap;        s := Form1.Image2.Bitmap;
# Line 383  end; Line 378  end;
378    
379  procedure TStoneGrid.Pause;  procedure TStoneGrid.Pause;
380  begin  begin
381    if FActive = true then    FActive := false;
     FActive := false;  
382    FTerminated := true;    FTerminated := true;
383  end;  end;
384    
385  procedure TStoneGrid.Restart;  procedure TStoneGrid.Restart;
386  begin  begin
387    if FTerminated = true then    FActive := true;
388    begin    FTurnIndex := FTurnNumber;
389      FActive := true;    FTerminated := false;
     FTurnIndex := FTurnNumber;  
     FTerminated := false;  
   end;  
390  end;  end;
391    
392  procedure TStoneGrid.SetStrings(X, Y: integer; const Value: TStoneType);  procedure TStoneGrid.SetStrings(X, Y: integer; const Value: TStoneType);
# Line 444  var Line 435  var
435    function Execute: Boolean;    function Execute: Boolean;
436    var    var
437      i, j: integer;      i, j: integer;
     m: integer;  
     n: integer;  
438    begin    begin
439      for i := 0 to Count - 1 do      for i := 0 to Count - 1 do
440        for j := 0 to Count - 1 do        for j := 0 to Count - 1 do
# Line 458  var Line 447  var
447    end;    end;
448    
449  begin  begin
   Timer1.Enabled:=false;  
450    Main;    Main;
451    if Execute = false then    if Execute = false then
452    begin    begin
# Line 491  begin Line 479  begin
479    end    end
480    else    else
481      Caption := s;      Caption := s;
   Timer1.Enabled:=true;  
482  end;  end;
483    
484  procedure TForm1.CompStone;  procedure TForm1.CompStone;

Legend:
Removed from v.24  
changed lines
  Added in v.25

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26