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 36 by yamat0jp, Sat Aug 29 19:48:45 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 Easy;
164      var
165        m, n: integer;
166      begin
167        for m := 0 to bmp_count - 1 do
168          for n := 0 to bmp_count - 1 do
169            if CanSetStone(Stone, m, n, false) = true then
170            begin
171              inc(Score);
172              inc(Score, AddScore(m, n, worth));
173            end;
174      end;
175      procedure Hard;
176      var
177        m, n: integer;
178      begin
179        if loop > 1 then
180          Exit;
181        inc(loop);
182        for m := 0 to bmp_count - 1 do
183          for n := 0 to bmp_count - 1 do
184          begin
185            if CanSetStone(Stone, m, n, true) = true then
186            begin
187              if (loop mod 2) > 0 then
188              begin
189                inc(Score, AddScore(m, n, worth));
190                if FTurnIndex + loop < 50 then
191                  dec(Score, AddScore(m, n, waste));
192              end
193              else
194              begin
195                dec(Score, AddScore(m, n, worth));
196                if FTurnIndex + loop < 50 then
197                  inc(Score, AddScore(m, n, waste));
198              end;
199              case Stone of
200                stBlack:
201                  Stone := stWhite;
202                stWhite:
203                  Stone := stBlack;
204              end;
205              Hard;
206              if loop > 1 then
207              begin
208                Easy;
209                FStrings := FBuffer[FTurnIndex + loop];
210              end else
211                FBuffer[FTurnIndex + loop] := FStrings;
212            end;
213          end;
214        dec(loop);
215      end;
216    
217  begin  begin
218    if CanSetStone(Stone, X, Y, true) = true then    if CanSetStone(Stone, X, Y, true) = true then
219    begin    begin
220      Score := 0;      Score := 0;
221      result := true;      result := true;
222      if FTurnIndex < 50 then      if FTurnIndex < 50 then
223        inc(Score, AddScore(X, Y, wast));        inc(Score, AddScore(X, Y, waste));
224      dec(Score, AddScore(X, Y, worth));      dec(Score, AddScore(X, Y, worth));
225      case Stone of      case Stone of
226        stBlack:        stBlack:
# Line 171  begin Line 228  begin
228        stWhite:        stWhite:
229          Stone := stBlack;          Stone := stBlack;
230      end;      end;
231      for i := 0 to bmp_count - 1 do      if (Form1.MenuItem14.IsChecked = true) and (FTurnIndex + 2 <= 60) then
232        for j := 0 to bmp_count - 1 do      begin
233          if CanSetStone(Stone, i, j, false) = true then        loop := 0;
234          begin        Hard;
235            inc(Score);      end
236            inc(Score, AddScore(i, j, worth));      else
237          end;        Easy;
238    end    end
239    else    else
240      result := false;      result := false;
# Line 332  begin Line 389  begin
389      result := false      result := false
390    else    else
391    begin    begin
392      i:=0;      i := 0;
393      while i < FList.Count do      while i < FList.Count do
394      begin      begin
395        s := FList[i];        s := FList[i];
# Line 350  begin Line 407  begin
407          inc(i);          inc(i);
408          continue;          continue;
409        end;        end;
410        FList[i]:=s;        FList[i] := s;
411        inc(i);        inc(i);
412      end;      end;
413      if FList.Count = 0 then      if FList.Count = 0 then
# Line 387  end; Line 444  end;
444    
445  procedure TStoneGrid.Paint(Canvas: TCanvas);  procedure TStoneGrid.Paint(Canvas: TCanvas);
446  var  var
447    k, m, n: integer;    k: integer;
448    s: TBitmap;    s: TBitmap;
449    p: TEffectData;    p: TEffectData;
450  begin  begin
   m := Form1.Image3.Bitmap.Width;  
   n := Form1.Image3.Bitmap.Height;  
451    k := Form1.Size;    k := Form1.Size;
452    if FEffectStone = stBlack then    if FEffectStone = stBlack then
453      s := Form1.Image1.Bitmap      s := Form1.Image1.Bitmap
# Line 400  begin Line 455  begin
455      s := Form1.Image2.Bitmap;      s := Form1.Image2.Bitmap;
456    for p in FList do    for p in FList do
457    begin    begin
458      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,
459        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,
460          (p.Top + 1) * k), 1);
461    end;    end;
462  end;  end;
463    
# Line 599  begin Line 655  begin
655      begin      begin
656        case StoneGrid.Strings[i, j] of        case StoneGrid.Strings[i, j] of
657          stWhite:          stWhite:
658            Canvas.DrawBitmap(Image4.Bitmap, RectF(0, 0, Image4.Bitmap.Width,            Canvas.DrawBitmap(Image3.Bitmap, RectF(100, 0, 150, 50),
659              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);  
660          stBlack:          stBlack:
661            Canvas.DrawBitmap(Image3.Bitmap, RectF(0, 0, Image3.Bitmap.Width,            Canvas.DrawBitmap(Image3.Bitmap, RectF(50, 0, 100, 50),
662              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);  
663          stEffect:          stEffect:
664            continue;            continue;
665        else        else
666          Canvas.DrawBitmap(Image5.Bitmap, RectF(0, 0, Image5.Bitmap.Width,          Canvas.DrawBitmap(Image3.Bitmap, RectF(0, 0, 50, 50),
667            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);  
668        end;        end;
669        Canvas.DrawLine(PointF(0, j * Size), PointF(bmp_count * Size,        Canvas.DrawLine(PointF(0, j * Size), PointF(bmp_count * Size,
670          j * Size), 1);          j * Size), 1);
# Line 631  end; Line 684  end;
684    
685  procedure TForm1.FormCreate(Sender: TObject);  procedure TForm1.FormCreate(Sender: TObject);
686  begin  begin
687    ClientWidth := 50 * bmp_count;    ClientWidth := 400;
688    ClientHeight := 50 * bmp_count;    ClientHeight := 400;
689    StoneGrid := TStoneGrid.Create;    StoneGrid := TStoneGrid.Create;
690    StoneGrid.ImageCount(6, 5);    StoneGrid.ImageCount(6, 5);
691    Player1 := TPlayer.Create;    Player1 := TPlayer.Create;

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

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