| 53 |
function CalScore(Stone: TStoneType; X, Y: integer): integer; |
function CalScore(Stone: TStoneType; X, Y: integer): integer; |
| 54 |
function CanSetStone(Stone: TStoneType; X, Y: integer; Reverse: Boolean; |
function CanSetStone(Stone: TStoneType; X, Y: integer; Reverse: Boolean; |
| 55 |
const Visible: Boolean = false): Boolean; |
const Visible: Boolean = false): Boolean; |
| 56 |
function NextStone(Stone: TStoneType): TPoint; |
function NextStone(Stone: TStoneType; var Pos: TPoint): Boolean; |
| 57 |
procedure Start; |
procedure Start; |
| 58 |
procedure Restart; |
procedure Restart; |
| 59 |
procedure Pause; |
procedure Pause; |
| 134 |
var |
var |
| 135 |
i, j: integer; |
i, j: integer; |
| 136 |
begin |
begin |
| 137 |
result:=0; |
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 |
if Stone = stEffect then |
| 141 |
Stone:=FEffectStone; |
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 |
else |
else |
| 148 |
Exit; |
Exit; |
| 149 |
end; |
end; |
| 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 |
| 334 |
end; |
end; |
| 335 |
end; |
end; |
| 336 |
|
|
| 337 |
function TStoneGrid.NextStone(Stone: TStoneType): TPoint; |
function TStoneGrid.NextStone(Stone: TStoneType; var Pos: TPoint): Boolean; |
| 338 |
var |
var |
| 339 |
i, j, m, n: integer; |
i, j, m, n: integer; |
| 340 |
begin |
begin |
| 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 = 0)and(m > 0)) or ((0 < m) and (m < n)) 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); |
Pos := Point(i, j); |
| 350 |
end; |
end; |
| 351 |
end; |
end; |
| 352 |
if n = 0 then |
result := not(n = 0); |
|
result := Point(-1, -1); |
|
| 353 |
end; |
end; |
| 354 |
|
|
| 355 |
procedure TStoneGrid.Paint(Canvas: TCanvas); |
procedure TStoneGrid.Paint(Canvas: TCanvas); |
| 484 |
var |
var |
| 485 |
s: TPoint; |
s: TPoint; |
| 486 |
begin |
begin |
| 487 |
s := StoneGrid.NextStone(Index.Stone); |
if StoneGrid.NextStone(Index.Stone, s) = true then |
| 488 |
StoneGrid.CanSetStone(Index.Stone, s.X, s.Y, true, true); |
begin |
| 489 |
PaintBox1.Repaint; |
StoneGrid.CanSetStone(Index.Stone, s.X, s.Y, true, true); |
| 490 |
ChangePlayer; |
PaintBox1.Repaint; |
| 491 |
|
ChangePlayer; |
| 492 |
|
end; |
| 493 |
end; |
end; |
| 494 |
|
|
| 495 |
procedure TForm1.GameStart; |
procedure TForm1.GameStart; |
| 496 |
begin |
begin |
| 497 |
Timer1.Enabled:=false; |
Timer1.Enabled := false; |
| 498 |
Index := Player1; |
Index := Player1; |
| 499 |
StoneGrid.Start; |
StoneGrid.Start; |
| 500 |
PaintBox1.Repaint; |
PaintBox1.Repaint; |
| 501 |
Caption := '黒から始めます'; |
Caption := '黒から始めます'; |
| 502 |
Timer1.Enabled:=true; |
Timer1.Enabled := true; |
| 503 |
end; |
end; |
| 504 |
|
|
| 505 |
procedure TForm1.MenuItem10Click(Sender: TObject); |
procedure TForm1.MenuItem10Click(Sender: TObject); |