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 33 by yamat0jp, Wed Aug 19 14:41:09 2015 UTC revision 34 by yamat0jp, Sun Aug 23 05:26:29 2015 UTC
# Line 91  type Line 91  type
91      Image1: TImage;      Image1: TImage;
92      Image2: TImage;      Image2: TImage;
93      Image3: TImage;      Image3: TImage;
94      Image4: TImage;      MenuItem13: TMenuItem;
95      Image5: TImage;      MenuItem14: TMenuItem;
96        MenuItem15: TMenuItem;
97      procedure FormCreate(Sender: TObject);      procedure FormCreate(Sender: TObject);
98      procedure FormDestroy(Sender: TObject);      procedure FormDestroy(Sender: TObject);
99      procedure Timer1Timer(Sender: TObject);      procedure Timer1Timer(Sender: TObject);
# Line 151  function TStoneGrid.CalScore(Stone: TSto Line 152  function TStoneGrid.CalScore(Stone: TSto
152    out Score: integer): Boolean;    out Score: integer): Boolean;
153  var  var
154    i, j: integer;    i, j: integer;
155      loop: integer;
156  const  const
157    wast: array [1 .. 12] of TPoint = ((X: 1; Y: 0), (X: 6; Y: 0), (X: 0; Y: 1),    waste: array [1 .. 12] of TPoint = ((X: 1; Y: 0), (X: 6; Y: 0), (X: 0; Y: 1),
158      (X: 1; Y: 1), (X: 6; Y: 1), (X: 7; Y: 1), (X: 0; Y: 6), (X: 1; Y: 6), (X: 6;      (X: 1; Y: 1), (X: 6; Y: 1), (X: 7; Y: 1), (X: 0; Y: 6), (X: 1; Y: 6), (X: 6;
159      Y: 6), (X: 7; Y: 6), (X: 1; Y: 7), (X: 6; Y: 7));      Y: 6), (X: 7; Y: 6), (X: 1; Y: 7), (X: 6; Y: 7));
160    worth: array [1 .. 4] of TPoint = ((X: 0; Y: 0), (X: 7; Y: 0), (X: 0; Y: 7),    worth: array [1 .. 4] of TPoint = ((X: 0; Y: 0), (X: 7; Y: 0), (X: 0; Y: 7),
161      (X: 7; Y: 7));      (X: 7; Y: 7));
162    label Last;
163      procedure Hard;
164      var
165        m, n: integer;
166      begin
167        if loop > 2 then
168          Exit;
169        inc(loop);
170        for m := 0 to bmp_count - 1 do
171          for n := 0 to bmp_count - 1 do
172          begin
173            if CanSetStone(Stone, m, n, true) = true then
174            begin
175              inc(Score, AddScore(m, n, worth));
176              if FTurnIndex + 1 < 50 then
177                dec(Score, AddScore(m, n, waste));
178              case Stone of
179                stBlack:
180                  Stone := stWhite;
181                stWhite:
182                  Stone := stBlack;
183              end;
184              Hard;
185            end;
186            FStrings := FBuffer[FTurnIndex + 1];
187          end;
188      end;
189    
190  begin  begin
191    if CanSetStone(Stone, X, Y, true) = true then    if CanSetStone(Stone, X, Y, true) = true then
192    begin    begin
193      Score := 0;      Score := 0;
194      result := true;      result := true;
195      if FTurnIndex < 50 then      if FTurnIndex < 50 then
196        inc(Score, AddScore(X, Y, wast));        inc(Score, AddScore(X, Y, waste));
197      dec(Score, AddScore(X, Y, worth));      dec(Score, AddScore(X, Y, worth));
198      case Stone of      case Stone of
199        stBlack:        stBlack:
# Line 171  begin Line 201  begin
201        stWhite:        stWhite:
202          Stone := stBlack;          Stone := stBlack;
203      end;      end;
204        if (Form1.MenuItem14.IsChecked = true) and (FTurnIndex + 1 >= 60) then
205        begin
206          FBuffer[FTurnIndex + 1] := FStrings;
207          loop := 0;
208          Hard;
209        end;
210      for i := 0 to bmp_count - 1 do      for i := 0 to bmp_count - 1 do
211        for j := 0 to bmp_count - 1 do        for j := 0 to bmp_count - 1 do
212          if CanSetStone(Stone, i, j, false) = true then          if CanSetStone(Stone, i, j, false) = true then
# Line 332  begin Line 368  begin
368      result := false      result := false
369    else    else
370    begin    begin
371      i:=0;      i := 0;
372      while i < FList.Count do      while i < FList.Count do
373      begin      begin
374        s := FList[i];        s := FList[i];
# Line 350  begin Line 386  begin
386          inc(i);          inc(i);
387          continue;          continue;
388        end;        end;
389        FList[i]:=s;        FList[i] := s;
390        inc(i);        inc(i);
391      end;      end;
392      if FList.Count = 0 then      if FList.Count = 0 then
# Line 387  end; Line 423  end;
423    
424  procedure TStoneGrid.Paint(Canvas: TCanvas);  procedure TStoneGrid.Paint(Canvas: TCanvas);
425  var  var
426    k, m, n: integer;    k: integer;
427    s: TBitmap;    s: TBitmap;
428    p: TEffectData;    p: TEffectData;
429  begin  begin
   m := Form1.Image3.Bitmap.Width;  
   n := Form1.Image3.Bitmap.Height;  
430    k := Form1.Size;    k := Form1.Size;
431    if FEffectStone = stBlack then    if FEffectStone = stBlack then
432      s := Form1.Image1.Bitmap      s := Form1.Image1.Bitmap
# Line 400  begin Line 434  begin
434      s := Form1.Image2.Bitmap;      s := Form1.Image2.Bitmap;
435    for p in FList do    for p in FList do
436    begin    begin
437      Canvas.DrawBitmap(s, RectF(p.X * m, p.Y * n, (p.X + 1) * m, (p.Y + 1) * n),      Canvas.DrawBitmap(s, RectF(p.X * 50, p.Y * 50, (p.X + 1) * 50,
438        RectF(p.Left * k, p.Top * k, (p.Left + 1) * k, (p.Top + 1) * k), 1);        (p.Y + 1) * 50), RectF(p.Left * k, p.Top * k, (p.Left + 1) * k,
439          (p.Top + 1) * k), 1);
440    end;    end;
441  end;  end;
442    
# Line 599  begin Line 634  begin
634      begin      begin
635        case StoneGrid.Strings[i, j] of        case StoneGrid.Strings[i, j] of
636          stWhite:          stWhite:
637            Canvas.DrawBitmap(Image4.Bitmap, RectF(0, 0, Image4.Bitmap.Width,            Canvas.DrawBitmap(Image3.Bitmap, RectF(100, 0, 150, 50),
638              Image4.Bitmap.Height), RectF(i * Size, j * Size, (i + 1) * Size,              RectF(i * Size, j * Size, (i + 1) * Size, (j + 1) * Size), 1);
             (j + 1) * Size), 1);  
639          stBlack:          stBlack:
640            Canvas.DrawBitmap(Image3.Bitmap, RectF(0, 0, Image3.Bitmap.Width,            Canvas.DrawBitmap(Image3.Bitmap, RectF(50, 0, 100, 50),
641              Image3.Bitmap.Height), RectF(i * Size, j * Size, (i + 1) * Size,              RectF(i * Size, j * Size, (i + 1) * Size, (j + 1) * Size), 1);
             (j + 1) * Size), 1);  
642          stEffect:          stEffect:
643            continue;            continue;
644        else        else
645          Canvas.DrawBitmap(Image5.Bitmap, RectF(0, 0, Image5.Bitmap.Width,          Canvas.DrawBitmap(Image3.Bitmap, RectF(0, 0, 50, 50),
646            Image5.Bitmap.Height), RectF(i * Size, j * Size, (i + 1) * Size,            RectF(i * Size, j * Size, (i + 1) * Size, (j + 1) * Size), 1);
           (j + 1) * Size), 1);  
647        end;        end;
648        Canvas.DrawLine(PointF(0, j * Size), PointF(bmp_count * Size,        Canvas.DrawLine(PointF(0, j * Size), PointF(bmp_count * Size,
649          j * Size), 1);          j * Size), 1);
# Line 631  end; Line 663  end;
663    
664  procedure TForm1.FormCreate(Sender: TObject);  procedure TForm1.FormCreate(Sender: TObject);
665  begin  begin
666    ClientWidth := 50 * bmp_count;    ClientWidth := 400;
667    ClientHeight := 50 * bmp_count;    ClientHeight := 400;
668    StoneGrid := TStoneGrid.Create;    StoneGrid := TStoneGrid.Create;
669    StoneGrid.ImageCount(6, 5);    StoneGrid.ImageCount(6, 5);
670    Player1 := TPlayer.Create;    Player1 := TPlayer.Create;

Legend:
Removed from v.33  
changed lines
  Added in v.34

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