| 216 |
end; |
end; |
| 217 |
|
|
| 218 |
begin |
begin |
| 219 |
|
result := false; |
| 220 |
if Visible = true then |
if Visible = true then |
| 221 |
begin |
begin |
| 222 |
FBool := FActive; |
FBool := FActive; |
| 223 |
FActive := false; |
FActive := false; |
| 224 |
end; |
end; |
|
result := false; |
|
| 225 |
p := true; |
p := true; |
| 226 |
if GetStrings(X, Y) = stNone then |
if GetStrings(X, Y) = stNone then |
| 227 |
begin |
begin |
| 409 |
procedure Main; |
procedure Main; |
| 410 |
begin |
begin |
| 411 |
if Index = Player1 then |
if Index = Player1 then |
| 412 |
Index := Player2 |
begin |
| 413 |
|
Index := Player2; |
| 414 |
|
s := '白の手番です'; |
| 415 |
|
end |
| 416 |
else |
else |
| 417 |
|
begin |
| 418 |
Index := Player1; |
Index := Player1; |
| 419 |
|
s := '黒の手番です'; |
| 420 |
|
end; |
| 421 |
end; |
end; |
| 422 |
function Execute: Boolean; |
function Execute: Boolean; |
| 423 |
var |
var |
| 424 |
i, j: integer; |
i, j: integer; |
| 425 |
|
m: integer; |
| 426 |
|
n: integer; |
| 427 |
begin |
begin |
|
result := false; |
|
| 428 |
for i := 0 to Count - 1 do |
for i := 0 to Count - 1 do |
| 429 |
for j := 0 to Count - 1 do |
for j := 0 to Count - 1 do |
| 430 |
if StoneGrid.CanSetStone(Index.Stone, i, j, false) = true then |
if StoneGrid.CanSetStone(Index.Stone, i, j, false) = true then |
| 432 |
result := true; |
result := true; |
| 433 |
Exit; |
Exit; |
| 434 |
end; |
end; |
| 435 |
|
result := false; |
| 436 |
end; |
end; |
| 437 |
|
|
| 438 |
begin |
begin |
| 443 |
if Execute = false then |
if Execute = false then |
| 444 |
begin |
begin |
| 445 |
StoneGrid.Pause; |
StoneGrid.Pause; |
|
Timer1.Enabled := false; |
|
| 446 |
m := 0; |
m := 0; |
| 447 |
n := 0; |
n := 0; |
| 448 |
for i := 0 to Count - 1 do |
for i := 0 to Count - 1 do |
| 453 |
stWhite: |
stWhite: |
| 454 |
inc(n); |
inc(n); |
| 455 |
end; |
end; |
| 456 |
|
Caption := s; |
| 457 |
if m > n then |
if m > n then |
| 458 |
s := 'Player1 Win:' + #13#10 |
s := 'Player1 Win:' + #13#10 |
| 459 |
else if m < n then |
else if m < n then |
| 462 |
s := 'Draw:' + #13#10; |
s := 'Draw:' + #13#10; |
| 463 |
Showmessage(s + '(Player1) ' + IntToStr(m) + #13#10 + '(Player2) ' + |
Showmessage(s + '(Player1) ' + IntToStr(m) + #13#10 + '(Player2) ' + |
| 464 |
IntToStr(n)); |
IntToStr(n)); |
| 465 |
end; |
end |
| 466 |
end; |
else |
| 467 |
|
Caption := s; |
| 468 |
|
end |
| 469 |
|
else |
| 470 |
|
Caption := s; |
| 471 |
end; |
end; |
| 472 |
|
|
| 473 |
procedure TForm1.CompStone; |
procedure TForm1.CompStone; |
| 485 |
StoneGrid.Start; |
StoneGrid.Start; |
| 486 |
PaintBox1.Repaint; |
PaintBox1.Repaint; |
| 487 |
Index := Player1; |
Index := Player1; |
| 488 |
|
Caption := '黒から始めます'; |
| 489 |
Timer1.Enabled := true; |
Timer1.Enabled := true; |
| 490 |
end; |
end; |
| 491 |
|
|
| 492 |
procedure TForm1.MenuItem10Click(Sender: TObject); |
procedure TForm1.MenuItem10Click(Sender: TObject); |
| 493 |
begin |
begin |
| 494 |
StoneGrid.Restart; |
StoneGrid.Restart; |
|
Timer1.Enabled := true; |
|
| 495 |
end; |
end; |
| 496 |
|
|
| 497 |
procedure TForm1.MenuItem11Click(Sender: TObject); |
procedure TForm1.MenuItem11Click(Sender: TObject); |
| 498 |
|
var |
| 499 |
|
i: integer; |
| 500 |
begin |
begin |
|
Timer1.Enabled := false; |
|
| 501 |
with StoneGrid do |
with StoneGrid do |
| 502 |
|
begin |
| 503 |
|
i := TurnNumber; |
| 504 |
if Sender = MenuItem11 then |
if Sender = MenuItem11 then |
| 505 |
TurnNumber := TurnNumber + 1 |
TurnNumber := TurnNumber + 1 |
| 506 |
else |
else |
| 507 |
TurnNumber := TurnNumber - 1; |
TurnNumber := TurnNumber - 1; |
| 508 |
|
if (i = TurnNumber) then |
| 509 |
|
Exit |
| 510 |
|
else |
| 511 |
|
Pause; |
| 512 |
|
end; |
| 513 |
PaintBox1.Repaint; |
PaintBox1.Repaint; |
| 514 |
ChangePlayer; |
ChangePlayer; |
| 515 |
end; |
end; |
| 534 |
procedure TForm1.MenuItem8Click(Sender: TObject); |
procedure TForm1.MenuItem8Click(Sender: TObject); |
| 535 |
begin |
begin |
| 536 |
StoneGrid.Pause; |
StoneGrid.Pause; |
|
Timer1.Enabled := false; |
|
| 537 |
end; |
end; |
| 538 |
|
|
| 539 |
procedure TForm1.PaintBox1Paint(Sender: TObject; Canvas: TCanvas); |
procedure TForm1.PaintBox1Paint(Sender: TObject; Canvas: TCanvas); |
| 540 |
var |
var |
| 541 |
i, j: integer; |
i, j: integer; |
| 542 |
begin |
begin |
| 543 |
for i := 0 to Count-1 do |
if StoneGrid.Active = false then |
| 544 |
|
StoneGrid.Paint(Canvas); |
| 545 |
|
for i := 0 to Count - 1 do |
| 546 |
begin |
begin |
| 547 |
for j := 0 to Count-1 do |
for j := 0 to Count - 1 do |
| 548 |
begin |
begin |
| 549 |
case StoneGrid.Strings[i, j] of |
case StoneGrid.Strings[i, j] of |
| 550 |
stWhite: |
stWhite: |
| 566 |
end; |
end; |
| 567 |
Canvas.DrawLine(PointF(i * Size, 0), PointF(i * Size, Size * Count), 1); |
Canvas.DrawLine(PointF(i * Size, 0), PointF(i * Size, Size * Count), 1); |
| 568 |
end; |
end; |
| 569 |
Canvas.DrawLine(PointF(Count*Size,0),PointF(Count*Size,Count*Size),1); |
Canvas.DrawLine(PointF(Count * Size, 0), |
| 570 |
Canvas.DrawLine(PointF(0,Count*Size),PointF(Count*Size,Count*Size),1); |
PointF(Count * Size, Count * Size), 1); |
| 571 |
if StoneGrid.Active = false then |
Canvas.DrawLine(PointF(0, Count * Size), |
| 572 |
StoneGrid.Paint(Canvas); |
PointF(Count * Size, Count * Size), 1); |
| 573 |
end; |
end; |
| 574 |
|
|
| 575 |
procedure TForm1.PaintBox1Resize(Sender: TObject); |
procedure TForm1.PaintBox1Resize(Sender: TObject); |