Reduce reliance on (symbolic links for) images, add dynamic movelog, and display moves like chess notations.

main
Roy 2 years ago
parent 16f3d174eb
commit 73241fbfe7
  1. 10
      chess.sql
  2. 62
      chess_gui/lib/chess_gui.pm
  3. 24
      chess_gui/llll
  4. 3
      chess_gui/public/css/index.css
  5. 1
      chess_gui/public/i/0.0.png
  6. 1
      chess_gui/public/i/0.1.png
  7. 1
      chess_gui/public/i/0.2.png
  8. 1
      chess_gui/public/i/0.3.png
  9. 1
      chess_gui/public/i/0.4.png
  10. 1
      chess_gui/public/i/0.5.png
  11. 1
      chess_gui/public/i/0.6.png
  12. 1
      chess_gui/public/i/0.7.png
  13. 0
      chess_gui/public/i/0b.png
  14. 1
      chess_gui/public/i/0b1.png
  15. 0
      chess_gui/public/i/0k.png
  16. 0
      chess_gui/public/i/0n.png
  17. 1
      chess_gui/public/i/0n1.png
  18. 0
      chess_gui/public/i/0p.png
  19. 1
      chess_gui/public/i/0p1.png
  20. 1
      chess_gui/public/i/0p2.png
  21. 1
      chess_gui/public/i/0p3.png
  22. 1
      chess_gui/public/i/0p4.png
  23. 1
      chess_gui/public/i/0p5.png
  24. 1
      chess_gui/public/i/0p6.png
  25. 1
      chess_gui/public/i/0p7.png
  26. 0
      chess_gui/public/i/0q.png
  27. 0
      chess_gui/public/i/0r.png
  28. 1
      chess_gui/public/i/0r1.png
  29. 1
      chess_gui/public/i/1.0.png
  30. 1
      chess_gui/public/i/1.1.png
  31. 1
      chess_gui/public/i/1.2.png
  32. 1
      chess_gui/public/i/1.3.png
  33. 1
      chess_gui/public/i/1.4.png
  34. 1
      chess_gui/public/i/1.5.png
  35. 1
      chess_gui/public/i/1.6.png
  36. 1
      chess_gui/public/i/1.7.png
  37. 0
      chess_gui/public/i/1b.png
  38. 1
      chess_gui/public/i/1b1.png
  39. 0
      chess_gui/public/i/1k.png
  40. 0
      chess_gui/public/i/1n.png
  41. 1
      chess_gui/public/i/1n1.png
  42. 0
      chess_gui/public/i/1p.png
  43. 1
      chess_gui/public/i/1p1.png
  44. 1
      chess_gui/public/i/1p2.png
  45. 1
      chess_gui/public/i/1p3.png
  46. 1
      chess_gui/public/i/1p4.png
  47. 1
      chess_gui/public/i/1p5.png
  48. 1
      chess_gui/public/i/1p6.png
  49. 1
      chess_gui/public/i/1p7.png
  50. 0
      chess_gui/public/i/1q.png
  51. 0
      chess_gui/public/i/1r.png
  52. 1
      chess_gui/public/i/1r1.png
  53. 1
      chess_gui/public/i/2.0.png
  54. 1
      chess_gui/public/i/2.1.png
  55. 1
      chess_gui/public/i/2.2.png
  56. 1
      chess_gui/public/i/2.3.png
  57. 1
      chess_gui/public/i/2.4.png
  58. 1
      chess_gui/public/i/2.5.png
  59. 1
      chess_gui/public/i/2.6.png
  60. 1
      chess_gui/public/i/2.7.png
  61. 1
      chess_gui/public/i/3.0.png
  62. 1
      chess_gui/public/i/3.1.png
  63. 1
      chess_gui/public/i/3.2.png
  64. 1
      chess_gui/public/i/3.3.png
  65. 1
      chess_gui/public/i/3.4.png
  66. 1
      chess_gui/public/i/3.5.png
  67. 1
      chess_gui/public/i/3.6.png
  68. 1
      chess_gui/public/i/3.7.png
  69. 1
      chess_gui/public/i/4.0.png
  70. 1
      chess_gui/public/i/4.1.png
  71. 1
      chess_gui/public/i/4.2.png
  72. 1
      chess_gui/public/i/4.3.png
  73. 1
      chess_gui/public/i/4.4.png
  74. 1
      chess_gui/public/i/4.5.png
  75. 1
      chess_gui/public/i/4.6.png
  76. 1
      chess_gui/public/i/4.7.png
  77. 1
      chess_gui/public/i/5.0.png
  78. 1
      chess_gui/public/i/5.1.png
  79. 1
      chess_gui/public/i/5.2.png
  80. 1
      chess_gui/public/i/5.3.png
  81. 1
      chess_gui/public/i/5.4.png
  82. 1
      chess_gui/public/i/5.5.png
  83. 1
      chess_gui/public/i/5.6.png
  84. 1
      chess_gui/public/i/5.7.png
  85. 1
      chess_gui/public/i/6.0.png
  86. 1
      chess_gui/public/i/6.1.png
  87. 1
      chess_gui/public/i/6.2.png
  88. 1
      chess_gui/public/i/6.3.png
  89. 1
      chess_gui/public/i/6.4.png
  90. 1
      chess_gui/public/i/6.5.png
  91. 1
      chess_gui/public/i/6.6.png
  92. 1
      chess_gui/public/i/6.7.png
  93. 1
      chess_gui/public/i/7.0.png
  94. 1
      chess_gui/public/i/7.1.png
  95. 1
      chess_gui/public/i/7.2.png
  96. 1
      chess_gui/public/i/7.3.png
  97. 1
      chess_gui/public/i/7.4.png
  98. 1
      chess_gui/public/i/7.5.png
  99. 1
      chess_gui/public/i/7.6.png
  100. 1
      chess_gui/public/i/7.7.png
  101. Some files were not shown because too many files have changed in this diff Show More

@ -88,8 +88,8 @@ CREATE TABLE public.context (
id integer DEFAULT nextval('public.context_seq_id'::regclass), id integer DEFAULT nextval('public.context_seq_id'::regclass),
bid integer, bid integer,
wid integer, wid integer,
bprio real, Blackprio real,
wprio real Whiteprio real
); );
ALTER TABLE public.context ALTER TABLE public.context
@ -150,9 +150,9 @@ ALTER TABLE public.black
ALTER TABLE public.black OWNER TO postgres; ALTER TABLE public.black OWNER TO postgres;
CREATE TABLE public.sessions ( CREATE TABLE public.sessions (
session text, session text NOT NULL,
bid integer, bid integer NOT NULL,
wid integer wid integer NOT NULL
); );
ALTER TABLE public.sessions ALTER TABLE public.sessions

@ -44,7 +44,7 @@ my $dbh = DBI->connect("dbi:Pg:dbname=$dbname", $username, '', {PrintError => 1,
#my $sth1 = $dbh->prepare(q/SELECT bw_id, prio FROM black, context WHERE black.b0 = ? and black.b1 = ? and black.k0 = ? and black.n0 = ? and black.n1 = ? and black.p0 = ? and black.p1 = ? and black.p2 = ? and black.p3 = ? and black.p4 = ? and black.p5 = ? and black.p6 = ? and black.p7 = ? and black.q0 = ? and black.r0 = ? and black.r1 = ? and black.b0 = ? and context.b1 = ? and context.k0 = ? and context.n0 = ? and context.n1 = ? and context.p0 = ? and context.p1 = ? and context.p2 = ? and context.p3 = ? and context.p4 = ? and context.p5 = ? and context.p6 = ? and context.p7 = ? and context.q0 = ? and context.r0 = ? and context.r1 = ?/); #my $sth1 = $dbh->prepare(q/SELECT bw_id, prio FROM black, context WHERE black.b0 = ? and black.b1 = ? and black.k0 = ? and black.n0 = ? and black.n1 = ? and black.p0 = ? and black.p1 = ? and black.p2 = ? and black.p3 = ? and black.p4 = ? and black.p5 = ? and black.p6 = ? and black.p7 = ? and black.q0 = ? and black.r0 = ? and black.r1 = ? and black.b0 = ? and context.b1 = ? and context.k0 = ? and context.n0 = ? and context.n1 = ? and context.p0 = ? and context.p1 = ? and context.p2 = ? and context.p3 = ? and context.p4 = ? and context.p5 = ? and context.p6 = ? and context.p7 = ? and context.q0 = ? and context.r0 = ? and context.r1 = ?/);
#my $sth1 = $dbh->prepare(q/SELECT black.id, white.id, bprio, wprio FROM black, white, context WHERE black.id = bid and white.id = wid and white.b0 = ? and white.b1 = ? and white.k0 = ? and white.n0 = ? and white.n1 = ? and white.p0 = ? and white.p1 = ? and white.p2 = ? and white.p3 = ? and white.p4 = ? and white.p5 = ? and white.p6 = ? and white.p7 = ? and white.q0 = ? and white.r0 = ? and white.r1 = ? and black.b0 = ? and black.b1 = ? and black.k0 = ? and black.n0 = ? and black.n1 = ? and black.p0 = ? and black.p1 = ? and black.p2 = ? and black.p3 = ? and black.p4 = ? and black.p5 = ? and black.p6 = ? and black.p7 = ? and black.q0 = ? and black.r0 = ? and black.r1 = ?/); #TODO: There should be a better way to do this... #my $sth1 = $dbh->prepare(q/SELECT black.id, white.id, bprio, wprio FROM black, white, context WHERE black.id = bid and white.id = wid and white.b0 = ? and white.b1 = ? and white.k0 = ? and white.n0 = ? and white.n1 = ? and white.p0 = ? and white.p1 = ? and white.p2 = ? and white.p3 = ? and white.p4 = ? and white.p5 = ? and white.p6 = ? and white.p7 = ? and white.q0 = ? and white.r0 = ? and white.r1 = ? and black.b0 = ? and black.b1 = ? and black.k0 = ? and black.n0 = ? and black.n1 = ? and black.p0 = ? and black.p1 = ? and black.p2 = ? and black.p3 = ? and black.p4 = ? and black.p5 = ? and black.p6 = ? and black.p7 = ? and black.q0 = ? and black.r0 = ? and black.r1 = ?/); #TODO: There should be a better way to do this...
#my $sth1 = $dbh->prepare(q/SELECT black.id, white.id FROM black, white WHERE (black.id, white.id) IN (SELECT bid, wid FROM context) and white.b0 = ? and white.b1 = ? and white.k0 = ? and white.n0 = ? and white.n1 = ? and white.p0 = ? and white.p1 = ? and white.p2 = ? and white.p3 = ? and white.p4 = ? and white.p5 = ? and white.p6 = ? and white.p7 = ? and white.q0 = ? and white.r0 = ? and white.r1 = ? and black.b0 = ? and black.b1 = ? and black.k0 = ? and black.n0 = ? and black.n1 = ? and black.p0 = ? and black.p1 = ? and black.p2 = ? and black.p3 = ? and black.p4 = ? and black.p5 = ? and black.p6 = ? and black.p7 = ? and black.q0 = ? and black.r0 = ? and black.r1 = ?/); #my $sth1 = $dbh->prepare(q/SELECT black.id, white.id FROM black, white WHERE (black.id, white.id) IN (SELECT bid, wid FROM context) and white.b0 = ? and white.b1 = ? and white.k0 = ? and white.n0 = ? and white.n1 = ? and white.p0 = ? and white.p1 = ? and white.p2 = ? and white.p3 = ? and white.p4 = ? and white.p5 = ? and white.p6 = ? and white.p7 = ? and white.q0 = ? and white.r0 = ? and white.r1 = ? and black.b0 = ? and black.b1 = ? and black.k0 = ? and black.n0 = ? and black.n1 = ? and black.p0 = ? and black.p1 = ? and black.p2 = ? and black.p3 = ? and black.p4 = ? and black.p5 = ? and black.p6 = ? and black.p7 = ? and black.q0 = ? and black.r0 = ? and black.r1 = ?/);
my $sth1 = $dbh->prepare(q/SELECT bid, wid, bprio, wprio FROM context WHERE (bid, wid) IN (SELECT black.id, white.id FROM black, white WHERE white.b0 = ? and white.b1 = ? and white.k0 = ? and white.n0 = ? and white.n1 = ? and white.p0 = ? and white.p1 = ? and white.p2 = ? and white.p3 = ? and white.p4 = ? and white.p5 = ? and white.p6 = ? and white.p7 = ? and white.q0 = ? and white.r0 = ? and white.r1 = ? and black.b0 = ? and black.b1 = ? and black.k0 = ? and black.n0 = ? and black.n1 = ? and black.p0 = ? and black.p1 = ? and black.p2 = ? and black.p3 = ? and black.p4 = ? and black.p5 = ? and black.p6 = ? and black.p7 = ? and black.q0 = ? and black.r0 = ? and black.r1 = ?)/); my $sth1 = $dbh->prepare(q/SELECT bid, wid, Blackprio, Whiteprio FROM context WHERE (bid, wid) IN (SELECT black.id, white.id FROM black, white WHERE white.b0 = ? and white.b1 = ? and white.k0 = ? and white.n0 = ? and white.n1 = ? and white.p0 = ? and white.p1 = ? and white.p2 = ? and white.p3 = ? and white.p4 = ? and white.p5 = ? and white.p6 = ? and white.p7 = ? and white.q0 = ? and white.r0 = ? and white.r1 = ? and black.b0 = ? and black.b1 = ? and black.k0 = ? and black.n0 = ? and black.n1 = ? and black.p0 = ? and black.p1 = ? and black.p2 = ? and black.p3 = ? and black.p4 = ? and black.p5 = ? and black.p6 = ? and black.p7 = ? and black.q0 = ? and black.r0 = ? and black.r1 = ?)/);
#my $sth2 = $dbh->prepare(q/INSERT INTO white (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1, prio) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/); #my $sth2 = $dbh->prepare(q/INSERT INTO white (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1, prio) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/);
#my $sth3 = $dbh->prepare(q/INSERT INTO black (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1, prio) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/); #my $sth3 = $dbh->prepare(q/INSERT INTO black (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1, prio) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/);
#my $sth2 = $dbh->prepare(q/INSERT INTO white (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/); #my $sth2 = $dbh->prepare(q/INSERT INTO white (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/);
@ -52,7 +52,7 @@ my $sth1 = $dbh->prepare(q/SELECT bid, wid, bprio, wprio FROM context WHERE (bid
#my $sth4 = $dbh->prepare(q/INSERT INTO context (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1, prio) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/); #my $sth4 = $dbh->prepare(q/INSERT INTO context (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1, prio) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/);
my $sth2 = $dbh->prepare(q/INSERT INTO white (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/); my $sth2 = $dbh->prepare(q/INSERT INTO white (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/);
my $sth3 = $dbh->prepare(q/INSERT INTO black (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/); my $sth3 = $dbh->prepare(q/INSERT INTO black (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)/);
my $sth5 = $dbh->prepare(q/INSERT INTO context (bid, wid, bprio, wprio) VALUES (?, ?, ?, ?)/); my $sth5 = $dbh->prepare(q/INSERT INTO context (bid, wid, Blackprio, Whiteprio) VALUES (?, ?, ?, ?)/);
my $sth6 = $dbh->prepare(q/SELECT id FROM white WHERE b0 = ? and b1 = ? and k0 = ? and n0 = ? and n1 = ? and p0 = ? and p1 = ? and p2 = ? and p3 = ? and p4 = ? and p5 = ? and p6 = ? and p7 = ? and q0 = ? and r0 = ? and r1 = ?/); my $sth6 = $dbh->prepare(q/SELECT id FROM white WHERE b0 = ? and b1 = ? and k0 = ? and n0 = ? and n1 = ? and p0 = ? and p1 = ? and p2 = ? and p3 = ? and p4 = ? and p5 = ? and p6 = ? and p7 = ? and q0 = ? and r0 = ? and r1 = ?/);
my $sth7 = $dbh->prepare(q/SELECT id FROM black WHERE b0 = ? and b1 = ? and k0 = ? and n0 = ? and n1 = ? and p0 = ? and p1 = ? and p2 = ? and p3 = ? and p4 = ? and p5 = ? and p6 = ? and p7 = ? and q0 = ? and r0 = ? and r1 = ?/); my $sth7 = $dbh->prepare(q/SELECT id FROM black WHERE b0 = ? and b1 = ? and k0 = ? and n0 = ? and n1 = ? and p0 = ? and p1 = ? and p2 = ? and p3 = ? and p4 = ? and p5 = ? and p6 = ? and p7 = ? and q0 = ? and r0 = ? and r1 = ?/);
#my $sth8 = $dbh->prepare(q/SELECT black.b0, black.b1, black.k0, black.n0, black.n1, black.p0, black.p1, black.p2, black.p3, black.p4, black.p5, black.p6, black.p7, black.q0, black.r0, black.r1, white.b0, white.b1, white.k0, white.n0, white.n1, white.p0, white.p1, white.p2, white.p3, white.p4, white.p5, white.p6, white.p7, white.q0, white.r0, white.r1 FROM black, white WHERE (black.id, white.id) IN (SELECT bid, wid FROM sessions WHERE session = ?)/); #my $sth8 = $dbh->prepare(q/SELECT black.b0, black.b1, black.k0, black.n0, black.n1, black.p0, black.p1, black.p2, black.p3, black.p4, black.p5, black.p6, black.p7, black.q0, black.r0, black.r1, white.b0, white.b1, white.k0, white.n0, white.n1, white.p0, white.p1, white.p2, white.p3, white.p4, white.p5, white.p6, white.p7, white.q0, white.r0, white.r1 FROM black, white WHERE (black.id, white.id) IN (SELECT bid, wid FROM sessions WHERE session = ?)/);
@ -62,8 +62,13 @@ my $sth10 = $dbh->prepare(q/INSERT INTO sessions (session, bid, wid) VALUES ($1,
my $sth11 = $dbh->prepare(q/SELECT bid, wid FROM sessions WHERE session = ?/); my $sth11 = $dbh->prepare(q/SELECT bid, wid FROM sessions WHERE session = ?/);
my (@tree, @what_i_did, %prop, @keys, @pplayer, %tmpalg, %tmpalg2, %tmpalg3, %tmpalg4, $players, @not_player, $smaleer, %pval); my (@tree, @what_i_did, %prop, @keys, @pplayer, %tmpalg, %tmpalg2, %tmpalg3, %tmpalg4, $players, @not_player, $smaleer, %pval);
@not_player[0, 1] = (1, 0); @not_player[0, 1] = (1, 0);
my @px = ('A'..'H');
my %pxr;
@pxr{'A'..'H'} = (0..7);
my %ppiece;
@ppiece{qw/b k n p q r/} = qw/bishop king knight pawn queen rook/;
my @player = reverse @not_player; my @player = reverse @not_player;
@pplayer[0, 1] = qw/w b/; @pplayer[0, 1] = qw/White Black/;
my @pseudoinfinite_loop_check; my @pseudoinfinite_loop_check;
my $user_mode; my $user_mode;
my $player; my $player;
@ -73,6 +78,7 @@ my $action_limit = 100;
my $loop_limit = 6; my $loop_limit = 6;
my @direction = qw/1 1 1 -1 -1 -1 -1 1 0 1 0 -1 1 0 -1 0 0.5 2 0.5 -2 -0.5 -2 -0.5 2/; # Diagonal direction modifiers: $direction[0..7]. Straight direction modifiers: $direction[8..15]. Knight direction modifiers: $direction[0..7,16..23]. my @direction = qw/1 1 1 -1 -1 -1 -1 1 0 1 0 -1 1 0 -1 0 0.5 2 0.5 -2 -0.5 -2 -0.5 2/; # Diagonal direction modifiers: $direction[0..7]. Straight direction modifiers: $direction[8..15]. Knight direction modifiers: $direction[0..7,16..23].
my @default_iboard; my @default_iboard;
#my %default_iboard;
my @session_iboard; my @session_iboard;
sub INTERRUPT { sub INTERRUPT {
$sth1->finish(); $sth1->finish();
@ -133,7 +139,8 @@ if ($#_ != -1) {
} elsif ($y > 5) { # Black, hereafter called player 1. } elsif ($y > 5) { # Black, hereafter called player 1.
$player = 1; $player = 1;
} else { } else {
$default_iboard[$y][$x] = $_; # $default_iboard[$y][$x] = $_;
$default_iboard[$y][$x]{'pco'} = join '', $px[$x], ($y+1);
next; next;
} }
if ($y*2 % 10 == 2) { # Pawn. if ($y*2 % 10 == 2) { # Pawn.
@ -155,8 +162,10 @@ if ($#_ != -1) {
push @{$prop{$_}}, ($player, 'b', $x % 2); push @{$prop{$_}}, ($player, 'b', $x % 2);
$pval{join '', @{$prop{$_}}} = 0.01; $pval{join '', @{$prop{$_}}} = 0.01;
} }
if (exists($prop{$_})) {$default_iboard[$y][$x] = join '', @{$prop{$_}}} # if (exists($prop{$_})) {$default_iboard[$y][$x] = join '', @{$prop{$_}}}
# if (exists($prop{$_})) {$default_iboard[$y][$x]{'isPiece'} = 1; $default_iboard[$y][$x]{'value'} = join '', @{$prop{$_}}; $default_iboard[$y][$x]{'prettyName'} = join ' ', $pplayer[$prop{$_}[0]], $ppiece{$prop{$_}[1]}} else {$default_iboard[$y][$x]{'isPiece'} = 0; $default_iboard[$y][$x]{'value'} = undef}; # HoA for Template Toolkit.
$default_iboard[$y][$x]{'isPiece'} = 1; $default_iboard[$y][$x]{'id'} = join '', @{$prop{$_}}; $default_iboard[$y][$x]{'img'} = join '', @{$prop{$_}}[0..1]; $default_iboard[$y][$x]{'prettyName'} = join ' ', $pplayer[$prop{$_}[0]], $ppiece{$prop{$_}[1]}; # HoA for Template Toolkit.
$default_iboard[$y][$x]{'pco'} = join '', $px[$x], ($y+1);
} else { # Restore a previous state (from a session). } else { # Restore a previous state (from a session).
$session_iboard[$y][$x] = $h1{$_} // $h0{$_} // $_; $session_iboard[$y][$x] = $h1{$_} // $h0{$_} // $_;
} }
@ -184,7 +193,8 @@ sub MOVEMENT_TREE { # Assume relative movement to support abritrary depth (0 < $
if ($#ditet != -1 and defined($ditet[2/($player+1)+1])) { if ($#ditet != -1 and defined($ditet[2/($player+1)+1])) {
my $tmpkey = join ',', @keys; my $tmpkey = join ',', @keys;
{no warnings; $tmpalg{$tmpkey} = $ditet[2/($player+1)+1]}; {no warnings; $tmpalg{$tmpkey} = $ditet[2/($player+1)+1]};
if ($player == $user_mode) {if (defined($prop{$asrc}) and (join '', @{$prop{$asrc}}) eq $_[7] and ($_[8] eq $tree[$i]{$asrc}[$c] or (defined($prop{$tree[$i]{$asrc}[$c]}) and $_[8] eq (join '', @{$prop{$tree[$i]{$asrc}[$c]}})))) {$tmpalg{$tmpkey} = 'Inf'; $sth10->execute($_[9], $ditet[0], $ditet[1])}} #else { # if ($player == $user_mode) {if (defined($prop{$asrc}) and (join '', @{$prop{$asrc}}) eq $_[7] and ($_[8] eq $tree[$i]{$asrc}[$c] or (defined($prop{$tree[$i]{$asrc}[$c]}) and $_[8] eq (join '', @{$prop{$tree[$i]{$asrc}[$c]}})))) {$tmpalg{$tmpkey} = 'Inf'; $sth10->execute($_[9], $ditet[0], $ditet[1])}} #else {
if ($player == $user_mode) {if ($asrc eq $_[7] and $_[8] eq $tree[$i]{$asrc}[$c]) {$tmpalg{$tmpkey} = 'Inf'; $sth10->execute($_[9], $ditet[0], $ditet[1])}}
my $val = $tmpalg{$tmpkey}; my $val = $tmpalg{$tmpkey};
push @{$key_list_by_value{$val}}, ($tmpkey, @ditet[0, 1]); push @{$key_list_by_value{$val}}, ($tmpkey, @ditet[0, 1]);
unless (defined($prio)) { unless (defined($prio)) {
@ -460,7 +470,8 @@ $sth5->execute($bid, $wid, $tmpalg{$selection}, undef);
} }
# if ($player == $user_mode and (join '', @asrc) eq $_[7] and ($_[8] eq $adest or $_[8] eq (join '', @adest))) {$tmpalg{$selection} = 'Inf'; $sth9->execute($_[9], $bid, $wid)} # if ($player == $user_mode and (join '', @asrc) eq $_[7] and ($_[8] eq $adest or $_[8] eq (join '', @adest))) {$tmpalg{$selection} = 'Inf'; $sth9->execute($_[9], $bid, $wid)}
if ($player == $user_mode) {if ($#asrc != -1 and (join '', @asrc) eq $_[7] and ($_[8] eq $adest or $_[8] eq (join '', @adest))) {$tmpalg{$selection} = 'Inf'; $sth10->execute($_[9], $bid, $wid)}} #else { # if ($player == $user_mode) {if ($#asrc != -1 and (join '', @asrc) eq $_[7] and ($_[8] eq $adest or $_[8] eq (join '', @adest))) {$tmpalg{$selection} = 'Inf'; $sth10->execute($_[9], $bid, $wid)}} #else {
if ($player == $user_mode) {if ($asrc eq $_[7] and $_[8] eq $adest) {$tmpalg{$selection} = 'Inf'; $sth10->execute($_[9], $bid, $wid)}} #else {
my $val = $tmpalg{$selection}; my $val = $tmpalg{$selection};
push @{$key_list_by_value{$val}}, ($selection, $bid, $wid); push @{$key_list_by_value{$val}}, ($selection, $bid, $wid);
unless (defined($prio)) { unless (defined($prio)) {
@ -480,7 +491,7 @@ $sth5->execute($bid, $wid, $tmpalg{$selection}, undef);
push @selection, $key_list_by_value{$prio}[$ii]; push @selection, $key_list_by_value{$prio}[$ii];
} }
$ice = int(rand($#selection+1)); $ice = int(rand($#selection+1));
return ($prio, $key_list_by_value{$prio}[$ice*3+1], $key_list_by_value{$prio}[$ice*3+2], $selection[$ice], $ice, $#selection); return ($prio, $key_list_by_value{$prio}[$ice*3+1], $key_list_by_value{$prio}[$ice*3+2], $selection[$ice], $ice, ($#selection+1));
} }
sub QUEEN { sub QUEEN {
@ -671,18 +682,18 @@ my ($pval, $called_player, $reason) = @_; # Arguments: (Value of all pieces of $
} else { } else {
$mpval = $pval; $mpval = $pval;
} }
} elsif ($reason == 1) { } elsif ($reason == 1) { # Won: add king value; Lost: detract king value.
if ($current_player == 0) { if ($current_player == 0) {
if ($called_player == 0) { if ($called_player == 0) {
$mpval = $pval; $mpval = $pval + $pval{'0k0'};
} else { } else {
$mpval = $pval * -1; $mpval = $pval * -1 - $pval{'0k0'};
} }
} else { } else {
if ($called_player == 1) { if ($called_player == 1) {
$mpval = $pval; $mpval = $pval + $pval{'1k0'};
} else { } else {
$mpval = $pval * -1; $mpval = $pval * -1 - $pval{'1k0'};
} }
} }
} }
@ -731,6 +742,11 @@ $user_mode = 0;
my ($dpval, $i_al) = (0, 0); my ($dpval, $i_al) = (0, 0);
if ($player == $user_mode) { # If the player is human-controlled, we needn't more than $depth 1 (for input validation). if ($player == $user_mode) { # If the player is human-controlled, we needn't more than $depth 1 (for input validation).
$depth = 1; $depth = 1;
my ($xrc, $yrc) = split //, $_[0];
$_[0] = join '.', $pxr{$xrc}, ($yrc-1);
($xrc, $yrc) = split //, $_[1];
$_[1] = join '.', $pxr{$xrc}, ($yrc-1);
print $_[0], ' ', $_[1], "\n";
($prio, @id[0, 1], $selection, $ice, $n_o_selections) = &MOVEMENT_TREE($player, $depth, undef, undef, undef, undef, undef, $_[0], $_[1], $sessid); ($prio, @id[0, 1], $selection, $ice, $n_o_selections) = &MOVEMENT_TREE($player, $depth, undef, undef, undef, undef, undef, $_[0], $_[1], $sessid);
print 'w ', $id[0], ' ', $id[1], "\n"; print 'w ', $id[0], ' ', $id[1], "\n";
} else { } else {
@ -757,10 +773,14 @@ print 'b ', $id[0], ' ', $id[1], "\n";
$player_turn--; $player_turn--;
# push @{$diff{$player}{'warn'}} = 'Reverting an invalid set.'; # push @{$diff{$player}{'warn'}} = 'Reverting an invalid set.';
undef $diff{$pplayer[$not_player[$player]]}; undef $diff{$pplayer[$not_player[$player]]};
push @{$diff{$pplayer[$player]}{'status'}}, 0; push @{$diff{$pplayer[$player]}{'status'}}, -1;
# redo TURN; # redo TURN;
return %diff; return %diff;
} } else {push @{$diff{$pplayer[$player]}{'status'}}, 0}
push @{$diff{$pplayer[$player]}{'status'}}, $prio;
push @{$diff{$pplayer[$player]}{'status'}}, ($ice+1);
push @{$diff{$pplayer[$player]}{'status'}}, $n_o_selections;
# if (scalar keys %key_list_by_value > 0) { # if (scalar keys %key_list_by_value > 0) {
# for (my $ii = 0; $#{$key_list_by_value{$prio}} >= $ii; $ii++) { # for (my $ii = 0; $#{$key_list_by_value{$prio}} >= $ii; $ii++) {
@ -839,8 +859,8 @@ print 'b ', $id[0], ' ', $id[1], "\n";
} }
push @pseudoinfinite_loop_check, $selection; push @pseudoinfinite_loop_check, $selection;
push @{$diff{$pplayer[$player]}{'prio'}}, $prio; # push @{$diff{$pplayer[$player]}{'prio'}}, $prio;
push @{$diff{$pplayer[$player]}{'moveno'}}, ($ice+1) . '/' . $n_o_selections; # push @{$diff{$pplayer[$player]}{'moveno'}}, ($ice+1) . '/' . $n_o_selections;
# @{$diff{'msg'}{'verbose'}}[$player] = $selection[$ice]; # @{$diff{'msg'}{'verbose'}}[$player] = $selection[$ice];
$what_i_did[$player]{$selection} = $prio; $what_i_did[$player]{$selection} = $prio;
@ -855,9 +875,11 @@ print 'b ', $id[0], ' ', $id[1], "\n";
} }
my $asrc = $keys[$c]; my $asrc = $keys[$c];
my $piece = $prop{$asrc}; my $piece = $prop{$asrc};
push @{$diff{$pplayer[$player]}{'src'}}, $asrc; my ($sxc, $syc) = split /\./, $asrc;
push @{$diff{$pplayer[$player]}{'src'}}, join '', $px[$sxc], ($syc+1);
my ($dxc, $dyc) = split /\./, $adest;
push @{$diff{$pplayer[$player]}{'dst'}}, join '', $px[$dxc], ($dyc+1);
push @{$diff{$pplayer[$player]}{'src'}}, join '', @{$piece}; push @{$diff{$pplayer[$player]}{'src'}}, join '', @{$piece};
push @{$diff{$pplayer[$player]}{'dst'}}, $adest;
# @{$diff{$player}{'move'}}[$player*2] = (join '', @{$piece}) . ' moves from ' . $asrc . ' to ' . $adest; # @{$diff{$player}{'move'}}[$player*2] = (join '', @{$piece}) . ' moves from ' . $asrc . ' to ' . $adest;
if (defined($prop{$adest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 | | 3.7 | 0.7 | 7.6
2.7, 5.7, 4.7, 2.5, 6.7, 0.6, 1.6, 2.6, 3.6, 4.6, 5.4, 6.6, , 3.7, 0.7, 7.6
2.0 | 5.0 | 4.0 | 1.0 | 7.6 | 0.1 | 1.1 | 2.1 | 3.1 | 4.1 | 5.1 | 6.1 | 7.1 | 3.0 | 0.0 | 7.0
2.0, 5.0, 4.0, 1.0, 7.6, 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 3.0, 0.0, 7.0,

@ -9,6 +9,7 @@ a {
ol > li li { ol > li li {
display: inline-block; display: inline-block;
width: 32px; width: 32px;
height: 32px;
} }
#y-co { #y-co {
@ -61,7 +62,7 @@ h3 > ul:hover .key {
img { img {
position: relative; position: relative;
border: 2.5px; border: 2.5px;
height: 30px; height: 32px;
border-color: #884b10; border-color: #884b10;
border-color: #592b07; border-color: #592b07;
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save