Since no firstrank constant has been stored for this game, one will be calculated by analyzing the moves in the game. This will work only if the game lasted long enough to put enough pieces into play.

mv is f2-f3, p is #p, o is f2

space f2 is P

0 P f2-f3 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

mv is c7-c6, p is #p, o is c7

space c7 is p

1 p c7-c6 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

mv is b2-b3, p is #p, o is b2

space b2 is P

2 P b2-b3 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

mv is d8-b6, p is #p, o is d8

space d8 is d1

3 d1 d8-b6 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

5 one bits in var d1

11011 111101 111011 10100 111011 111101 111011 11101

q end d8-b6 27 61 59 20 59 61 59 29

bb end d8-b6 27 61 59 20 59 61 59 29

bw end d8-b6 27 61 59 20 59 61 59 29

firstr is a1, and lastr is h1

r d8-b6 27 61 59 20 59 61 59 29

first 27 61 59 20 59 61 59 29

mv is e2-e3, p is #p, o is e2

space e2 is P

4 P e2-e3 27 61 59 20 59 61 59 29

11011 111101 111011 10100 111011 111101 111011 11101

mv is d7-d6, p is #p, o is d7

space d7 is p

5 p d7-d6 27 61 59 20 59 61 59 29

11011 111101 111011 10100 111011 111101 111011 11101

mv is e1-g3, p is #p, o is e1

space e1 is e1

6 e1 e1-g3 27 61 59 20 59 61 59 29

11011 111101 111011 10100 111011 111101 111011 11101

5 one bits in var e1

11011 111101 111011 10100 10010 111101 111011 11101

q end e1-g3 27 61 59 20 18 61 59 29

bb end e1-g3 27 61 59 20 18 61 59 29

bw end e1-g3 27 61 59 20 18 61 59 29

firstr is a1, and lastr is h1

r e1-g3 27 61 59 20 18 61 59 29

first 27 61 59 20 18 61 59 29

mv is e7-e5, p is #p, o is e7

space e7 is p

7 p e7-e5 27 61 59 20 18 61 59 29

11011 111101 111011 10100 10010 111101 111011 11101

mv is d2-d4, p is #p, o is d2

space d2 is P

8 P d2-d4 27 61 59 20 18 61 59 29

11011 111101 111011 10100 10010 111101 111011 11101

mv is e5-d4, p is #p, o is e5

space e5 is p

9 p e5-d4 27 61 59 20 18 61 59 29

11011 111101 111011 10100 10010 111101 111011 11101

mv is e3-d4, p is #p, o is e3

space e3 is P

10 P e3-d4 27 61 59 20 18 61 59 29

11011 111101 111011 10100 10010 111101 111011 11101

mv is e8-e3, p is #p, o is e8

space e8 is e1

11 e1 e8-e3 27 61 59 20 18 61 59 29

11011 111101 111011 10100 10010 111101 111011 11101

2 one bits in var e1

rook ride

e1 currently set to 18

e1 now set to 16

11011 111101 111011 10100 10000 111101 111011 11101

queen before e8-e3 27 61 59 20 16 61 59 29

queen after e8-e3 11 45 43 4 16 45 43 13

q end e8-e3 11 45 43 4 16 45 43 13

bb end e8-e3 11 45 43 4 16 45 43 13

bw end e8-e3 11 41 43 4 16 41 43 9

firstr is a1, and lastr is h1

r e8-e3 11 41 43 4 16 41 43 9

first 11 41 43 4 16 41 43 9

1011 101001 101011 100 10000 101001 101011 1001

q end e8-e3 11 41 43 4 16 41 43 9

bb end e8-e3 11 41 43 4 16 41 43 9

bw end e8-e3 11 41 43 4 16 41 43 9

firstr is a1, and lastr is h1

r e8-e3 11 41 43 4 16 41 43 9

first 11 41 43 4 16 41 43 9

mv is f1-f2, p is #p, o is f1

space f1 is f1

12 f1 f1-f2 11 41 43 4 16 41 43 9

1011 101001 101011 100 10000 101001 101011 1001

3 one bits in var f1

1011 101001 101011 100 10000 101000 101011 1001

q end f1-f2 11 41 43 4 16 40 43 9

bb end f1-f2 11 41 43 4 16 40 43 9

bw end f1-f2 11 41 43 4 16 40 43 9

firstr is a1, and lastr is h1

r f1-f2 11 41 43 4 16 40 43 9

first 11 41 43 4 16 40 43 9

mv is b6-d4, p is #p, o is b6

space b6 is d1

13 d1 b6-d4 11 41 43 4 16 40 43 9

1011 101001 101011 100 10000 101000 101011 1001

1 one bits in var d1

1011 101001 101011 100 10000 101000 101011 1001

q end b6-d4 11 41 43 4 16 40 43 9

bb end b6-d4 11 41 43 4 16 40 43 9

bw end b6-d4 11 41 43 4 16 40 43 9

firstr is a1, and lastr is h1

r b6-d4 11 41 43 4 16 40 43 9

first 11 41 43 4 16 40 43 9

mv is a1-d4, p is #p, o is a1

space a1 is a1

14 a1 a1-d4 11 41 43 4 16 40 43 9

1011 101001 101011 100 10000 101000 101011 1001

3 one bits in var a1

10 101001 101011 100 10000 101000 101011 1001

q end a1-d4 2 41 43 4 16 40 43 9

bb end a1-d4 2 41 41 4 16 40 41 9

bw end a1-d4 2 41 41 4 16 40 41 9

firstr is b1, and lastr is h1

r a1-d4 2 9 41 4 16 40 41 9

first 2 9 41 4 16 40 41 9

10 1001 101001 100 10000 101000 101001 1001

q end a1-d4 2 9 41 4 16 40 41 9

bb end a1-d4 2 9 41 4 16 40 41 9

bw end a1-d4 2 9 41 4 16 40 41 9

firstr is b1, and lastr is h1

r a1-d4 2 9 41 4 16 40 41 9

first 2 9 41 4 16 40 41 9

mv is e3-d4, p is #p, o is e3

space e3 is e1

15 e1 e3-d4 2 9 41 4 16 40 41 9

10 1001 101001 100 10000 101000 101001 1001

1 one bits in var e1

10 1001 101001 100 10000 101000 101001 1001

q end e3-d4 2 9 41 4 16 40 41 9

bb end e3-d4 2 9 41 4 16 40 41 9

bw end e3-d4 2 9 41 4 16 40 41 9

firstr is b1, and lastr is h1

r e3-d4 2 9 41 4 16 40 41 9

first 2 9 41 4 16 40 41 9

mv is c1-e2, p is #p, o is c1

space c1 is c1

16 c1 c1-e2 2 9 41 4 16 40 41 9

10 1001 101001 100 10000 101000 101001 1001

3 one bits in var c1

10 1001 1 100 10000 101000 101001 1001

q end c1-e2 2 9 1 4 16 40 41 9

bb end c1-e2 2 9 1 4 16 40 41 9

bw end c1-e2 2 9 1 4 16 40 41 9

firstr is b1, and lastr is h1

r c1-e2 2 9 1 4 16 40 41 9

first 2 9 1 4 16 40 41 9

mv is d4-d1, p is #p, o is d4

space d4 is e1

17 e1 d4-d1 2 9 1 4 16 40 41 9

10 1001 1 100 10000 101000 101001 1001

1 one bits in var e1

10 1001 1 100 10000 101000 101001 1001

q end d4-d1 2 9 1 4 16 40 41 9

bb end d4-d1 2 9 1 4 16 40 41 9

bw end d4-d1 2 9 1 4 16 40 41 9

firstr is b1, and lastr is h1

r d4-d1 2 9 1 4 16 40 41 9

first 2 9 1 4 16 40 41 9

mv is f2-f1, p is #p, o is f2

space f2 is f1

18 f1 f2-f1 2 9 1 4 16 40 41 9

10 1001 1 100 10000 101000 101001 1001

2 one bits in var f1

10 1001 1 100 10000 101000 101001 1001

q end f2-f1 2 9 1 4 16 40 41 9

bb end f2-f1 2 9 1 4 16 40 41 9

bw end f2-f1 2 9 1 4 16 40 41 9

firstr is b1, and lastr is h1

r f2-f1 2 9 1 4 16 40 41 9

first 2 9 1 4 16 40 41 9

mv is d1-e2, p is #p, o is d1

space d1 is e1

19 e1 d1-e2 2 9 1 4 16 40 41 9

10 1001 1 100 10000 101000 101001 1001

1 one bits in var e1

10 1001 1 100 10000 101000 101001 1001

q end d1-e2 2 9 1 4 16 40 41 9

bb end d1-e2 2 9 1 4 16 40 41 9

bw end d1-e2 2 9 1 4 16 40 41 9

firstr is b1, and lastr is h1

r d1-e2 2 9 1 4 16 40 41 9

first 2 9 1 4 16 40 41 9

mv is b1-c3, p is #p, o is b1

space b1 is b1

20 b1 b1-c3 2 9 1 4 16 40 41 9

10 1001 1 100 10000 101000 101001 1001

2 one bits in var b1

10 1 1 100 10000 101000 101001 1001

q end b1-c3 2 1 1 4 16 40 41 9

bb end b1-c3 2 1 1 4 16 40 41 9

bw end b1-c3 2 1 1 4 16 40 41 9

firstr is f1, and lastr is h1

Two rooks found.

r b1-c3 2 1 1 4 16 8 33 8

first 2 1 1 4 16 8 33 8

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end b1-c3 2 1 1 4 16 8 32 8

bb end b1-c3 2 1 1 4 16 8 32 8

bw end b1-c3 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is e2-c2, p is #p, o is e2

space e2 is e1

21 e1 e2-c2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var e1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end e2-c2 2 1 1 4 16 8 32 8

bb end e2-c2 2 1 1 4 16 8 32 8

bw end e2-c2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is c3-e4, p is #p, o is c3

space c3 is b1

22 b1 c3-e4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var b1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end c3-e4 2 1 1 4 16 8 32 8

bb end c3-e4 2 1 1 4 16 8 32 8

bw end c3-e4 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is c2-b2, p is #p, o is c2

space c2 is e1

23 e1 c2-b2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var e1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end c2-b2 2 1 1 4 16 8 32 8

bb end c2-b2 2 1 1 4 16 8 32 8

bw end c2-b2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is e4-d6, p is #p, o is e4

space e4 is b1

24 b1 e4-d6 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var b1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end e4-d6 2 1 1 4 16 8 32 8

bb end e4-d6 2 1 1 4 16 8 32 8

bw end e4-d6 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is b2-d4, p is #p, o is b2

space b2 is e1

25 e1 b2-d4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var e1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end b2-d4 2 1 1 4 16 8 32 8

bb end b2-d4 2 1 1 4 16 8 32 8

bw end b2-d4 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is f1-f2, p is #p, o is f1

space f1 is f1

26 f1 f1-f2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var f1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end f1-f2 2 1 1 4 16 8 32 8

bb end f1-f2 2 1 1 4 16 8 32 8

bw end f1-f2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is d4-d6, p is #p, o is d4

space d4 is e1

27 e1 d4-d6 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var e1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end d4-d6 2 1 1 4 16 8 32 8

bb end d4-d6 2 1 1 4 16 8 32 8

bw end d4-d6 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is g3-d6, p is #p, o is g3

space g3 is e1

28 e1 g3-d6 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var e1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end g3-d6 2 1 1 4 16 8 32 8

bb end g3-d6 2 1 1 4 16 8 32 8

bw end g3-d6 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is c8-d6, p is #p, o is c8

space c8 is c1

29 c1 c8-d6 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var c1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end c8-d6 2 1 1 4 16 8 32 8

bb end c8-d6 2 1 1 4 16 8 32 8

bw end c8-d6 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is h2-h3, p is #p, o is h2

space h2 is P

30 P h2-h3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is g7-g6, p is #p, o is g7

space g7 is p

31 p g7-g6 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is g1-h2, p is #p, o is g1

space g1 is g1

32 g1 g1-h2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var g1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end g1-h2 2 1 1 4 16 8 32 8

bb end g1-h2 2 1 1 4 16 8 32 8

bw end g1-h2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is f8-e8, p is #p, o is f8

space f8 is f1

33 f1 f8-e8 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var f1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end f8-e8 2 1 1 4 16 8 32 8

bb end f8-e8 2 1 1 4 16 8 32 8

bw end f8-e8 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is h1-d1, p is #p, o is h1

space h1 is h1

34 h1 h1-d1 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var h1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end h1-d1 2 1 1 4 16 8 32 8

bb end h1-d1 2 1 1 4 16 8 32 8

bw end h1-d1 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is d6-f5, p is #p, o is d6

space d6 is c1

35 c1 d6-f5 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var c1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end d6-f5 2 1 1 4 16 8 32 8

bb end d6-f5 2 1 1 4 16 8 32 8

bw end d6-f5 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is g2-g4, p is #p, o is g2

space g2 is P

36 P g2-g4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is f5-h4, p is #p, o is f5

space f5 is c1

37 c1 f5-h4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var c1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end f5-h4 2 1 1 4 16 8 32 8

bb end f5-h4 2 1 1 4 16 8 32 8

bw end f5-h4 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is h2-g3, p is #p, o is h2

space h2 is g1

38 g1 h2-g3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var g1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end h2-g3 2 1 1 4 16 8 32 8

bb end h2-g3 2 1 1 4 16 8 32 8

bw end h2-g3 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is g6-g5, p is #p, o is g6

space g6 is p

39 p g6-g5 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is d1-d3, p is #p, o is d1

space d1 is h1

40 h1 d1-d3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var h1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end d1-d3 2 1 1 4 16 8 32 8

bb end d1-d3 2 1 1 4 16 8 32 8

bw end d1-d3 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is g8-g7, p is #p, o is g8

space g8 is g1

41 g1 g8-g7 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var g1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end g8-g7 2 1 1 4 16 8 32 8

bb end g8-g7 2 1 1 4 16 8 32 8

bw end g8-g7 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is f3-f4, p is #p, o is f3

space f3 is P

42 P f3-f4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is h7-h6, p is #p, o is h7

space h7 is p

43 p h7-h6 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is f4-g5, p is #p, o is f4

space f4 is P

44 P f4-g5 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is h6-g5, p is #p, o is h6

space h6 is p

45 p h6-g5 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is d3-d4, p is #p, o is d3

space d3 is h1

46 h1 d3-d4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var h1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end d3-d4 2 1 1 4 16 8 32 8

bb end d3-d4 2 1 1 4 16 8 32 8

bw end d3-d4 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is e8-e7, p is #p, o is e8

space e8 is f1

47 f1 e8-e7 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var f1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end e8-e7 2 1 1 4 16 8 32 8

bb end e8-e7 2 1 1 4 16 8 32 8

bw end e8-e7 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is a2-a4, p is #p, o is a2

space a2 is P

48 P a2-a4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is h8-e8, p is #p, o is h8

space h8 is h1

49 h1 h8-e8 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var h1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end h8-e8 2 1 1 4 16 8 32 8

bb end h8-e8 2 1 1 4 16 8 32 8

bw end h8-e8 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is d4-d2, p is #p, o is d4

space d4 is h1

50 h1 d4-d2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var h1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end d4-d2 2 1 1 4 16 8 32 8

bb end d4-d2 2 1 1 4 16 8 32 8

bw end d4-d2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is e7-e3, p is #p, o is e7

space e7 is f1

51 f1 e7-e3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var f1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end e7-e3 2 1 1 4 16 8 32 8

bb end e7-e3 2 1 1 4 16 8 32 8

bw end e7-e3 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is g3-h2, p is #p, o is g3

space g3 is g1

52 g1 g3-h2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var g1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end g3-h2 2 1 1 4 16 8 32 8

bb end g3-h2 2 1 1 4 16 8 32 8

bw end g3-h2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is h4-f3, p is #p, o is h4

space h4 is c1

53 c1 h4-f3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var c1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end h4-f3 2 1 1 4 16 8 32 8

bb end h4-f3 2 1 1 4 16 8 32 8

bw end h4-f3 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is f2-f3, p is #p, o is f2

space f2 is f1

54 f1 f2-f3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var f1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end f2-f3 2 1 1 4 16 8 32 8

bb end f2-f3 2 1 1 4 16 8 32 8

bw end f2-f3 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is e3-f3, p is #p, o is e3

space e3 is f1

55 f1 e3-f3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var f1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end e3-f3 2 1 1 4 16 8 32 8

bb end e3-f3 2 1 1 4 16 8 32 8

bw end e3-f3 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is b3-b4, p is #p, o is b3

space b3 is P

56 P b3-b4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is f3-e3, p is #p, o is f3

space f3 is f1

57 f1 f3-e3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var f1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end f3-e3 2 1 1 4 16 8 32 8

bb end f3-e3 2 1 1 4 16 8 32 8

bw end f3-e3 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is b4-b5, p is #p, o is b4

space b4 is P

58 P b4-b5 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is e3-e2, p is #p, o is e3

space e3 is f1

59 f1 e3-e2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var f1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end e3-e2 2 1 1 4 16 8 32 8

bb end e3-e2 2 1 1 4 16 8 32 8

bw end e3-e2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is d2-e2, p is #p, o is d2

space d2 is h1

60 h1 d2-e2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var h1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end d2-e2 2 1 1 4 16 8 32 8

bb end d2-e2 2 1 1 4 16 8 32 8

bw end d2-e2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is e8-e2, p is #p, o is e8

space e8 is h1

61 h1 e8-e2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var h1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end e8-e2 2 1 1 4 16 8 32 8

bb end e8-e2 2 1 1 4 16 8 32 8

bw end e8-e2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is h2-g1, p is #p, o is h2

space h2 is g1

62 g1 h2-g1 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var g1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end h2-g1 2 1 1 4 16 8 32 8

bb end h2-g1 2 1 1 4 16 8 32 8

bw end h2-g1 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is c6-c5, p is #p, o is c6

space c6 is p

63 p c6-c5 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is a4-a5, p is #p, o is a4

space a4 is P

64 P a4-a5 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is c5-c4, p is #p, o is c5

space c5 is p

65 p c5-c4 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is b5-b6, p is #p, o is b5

space b5 is P

66 P b5-b6 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is c4-c3, p is #p, o is c4

space c4 is p

67 p c4-c3 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is b6-a7, p is #p, o is b6

space b6 is P

68 P b6-a7 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is c3-c2, p is #p, o is c3

space c3 is p

69 p c3-c2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

mv is g1-f1, p is #p, o is g1

space g1 is g1

70 g1 g1-f1 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var g1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end g1-f1 2 1 1 4 16 8 32 8

bb end g1-f1 2 1 1 4 16 8 32 8

bw end g1-f1 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is e2-d2, p is #p, o is e2

space e2 is h1

71 h1 e2-d2 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var h1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end e2-d2 2 1 1 4 16 8 32 8

bb end e2-d2 2 1 1 4 16 8 32 8

bw end e2-d2 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is f1-g1, p is #p, o is f1

space f1 is g1

72 g1 f1-g1 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

1 one bits in var g1

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end f1-g1 2 1 1 4 16 8 32 8

bb end f1-g1 2 1 1 4 16 8 32 8

bw end f1-g1 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

mv is c2-c1; q-c1, p is c2-c1;, o is q

space q is

73 c2-c1; q-c1 2 1 1 4 16 8 32 8

10 1 1 100 10000 1000 100000 1000

0 one bits in var

10 1 1 100 10000 1000 100000 1000

g1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
    [4] => e1
    [5] => f1
)

q end c2-c1; q-c1 2 1 1 4 16 8 32 8

bb end c2-c1; q-c1 2 1 1 4 16 8 32 8

bw end c2-c1; q-c1 2 1 1 4 16 8 32 8

first 2 1 1 4 16 8 32 8

\count is 3

Syntax Error on line 1088

The first argument to the move command, q, is not a recognized coordinate.

Edit the Settings File for Fischer Random Chess

For the sake of debugging, here is the full GAME Code program that this error occurred in. The lines have been properly indented to help you spot scope errors.

   0 empty a1 b1 c1 d1 e1 f1 g1 h1 a8 b8 c8 d8 e8 f8 h8
   1 include fischer
   2 if isconst firstrank
   3   for i range 0 7
   4     set c join chr + 97 var i 1
   5     set p substr const firstrank var i 1
   6     add #p #c
   7   next
   8 elseif == status "Ongoing"
   9   drop B any a1 c1 e1 g1
  10   drop B any b1 d1 f1 h1
  11   drop Q any a1 b1 c1 d1 e1 f1 g1 h1
  12   drop N any a1 b1 c1 d1 e1 f1 g1 h1
  13   drop N any a1 b1 c1 d1 e1 f1 g1 h1
  14   drop R first a1 b1 c1 d1 e1 f1
  15   drop K first b1 c1 d1 e1 f1 g1
  16   drop R last c1 d1 e1 f1 g1 h1
  17   set fr null
  18   for i range a h
  19     set fr join var fr space join var i 1
  20   next
  21   setconst firstrank var fr
  22 else
  23   echo "Since no firstrank constant has been stored for this game, one will be calculated by analyzing the moves in the game. This will work only if the game lasted long enough to put enough pieces into play."
  24   gosub calc_original_position
  25 endif
  26 copy a1 a8
  27 copy b1 b8
  28 copy c1 c8
  29 copy d1 d8
  30 copy e1 e8
  31 copy f1 f8
  32 copy g1 g8
  33 copy h1 h8
  34 flip a8 b8 c8 d8 e8 f8 g8 h8
  35 set AR findpiece R first a1 b1 c1 d1 e1 f1
  36 set HR findpiece R first h1 g1 f1 e1 d1 c1
  37 set K findpiece K first b1 c1 d1 e1 f1 g1
  38 set ar findpiece r first a8 b8 c8 d8 e8 f8
  39 set hr findpiece r first h8 g8 f8 e8 d8 c8
  40 set k findpiece k first b8 c8 d8 e8 f8 g8
  41 setflag #AR #HR #K #ar #hr #k
  42 set k findpiece k spaces
  43 set K findpiece K spaces
  44 set ep false
  45 set koo g8
  46 set roo f8
  47 set kooo c8
  48 set rooo d8
  49 set KOO g1
  50 set ROO f1
  51 set KOOO c1
  52 set ROOO d1
  53 setsystem "dest" null
  54 sub postauto1
  55   if not equal moved P
  56     set ep false
  57     if unequal space dest moved
  58       die You may not change the type of this piece.
  59     endif
  60   endif
  61   set legal false
  62   if match moved P K R
  63     gosub moved origin dest
  64     if equal moved K
  65       set K dest
  66     endif
  67   elseif match moved Q B N
  68     set legal fn moved origin dest
  69   endif
  70   if not var legal
  71     die You may not move a moved from origin to dest
  72   endif
  73   if isupper $old and != $old K and != $moved R
  74     die You may not capture your own pieces.
  75   endif
  76   if fn ATTACKEDBYB #K
  77     die You may not move into check.
  78   endif
  79 endsub
  80 sub postauto2
  81   if not equal moved p
  82     set ep false
  83     if unequal space dest moved
  84       die You may not change the type of this piece.
  85     endif
  86   endif
  87   set legal false
  88   if match moved p k r
  89     gosub moved origin dest
  90     if equal moved k
  91       set k dest
  92     endif
  93   elseif match moved q b n
  94     set legal fn toupper moved origin dest
  95   endif
  96   if not var legal
  97     die You may not move a moved from origin to dest
  98   endif
  99   if islower old and != $old k and != $moved r
 100     die You may not capture your own pieces.
 101   endif
 102   if fn ATTACKEDBYW #k
 103     die You may not move into check.
 104   endif
 105 endsub
 106 moveindex 0
 107 MOVE: f2-f3
 108 postauto1
 109 moveindex 1
 110 MOVE: c7-c6
 111 postauto2
 112 moveindex 2
 113 MOVE: b2-b3
 114 postauto1
 115 moveindex 3
 116 MOVE: d8-b6
 117 postauto2
 118 moveindex 4
 119 MOVE: e2-e3
 120 postauto1
 121 moveindex 5
 122 MOVE: d7-d6
 123 postauto2
 124 moveindex 6
 125 MOVE: e1-g3
 126 postauto1
 127 moveindex 7
 128 MOVE: e7-e5
 129 postauto2
 130 moveindex 8
 131 MOVE: d2-d4
 132 postauto1
 133 moveindex 9
 134 MOVE: e5-d4
 135 postauto2
 136 moveindex 10
 137 MOVE: e3-d4
 138 postauto1
 139 moveindex 11
 140 MOVE: e8-e3
 141 postauto2
 142 moveindex 12
 143 MOVE: f1-f2
 144 postauto1
 145 moveindex 13
 146 MOVE: b6-d4
 147 postauto2
 148 moveindex 14
 149 MOVE: a1-d4
 150 postauto1
 151 moveindex 15
 152 MOVE: e3-d4
 153 postauto2
 154 moveindex 16
 155 MOVE: c1-e2
 156 postauto1
 157 moveindex 17
 158 MOVE: d4-d1
 159 postauto2
 160 moveindex 18
 161 MOVE: f2-f1
 162 postauto1
 163 moveindex 19
 164 MOVE: d1-e2
 165 postauto2
 166 moveindex 20
 167 MOVE: b1-c3
 168 postauto1
 169 moveindex 21
 170 MOVE: e2-c2
 171 postauto2
 172 moveindex 22
 173 MOVE: c3-e4
 174 postauto1
 175 moveindex 23
 176 MOVE: c2-b2
 177 postauto2
 178 moveindex 24
 179 MOVE: e4-d6
 180 postauto1
 181 moveindex 25
 182 MOVE: b2-d4
 183 postauto2
 184 moveindex 26
 185 MOVE: f1-f2
 186 postauto1
 187 moveindex 27
 188 MOVE: d4-d6
 189 postauto2
 190 moveindex 28
 191 MOVE: g3-d6
 192 postauto1
 193 moveindex 29
 194 MOVE: c8-d6
 195 postauto2
 196 moveindex 30
 197 MOVE: h2-h3
 198 postauto1
 199 moveindex 31
 200 MOVE: g7-g6
 201 postauto2
 202 moveindex 32
 203 MOVE: g1-h2
 204 postauto1
 205 moveindex 33
 206 MOVE: f8-e8
 207 postauto2
 208 moveindex 34
 209 MOVE: h1-d1
 210 postauto1
 211 moveindex 35
 212 MOVE: d6-f5
 213 postauto2
 214 moveindex 36
 215 MOVE: g2-g4
 216 postauto1
 217 moveindex 37
 218 MOVE: f5-h4
 219 postauto2
 220 moveindex 38
 221 MOVE: h2-g3
 222 postauto1
 223 moveindex 39
 224 MOVE: g6-g5
 225 postauto2
 226 moveindex 40
 227 MOVE: d1-d3
 228 postauto1
 229 moveindex 41
 230 MOVE: g8-g7
 231 postauto2
 232 moveindex 42
 233 MOVE: f3-f4
 234 postauto1
 235 moveindex 43
 236 MOVE: h7-h6
 237 postauto2
 238 moveindex 44
 239 MOVE: f4-g5
 240 postauto1
 241 moveindex 45
 242 MOVE: h6-g5
 243 postauto2
 244 moveindex 46
 245 MOVE: d3-d4
 246 postauto1
 247 moveindex 47
 248 MOVE: e8-e7
 249 postauto2
 250 moveindex 48
 251 MOVE: a2-a4
 252 postauto1
 253 moveindex 49
 254 MOVE: h8-e8
 255 postauto2
 256 moveindex 50
 257 MOVE: d4-d2
 258 postauto1
 259 moveindex 51
 260 MOVE: e7-e3
 261 postauto2
 262 moveindex 52
 263 MOVE: g3-h2
 264 postauto1
 265 moveindex 53
 266 MOVE: h4-f3
 267 postauto2
 268 moveindex 54
 269 MOVE: f2-f3
 270 postauto1
 271 moveindex 55
 272 MOVE: e3-f3
 273 postauto2
 274 moveindex 56
 275 MOVE: b3-b4
 276 postauto1
 277 moveindex 57
 278 MOVE: f3-e3
 279 postauto2
 280 moveindex 58
 281 MOVE: b4-b5
 282 postauto1
 283 moveindex 59
 284 MOVE: e3-e2
 285 postauto2
 286 moveindex 60
 287 MOVE: d2-e2
 288 postauto1
 289 moveindex 61
 290 MOVE: e8-e2
 291 postauto2
 292 moveindex 62
 293 MOVE: h2-g1
 294 postauto1
 295 moveindex 63
 296 MOVE: c6-c5
 297 postauto2
 298 moveindex 64
 299 MOVE: a4-a5
 300 postauto1
 301 moveindex 65
 302 MOVE: c5-c4
 303 postauto2
 304 moveindex 66
 305 MOVE: b5-b6
 306 postauto1
 307 moveindex 67
 308 MOVE: c4-c3
 309 postauto2
 310 moveindex 68
 311 MOVE: b6-a7
 312 postauto1
 313 moveindex 69
 314 MOVE: c3-c2
 315 postauto2
 316 moveindex 70
 317 MOVE: g1-f1
 318 postauto1
 319 moveindex 71
 320 MOVE: e2-d2
 321 postauto2
 322 moveindex 72
 323 MOVE: f1-g1
 324 postauto1
 325 moveindex 73
 326 MOVE: c2-c1
 327 MOVE:  q-c1
 328 postauto2
 329 set checks sub checks #K
 330 if var checks
 331   if sub checkmated #K #checks
 332     say Checkmate! Black has won!
 333     won
 334   else
 335     say Check!
 336   endif
 337 elseif sub stalemated #K
 338   say Stalemate! The game is drawn.
 339   drawn
 340 endif
 341 end
 342 
 343 lib fischer
 344 include chess
 345 set wprom (Q R B N)
 346 set bprom (q r b n)
 347 sub K from to
 348   set legal fn K #from #to
 349   if not var legal or == old R
 350     if == #to #KOOO
 351       castle #K #KOOO #AR #ROOO
 352     elseif == #to #KOO
 353       castle #K #KOO #HR #ROO
 354     endif
 355   endif
 356   set K #to
 357   unsetflag #from
 358 endsub
 359 sub k from to
 360   set legal fn K #from #to
 361   if not var legal or == old r
 362     if == #to #kooo
 363       castle #k #kooo #ar #rooo
 364     elseif == #to #koo
 365       castle #k #koo #hr #roo
 366     endif
 367   endif
 368   set k #to
 369   unsetflag #from
 370 endsub
 371 sub R from to
 372   set legal fn R #from #to
 373   if not var legal or == old K
 374     echo "Castling with Rook!" #from #to #AR #ROOO #HR #ROO
 375     if == #from #AR and == #to #ROOO
 376       castle #K #KOOO #from #ROOO
 377       set K #KOOO
 378     elseif == #from #HR and == #to #ROO
 379       castle #K #KOO #from #ROO
 380       set K #KOO
 381     endif
 382   endif
 383   unsetflag #from
 384 endsub
 385 sub r from to
 386   set legal fn R #from #to
 387   if not var legal or == old k
 388     if == #from #ar and == #to #rooo
 389       castle #k #kooo #from #rooo
 390       set k #kooo
 391     elseif == #from #hr and == #to #roo
 392       castle #k #koo #from #roo
 393       set k #koo
 394     endif
 395   endif
 396   unsetflag #from
 397 endsub
 398 sub castle
 399   local ATTACKED c KP RP KF KT RF RT RN
 400   if < count #subargs 4
 401     die The castle suboutine requires at least four arguments.
 402   endif
 403   set KF #subargs.0
 404   set KT #subargs.1
 405   set RF #subargs.2
 406   set RT #subargs.3
 407   if > count #subargs 4
 408     set RN #subargs.4
 409   else
 410     set RN Rook
 411   endif
 412   if not flag #KF
 413     die A King may not castle after it moves.
 414   endif
 415   if not flag #RF
 416     die A #RN may not castle after it moves.
 417   endif
 418   if empty #KF and empty #RF
 419     die Please castle by moving only one piece.
 420   elseif empty #KF
 421     if != #RF #KT
 422       if capture
 423         die The King may not castle to an occupied space.
 424       endif
 425       set RP space #RF
 426     else
 427       set RP old
 428       setglobal lastcaptured nil
 429     endif
 430     set KP space #KT
 431     empty #KT
 432     empty #RF
 433   elseif empty #RF
 434     if != #KF #RT
 435       if capture
 436         die The #RN may not castle to an occupied space.
 437       endif
 438       set KP space #KF
 439     else
 440       set KP old
 441       setglobal lastcaptured nil
 442     endif
 443     set RP space #RT
 444     empty #KF
 445     empty #RT
 446   elseif capture
 447     die You're not allowed to castle with a null move.
 448   else
 449     set RP space #RF
 450     set KP space #KF
 451     empty #KF
 452     empty #RF
 453   endif
 454   unsetflag #KF
 455   unsetflag #RF
 456   if not checkride #KF #KT 1 0 and != #KF #KT
 457     die The King may not castle across an obstructed path.
 458   endif
 459   if not checkride #RF #RT 1 0 and != #RF #RT
 460     die The #RN may not castle across an obstructed path.
 461   endif
 462   add #RP #RF
 463   set ATTACKED ATTACKEDBYW unless isupper moved ATTACKEDBYB
 464   if fn #ATTACKED #KT
 465     die A King may not castle out of check.
 466   endif
 467   for c path #KF #KT
 468     if fn var ATTACKED #c
 469       die A King may not castle through check.
 470     endif
 471   next
 472   move #RF #RT
 473   add #KP #KT
 474   set legal true
 475 endsub
 476 sub castlepos KF KT RF RT
 477   local ATTACKED c safe
 478   verify flag #KF
 479   verify flag #RF
 480   verify empty #KT or match #KT #KF #RF
 481   verify empty #RT or match #RT #KF #RF
 482   verify checkride #KF #RF 1 0
 483   verify checkride #KF #KT 1 0 or checkride #RF #KT 1 0
 484   verify allequal rank #KF rank #KT rank #RF rank #RT
 485   if isupper space #king
 486     def friend isupper #0
 487     def friends onlyupper
 488     set attacked ATTACKEDBYB
 489   else
 490     def friend islower #0
 491     def friends onlylower
 492     set attacked ATTACKEDBYW
 493   endif
 494   verify not fn var attacked #KF
 495   verify not fn var attacked #KT
 496   foreach c path #KF #KT
 497     verify not fn var attacked #c
 498   next
 499   store
 500   if != #KT #RF
 501     move #KF #KT
 502     move #RF #RT
 503   else
 504     move #RF #RT
 505     move #KF #KT
 506   endif
 507   set safe not fn var attacked #KT
 508   restore
 509   return #safe
 510 endsub
 511 sub stalemated king
 512   local legalmove temp from piece to attacked ra
 513   if isupper space #king
 514     def friend isupper #0
 515     def friends onlyupper
 516     set attacked ATTACKEDBYB
 517   else
 518     def friend islower #0
 519     def friends onlylower
 520     set attacked ATTACKEDBYW
 521   endif
 522   store
 523   set kingmoves fn KL #king
 524   for to #kingmoves
 525     if not fn friend space #to and onboard #to
 526       move #king #to
 527       set incheck fn var attacked #to
 528       restore
 529       if not #incheck
 530         setlegal #king #to
 531       endif
 532     endif
 533   next
 534   if isupper space #king
 535     if sub castlepos #king #KOOO #AR #ROOO
 536       if > distance #king #KOOO 1 or == #KOOO #AR
 537         setlegal #king #KOOO
 538       else
 539         setlegal #AR #ROOO
 540       endif
 541     endif
 542     if sub castlepos #king #KOO #HR #ROO
 543       if > distance #king #KOO 1 or == #KOO #HR
 544         setlegal #king #KOO
 545       else
 546         setlegal #HR #ROO
 547       endif
 548     endif
 549   else
 550     if sub castlepos #king #kooo #ar #rooo
 551       if > distance #king #kooo 1 or == #kooo #ar
 552         setlegal #king #kooo
 553       else
 554         setlegal #ar #rooo
 555       endif
 556     endif
 557     if sub castlepos #king #koo #hr #roo
 558       if > distance #king #koo 1 or == #koo #hr
 559         setlegal #king #koo
 560       else
 561         setlegal #hr #roo
 562       endif
 563     endif
 564   endif
 565   restore
 566   for (from piece) fn friends
 567     if == #from #king
 568       continue
 569     endif
 570     for to fn join #piece L #from
 571       if fn #piece #from #to and not fn friend space #to and onboard #to
 572         move #from #to
 573         set incheck fn var attacked #king
 574         if not #incheck
 575           setlegal #from #to
 576         endif
 577       endif
 578       restore
 579     next
 580   next
 581   return cond count system legalmoves false true
 582 endsub
 583 sub calc_original_position
 584   store
 585   local a1 b1 c1 d1 e1 f1 g1 h1 n bb w b r q k K Q R B N ra firstr lastr last
 586   add a1 a1
 587   add b1 b1
 588   add c1 c1
 589   add d1 d1
 590   add e1 e1
 591   add f1 f1
 592   add g1 g1
 593   add h1 h1
 594   add a1 a8
 595   add b1 b8
 596   add c1 c8
 597   add d1 d8
 598   add e1 e8
 599   add f1 f8
 600   add g1 g8
 601   add h1 h8
 602   set many n 1 bb 2 bw 4 b 6 r 8 q 16 k 32
 603   set a1 orsum #r #n #bb #q
 604   set b1 orsum #r #n #bw #q #k
 605   set c1 orsum #r #n #bb #q #k
 606   set d1 orsum #r #n #bw #q #k
 607   set e1 orsum #r #n #bb #q #k
 608   set f1 orsum #r #n #bw #q #k
 609   set g1 orsum #r #n #bb #q #k
 610   set h1 orsum #r #n #bw #q
 611   set many K 1 Q 1 R 2 B 2 N 2
 612   set rank1 array a1 b1 c1 d1 e1 f1 g1 h1
 613   setflag a1 b1 c1 d1 e1 f1 g1 h1 a8 b8 c8 d8 e8 f8 g8 h8
 614   foreach i range 0 $maxmoves
 615     set normal true
 616     set mv move #i
 617     if not var mv
 618       echo "Continue because mv is empty"
 619       continue
 620     endif
 621     set mv str_replace " - " chr 45 var mv
 622     set pm explode " " var mv
 623     set p elem 0 pm
 624     set m elem 1 pm
 625     if != var m null
 626       set od explode hyphen var m
 627     else
 628       set od explode hyphen var mv
 629       unset p
 630     endif
 631     set o elem 0 od
 632     set d elem 1 od
 633     echo "mv is {#mv}, p is {#p}, o is {#o}"
 634     if == #mv #o
 635       echo "Continue because {#mv} is {#o}"
 636       continue
 637     endif
 638     set pp space #o
 639     echo "space {#o} is {#pp}"
 640     echo #i #pp #mv #a1 #b1 #c1 #d1 #e1 #f1 #g1 #h1
 641     set b2 list base 2 #a1 base 2 #b1 base 2 #c1 base 2 #d1 base 2 #e1 base 2 #f1 base 2 #g1 base 2 #h1
 642     echo #b2
 643     if match #pp p P
 644       if checkleap #o #d 1 1 and empty #d
 645         set ep join filename #d rankname #o
 646         if == space #ep flipcase space #0
 647           empty #ep
 648         endif
 649       endif
 650       move #o #d
 651       continue
 652     elseif match #pp n N b B r R q Q
 653       move #o #d
 654       continue
 655     endif
 656     set bp onebits var #pp
 657     echo "{#bp} one bits in var {#pp}"
 658     if > #bp 1 and match var p k q r b n p K Q R B N P and != var p null
 659       set lc tolower var p
 660       set #pp bitand ##pp ##lc
 661     elseif == ##pp "@"
 662       echo "Warning: There is no piece on {#o}"
 663     elseif > #bp 1
 664       if checkleap #o #d 1 2
 665         set #pp bitand ##pp #n
 666       elseif checkleap #o #d 1 0
 667         set os orsum #r #q #k
 668         set #pp bitand ##pp orsum #r #q #k
 669       elseif checkleap #o #d 1 1
 670         set #pp bitand ##pp orsum #b #q #k
 671       elseif checkride #o #d 1 1
 672         set #pp bitand ##pp orsum #b #q
 673       elseif checkride #o #d 1 0
 674         echo "rook ride"
 675         if == rank #o rank #d and match rankname #d 1 8
 676           if match #d c1 g1 c8 g8 and flag #o
 677             if not empty #d
 678               echo "King castles by moving to Rook's space."
 679               set #pp bitand ##pp #k
 680               set ro #d
 681               set rp space #ro
 682               set #rp #r
 683               echo "rp: {#rp}, val: {##rp}"
 684               if == #d c1
 685                 set rd d1
 686               elseif == #d c8
 687                 set rd d8
 688               elseif == #d g1
 689                 set rd f1
 690               else
 691                 set rd f8
 692               endif
 693               move #o temp
 694               move #d #rd
 695               move temp #d
 696               foreach f flags
 697                 if == rank f rank #o
 698                   unsetflag #f
 699                 endif
 700               next
 701               set normal false
 702             elseif empty #d and bitand ##pp #k
 703               echo "King castling by moving 2+ spaces"
 704               if == #d c1
 705                 if empty b1
 706                   set ro a1
 707                 else
 708                   set ro b1
 709                 endif
 710                 set rd d1
 711               elseif == #d g1
 712                 set ro h1
 713                 set rd f1
 714               elseif == #d c8
 715                 if empty b8
 716                   set ro a8
 717                 else
 718                   set ro b8
 719                 endif
 720                 set rd d8
 721               elseif == #d g8
 722                 set ro h8
 723                 set rd f8
 724               endif
 725               set rp space #ro
 726               if not bitand #ko #r or not bitand #a1 #r or match file #ro a h bitand ##rp #r and not bitand ##pp #q and flag #ro
 727                 move #o #d
 728                 move #ro #rd
 729                 set #pp #k
 730                 set #rp #r
 731                 foreach f flags
 732                   if == rank f rank #o
 733                     unsetflag #f
 734                   endif
 735                 next
 736                 set normal false
 737               else
 738                 echo "Assuming not actually a castling move."
 739                 set #pp bitand ##pp orsum #r #q
 740               endif
 741             else
 742               echo "Rook or Queen move"
 743               set #pp bitand ##pp orsum #r #q
 744             endif
 745           elseif not empty #d and match #d f1 d1 f8 d8 and flag #o
 746             echo "Rook castles by moving to King's space."
 747             set #pp bitand ##pp #r
 748             set ko #d
 749             echo "ko set to {#ko}"
 750             set kp space #ko
 751             set #kp #k
 752             echo "{#kp} set to {##kp}"
 753             if == #d f1
 754               set kd g1
 755             elseif == #d d1
 756               set kd c1
 757             elseif == #d f8
 758               set kd g8
 759             elseif == #d d8
 760               set kd c8
 761             endif
 762             if == #kd #o
 763               swap #kd #o
 764             else
 765               move #o #d
 766               move #ko #kd
 767             endif
 768             foreach f flags
 769               if == rank f rank #o
 770                 unsetflag #f
 771               endif
 772             next
 773             set normal false
 774           else
 775             echo "Rook or Queen move"
 776             set #pp bitand ##pp orsum #r #q
 777           endif
 778         else
 779           echo "{#pp} currently set to {##pp}"
 780           set #pp bitand ##pp bitor #r #q
 781           echo "{#pp} now set to {##pp}"
 782         endif
 783       elseif checkhop #o #d 1 0 and match rankname #o 1 8 and flag #o
 784         echo "rook hopping king to castle"
 785         if and match #d f1 d1 f8 d8
 786           set #pp bitand ##pp #r
 787           set ko screen
 788           set kp var space #ko
 789           set #kp #k
 790           if == #d f1
 791             set kd g1
 792           elseif == #d d1
 793             set kd c1
 794           elseif == #d f8
 795             set kd g8
 796           elseif == #d d8
 797             set kd c8
 798           endif
 799           if == #kd #o and == #d #ko
 800             swap #kd #o
 801           elseif == #d #ko
 802             move #o temp
 803             move #ko #kd
 804             move temp #d
 805           else
 806             move #o #d
 807             move #ko #kd
 808           endif
 809           foreach f flags
 810             if == rank f rank #o
 811               unsetflag #f
 812             endif
 813           next
 814           set normal false
 815         elseif match #d c1 g1 c8 g8 and flag #o
 816           echo "King castling by hopping over Rook"
 817           set #pp bitand ##pp #k
 818           set ro screen
 819           set rp var space #ro
 820           set #rp #r
 821           if == #d c1
 822             set rd d1
 823           elseif == #d c8
 824             set rd d8
 825           elseif == #d g1
 826             set rd f1
 827           else
 828             set rd f8
 829           endif
 830           move #o #d
 831           move #ro #rd
 832           foreach f flags
 833             if == rank f rank #o
 834               unsetflag #f
 835             endif
 836           next
 837           set normal false
 838         endif
 839       endif
 840       if == ##pp 0
 841         echo "ERROR: Potential piece value set to zero"
 842       endif
 843     endif
 844     do
 845       set b2 list base 2 #a1 base 2 #b1 base 2 #c1 base 2 #d1 base 2 #e1 base 2 #f1 base 2 #g1 base 2 #h1
 846       echo #b2
 847       set changed false
 848       set ra aggregate lambda (cond bitand var #0 #k #0 false) #rank1
 849       if == count #ra 1
 850         set kp #ra.0
 851         if != ##kp #k
 852           set #kp #k
 853           set changed true
 854         endif
 855         set ra aggregate lambda (cond == var #0 #k #0 false) #rank1
 856         set kp #ra.0
 857         echo #kp
 858         set leftside aggregate lambda (cond < #0 #kp #0 false) #rank1
 859         printr #leftside
 860         set ra aggregate lambda (cond bitand var #0 #r #0 false) #leftside
 861         if == count #ra 1
 862           foreach sp #ra
 863             if != ##sp #r
 864               set #sp #r
 865               set changed true
 866             endif
 867           next
 868         else
 869           set ra aggregate lambda (cond == var #0 #r #0 false) #leftside
 870           if == count #ra 1
 871             foreach sp #leftside
 872               if != ##sp #r
 873                 set #sp bitand ##sp bitxor 63 #r
 874                 set changed true
 875               endif
 876             next
 877           endif
 878         endif
 879         set rightside aggregate lambda (cond > #0 #kp #0 false) #rank1
 880         set ra aggregate lambda (cond bitand var #0 #r #0 false) #rightside
 881         if == count #ra 1
 882           foreach sp #ra
 883             if != ##sp #r
 884               set #sp #r
 885               set changed true
 886             endif
 887           next
 888         else
 889           set ra aggregate lambda (cond == var #0 #r #0 false) #rightside
 890           if == count #ra 1
 891             foreach sp #rightside
 892               if != ##sp #r
 893                 set #sp bitand ##sp bitxor 63 #r
 894                 set changed true
 895               endif
 896             next
 897           endif
 898         endif
 899       else
 900         set ra aggregate lambda (cond != var #0 #k #0 false) #rank1
 901         if == count #ra 7
 902           foreach sp #ra
 903             if bitand ##sp #k
 904               set #sp bitand ##sp bitxor 63 #k
 905               set changed true
 906             endif
 907           next
 908         endif
 909       endif
 910       set ra aggregate lambda (cond bitand var #0 #q #0 false) #rank1
 911       if == count #ra 1
 912         foreach sp #ra
 913           if != ##sp #q
 914             set #sp #q
 915             set changed true
 916           endif
 917         next
 918       else
 919         set ra aggregate lambda (cond != var #0 #q #0 false) #rank1
 920         if == count #ra 7
 921           echo queen before #mv #a1 #b1 #c1 #d1 #e1 #f1 #g1 #h1
 922           foreach sp #ra
 923             if bitand ##sp #q
 924               set #sp bitand ##sp bitxor 63 #q
 925               set changed true
 926             endif
 927           next
 928           echo queen after #mv #a1 #b1 #c1 #d1 #e1 #f1 #g1 #h1
 929         endif
 930       endif
 931       echo q end #mv #a1 #b1 #c1 #d1 #e1 #f1 #g1 #h1
 932       set ra aggregate lambda (cond bitand var #0 #bb #0 false) #rank1
 933       if == count #ra 1
 934         foreach sp #ra
 935           if != ##sp #bb
 936             set #sp #bb
 937             set changed true
 938           endif
 939         next
 940       else
 941         set ra aggregate lambda (cond != var #0 #bb #0 false) #rank1
 942         if == count #ra 7
 943           foreach sp #ra
 944             if bitand ##sp #bb
 945               set #sp bitand ##sp bitxor 63 #bb
 946               set changed true
 947             endif
 948           next
 949         endif
 950       endif
 951       echo bb end #mv #a1 #b1 #c1 #d1 #e1 #f1 #g1 #h1
 952       set ra aggregate lambda (cond bitand var #0 #bw #0 false) #rank1
 953       if == count #ra 1
 954         foreach sp #ra
 955           if != ##sp #bw
 956             set #sp #bw
 957             set changed true
 958           endif
 959         next
 960       else
 961         set ra aggregate lambda (cond != var #0 #bw #0 false) #rank1
 962         if == count #ra 7
 963           foreach sp #ra
 964             if bitand ##sp #bw
 965               set #sp bitand ##sp bitxor 63 #bw
 966               set changed true
 967             endif
 968           next
 969         endif
 970       endif
 971       echo bw end #mv #a1 #b1 #c1 #d1 #e1 #f1 #g1 #h1
 972       set ra aggregate lambda (cond bitand var #0 #r #0 false) #rank1
 973       if == count #ra 2
 974         foreach sp #ra
 975           if != ##sp #r
 976             set #sp #r
 977             set changed true
 978           endif
 979         next
 980         set betweenrooks aggregate lambda (cond and < #ra.0 #0 > #ra.1 #0 #0 false) #rank1
 981         set ra2 aggregate lambda (cond bitand var #0 #k #0 false) #betweenrooks
 982         if == count #ra2 1
 983           foreach sp #ra2
 984             if != ##sp #k
 985               set #sp #k
 986               set changed true
 987             endif
 988           next
 989         else
 990           set ra2 aggregate lambda (cond == var #0 #r #0 false) #rank1
 991           foreach sp #rank1
 992             echo #ra2.0 #ra2.1
 993             if < #sp #ra2.0 or > #sp #ra2.1 and bitand ##sp #k
 994               set #sp bitand ##sp bitxor 63 #k
 995               set changed true
 996             endif
 997           next
 998         endif
 999       else
1000         set firstr #ra.0
1001         set last - count #ra 1
1002         set lastr #ra.{#last}
1003         echo "firstr is {#firstr}, and lastr is {#lastr}"
1004         set rooks 0
1005         foreach sp #rank1
1006           if match #sp #firstr #lastr
1007             inc rooks
1008             if bitand ##sp #k
1009               set #sp bitand ##sp bitxor 63 #k
1010               set changed true
1011             endif
1012           elseif != #rooks 1
1013             if bitand ##sp #k
1014               set #sp bitand ##sp bitxor 63 #k
1015               set changed true
1016             endif
1017           endif
1018         next
1019         if == count #ra 3
1020           set leftking anytrue lambda (bitand var #0 #k and > #0 #ra.0 and < #0 #ra.1) #rank1
1021           set rghtking anytrue lambda (bitand var #0 #k and > #0 #ra.1 and < #0 #ra.2) #rank1
1022           if not #leftking
1023             set #ra.2 #r
1024           elseif not #rghtking
1025             set #ra.0 #r
1026           endif
1027         endif
1028         set ra aggregate lambda (cond != var #0 #r #0 false) #rank1
1029         if == count #ra 6
1030           echo "Two rooks found."
1031           foreach sp #ra
1032             if bitand ##sp #r
1033               set #sp bitand ##sp bitxor 63 #r
1034               set changed true
1035             endif
1036           next
1037         elseif == count #ra 7
1038           echo "One Rook found"
1039           set ra aggregate lambda (cond == var #0 #r #0 false) #rank1
1040           set next where #ra.0 1 0
1041           do while onboard #next
1042             echo #next ##next
1043             if bitand ##next #r
1044               set #next bitand ##next bitxor 63 #r
1045               set changed true
1046             endif
1047             if bitand ##next #k
1048               break
1049             endif
1050             set next where #next 1 0
1051           loop
1052           set prev where #ra.0 -1 0
1053           do while onboard #prev
1054             if bitand ##prev #r
1055               set #prev bitand ##prev bitxor 63 #r
1056               set changed true
1057             endif
1058             if bitand ##prev #k
1059               break
1060             endif
1061             set prev where #prev -1 0
1062           loop
1063         endif
1064         echo r #mv #a1 #b1 #c1 #d1 #e1 #f1 #g1 #h1
1065       endif
1066       echo first #a1 #b1 #c1 #d1 #e1 #f1 #g1 #h1
1067       set ra aggregate lambda (cond bitand var #0 #2 #0 false) #rank1
1068       if == count #ra 2
1069         foreach sp #ra
1070           if != ##sp #n
1071             set #sp #n
1072             set changed true
1073           endif
1074         next
1075       else
1076         set ra aggregate lambda (cond != var #0 #n #0 false) #rank1
1077         if == count #ra 6
1078           foreach sp #ra
1079             if bitand ##sp #n
1080               set #sp bitand ##sp bitxor 63 #n
1081               set changed true
1082             endif
1083           next
1084         endif
1085       endif
1086     loop while #changed
1087     if var normal
1088       move #o #d
1089       unsetflag #o #d
1090     endif
1091   next
1092   set fr ""
1093   foreach c (a1 b1 c1 d1 e1 f1 g1 h1)
1094     if == ##c #n
1095       set fr join #fr "N"
1096     elseif match ##c #bb #bw
1097       set fr join #fr "B"
1098     elseif == ##c #r
1099       set fr join #fr "R"
1100     elseif == ##c #q
1101       set fr join #fr "Q"
1102     elseif == ##c #k
1103       set fr join #fr "K"
1104     else
1105       set fr join #fr "@"
1106     endif
1107   next
1108   if !== false strstr #fr "@"
1109     set pat str_replace "@" "?" #fr
1110     empty a1 b1 c1 d1 e1 f1 g1 h1 a8 b8 c8 d8 e8 f8 h8
1111     drop B any a1 c1 e1 g1
1112     drop B any b1 d1 f1 h1
1113     drop Q any a1 b1 c1 d1 e1 f1 g1 h1
1114     drop N any a1 b1 c1 d1 e1 f1 g1 h1
1115     drop N any a1 b1 c1 d1 e1 f1 g1 h1
1116     drop R first a1 b1 c1 d1 e1 f1
1117     drop K first b1 c1 d1 e1 f1 g1
1118     drop R last c1 d1 e1 f1 g1 h1
1119     set fr null
1120     for i range a h
1121       set fr join var fr space join var i 1
1122     next
1123     if not fnmatch var pat var fr
1124       die "This game may have been too short to properly calculate the original position, and the calculated pattern of {#pat} is inconsistent with randomly generated value of {#fr}. If you think this game does have enough data to calculate the original position, please report it to Fergus Duniho."
1125     endif
1126   endif
1127   restore
1128   setconst firstrank #fr
1129   for i range 0 7
1130     set c join chr + 97 var i 1
1131     set p substr const firstrank var i 1
1132     add #p #c
1133   next
1134   echo "firstrank is" @firstrank
1135 endsub
1136 endlib
1137 lib chess
1138 set wpr 2
1139 set bpr 7
1140 set fps 2
1141 set pzs 1
1142 set wcastle c1 g1
1143 set bcastle c8 g8
1144 do
1145   local x
1146   for x piecekeys
1147     if match #x P K p k
1148       continue
1149     elseif isupper #x
1150       push wprom #x
1151     elseif islower #x
1152       push bprom #x
1153     endif
1154   next
1155 loop never
1156 setsystem maxmove 2
1157 ban commands allmoves
1158 allow moves 1 captures 1 promotions 2
1159 def N checkleap #0 #1 1 2
1160 def B checkride #0 #1 1 1
1161 def R checkride #0 #1 1 0
1162 def Q fn B #0 #1 or fn R #0 #1
1163 def K checkleap #0 #1 1 1 or checkleap #0 #1 1 0
1164 def M fn N #0 #1 or fn R #0 #1
1165 def A fn N #0 #1 or fn B #0 #1
1166 def n checkleap #0 #1 1 2
1167 def b checkride #0 #1 1 1
1168 def r checkride #0 #1 1 0
1169 def q fn b #0 #1 or fn r #0 #1
1170 def k checkleap #0 #1 1 1 or checkleap #0 #1 1 0
1171 def m fn n #0 #1 or fn r #0 #1
1172 def a fn n #0 #1 or fn b #0 #1
1173 def P
remove var ep
and checkleap #0 #1 1 1
and == var ep join filename #1 rankname #0
or and checkride #0 #1 0 1 == rankname #0 var wpr
or checkleap #0 #1 0 1
and empty #1
or and islower space #1 checkleap #0 #1 1 1
and <= distance #0 #1 var fps
and > rank #1 rank #0
1174 def p
remove var ep
and checkleap #0 #1 1 1
and == var ep join filename #1 rankname #0
or and checkride #0 #1 0 1 == rankname #0 var bpr
or checkleap #0 #1 0 1
and empty #1
or and isupper space #1 checkleap #0 #1 1 1
and <= distance #0 #1 var fps
and < rank #1 rank #0
1175 sub capturep p
1176   empty #p
1177   return true
1178 endsub
1179 sub checks king
1180   if not dest
1181     return false
1182   endif
1183   my checks c
1184   set checks ()
1185   if fn space dest dest #king
1186     setelem checks dest space dest
1187   endif
1188   set c sub checkedthru #king origin
1189   if #c
1190     setelem checks #c space #c
1191   elseif #epc
1192     set c sub checkedthru #king #epc
1193     if #c
1194       setelem checks #c space #c
1195     endif
1196   endif
1197   return var checks
1198 endsub
1199 sub checkmated king checks
1200   local from piece to key legalmove piece nopawn
1201   store
1202   if isupper space #king
1203     def friends onlyupper
1204     def friend isupper #0
1205     set attacked ATTACKEDBYB
1206   else
1207     def friends onlylower
1208     def friend islower #0
1209     set attacked ATTACKEDBYW
1210   endif
1211   set kingmoves fn KL #king
1212   for to #kingmoves
1213     if not fn friend space #to and onboard #to
1214       move #king #to
1215       set incheck fn var attacked #to
1216       restore
1217       if not #incheck
1218         setlegal #king #to
1219       endif
1220     endif
1221   next
1222   if == count var checks 1
1223     for (key enemy) var checks
1224       set possible path #king #key
1225       push possible #key
1226       if == #key #ep
1227         push possible cond isupper space #ep where #ep 0 -1 where #ep 0 1
1228       endif
1229       for (from piece) fn friends
1230         if == #from #king
1231           continue
1232         endif
1233         for to #possible
1234           if fn #piece #from #to
1235             move #from #to
1236             set incheck fn var attacked #king
1237             if not #incheck
1238               setlegal #from #to
1239             endif
1240           endif
1241           restore
1242         next
1243       next
1244     next
1245   endif
1246   return cond count system legalmoves false true and checks
1247 endsub
1248 def PL array where #0 0 2 where #0 0 1 where #0 -1 1 where #0 1 1
1249 def pL array where #0 0 -2 where #0 0 -1 where #0 -1 -1 where #0 1 -1
1250 def NL leaps #0 1 2
1251 def BL rays #0 1 1
1252 def RL rays #0 1 0
1253 def VL rays #0 1 1
1254 def CL rays #0 1 0
1255 def QL merge rays #0 1 0 rays #0 1 1
1256 def KL merge leaps #0 1 0 leaps #0 1 1
1257 def AL merge leaps #0 1 2 rays #0 1 1
1258 def ML merge rays #0 1 0 leaps #0 1 2
1259 def nL leaps #0 1 2
1260 def bL rays #0 1 1
1261 def rL rays #0 1 0
1262 def vL rays #0 1 1
1263 def cL rays #0 1 0
1264 def qL merge rays #0 1 0 rays #0 1 1
1265 def kL merge leaps #0 1 0 leaps #0 1 1
1266 def aL merge leaps #0 1 2 rays #0 1 1
1267 def mL merge rays #0 1 0 leaps #0 1 2
1268 sub castlepos from to
1269   local c RPOS RDEST xdir safe
1270   verify flag #from
1271   verify empty #to
1272   if isupper space #king
1273     def friend isupper #0
1274     def friends onlyupper
1275     set attacked ATTACKEDBYB
1276   else
1277     def friend islower #0
1278     def friends onlylower
1279     set attacked ATTACKEDBYW
1280   endif
1281   set xdir sign minus file #to file #from
1282   verify checkaride #from #to #xdir 0
1283   verify not fn var attacked #from
1284   set c #to
1285   do
1286     set c where #c #xdir 0
1287     if flag #c
1288       break
1289     endif
1290     verify onboard #c
1291     verify empty #c
1292   loop
1293   verify flag #c
1294   set RPOS #c
1295   store
1296   for c path #from #to
1297     move #from #c
1298     set safe not fn var attacked #c
1299     restore
1300     verify #safe
1301   next
1302   move #from #to
1303   set RDEST where #to neg #xdir 0
1304   move #RPOS #RDEST
1305   return true
1306 endsub
1307 sub stalemated king
1308   local legalmove temp from piece to attacked ra
1309   if isupper space #king
1310     def friend isupper #0
1311     def friends onlyupper
1312     set attacked ATTACKEDBYB
1313     set cspaces var wcastle
1314   else
1315     def friend islower #0
1316     def friends onlylower
1317     set attacked ATTACKEDBYW
1318     set cspaces var bcastle
1319   endif
1320   store
1321   set kingmoves fn KL #king
1322   for to #kingmoves
1323     if not fn friend space #to and onboard #to
1324       move #king #to
1325       set incheck fn var attacked #to
1326       restore
1327       if not #incheck
1328         setlegal #king #to
1329       endif
1330     endif
1331   next
1332   for to var cspaces
1333     if sub castlepos #king #to
1334       set incheck fn var attacked #to
1335       restore
1336       if not #incheck
1337         setlegal #king #to
1338       endif
1339     endif
1340   next
1341   restore
1342   for (from piece) fn friends
1343     if == #from #king
1344       continue
1345     endif
1346     for to fn join #piece L #from
1347       if fn #piece #from #to and not fn friend space #to and onboard #to
1348         move #from #to
1349         set incheck fn var attacked #king
1350         if not #incheck
1351           setlegal #from #to
1352         endif
1353       endif
1354       restore
1355     next
1356   next
1357   return cond count system legalmoves false true
1358 endsub
1359 def WPAWN match P what #0 1 -1 what #0 -1 -1
1360 def BPAWN match p what #0 1 1 what #0 -1 1
1361 def KNIGHT check what #0 1 2 check what #0 -1 2 check what #0 1 -2 check what #0 -1 -2 check what #0 2 1 check what #0 -2 1 check what #0 2 -1 check what #0 -2 -1 target #1
1362 def WAZIR check what #0 0 -1 check what #0 -1 0 check what #0 0 1 check what #0 1 0 target #1
1363 def FERZ check what #0 -1 -1 check what #0 -1 1 check what #0 1 -1 check what #0 1 1 target #1
1364 def KING fn WAZIR #0 #1 or fn FERZ #0 #1
1365 def ROOK check insight #0 0 -1 check insight #0 -1 0 check insight #0 0 1 check insight #0 1 0 target #1
1366 def BISHOP check insight #0 -1 -1 check insight #0 -1 1 check insight #0 1 -1 check insight #0 1 1 target #1
1367 def ATTACKEDBYB fn KING #0 k or fn BPAWN #0 or fn KNIGHT #0 (n a m) or fn ROOK #0 (r q m) or fn BISHOP #0 (b q a)
1368 def ATTACKEDBYW fn KING #0 K or fn WPAWN #0 or fn KNIGHT #0 (N A M) or fn ROOK #0 (R Q M) or fn BISHOP #0 (B Q A)
1369 sub P from to
1370   local ydir
1371   if == file #from file #to and not capture
1372     set legal checkaleap #from #to 0 1
1373     if var legal
1374       set ep false
1375     else
1376       set legal checkaride #from #to 0 1 and <= distance #from #to #fps and or == rankname #from #wpr < #wpr 0
1377       set ep #to
1378     endif
1379     set epc false
1380   elseif capture or #ep
1381     set legal checkaleap #from #to -1 1 or checkaleap #from #to 1 1
1382     set epc false
1383     if not capture and var legal
1384       set legal > rank #to rank #ep and < rankname #to #bpr and == file #to file #ep
1385       if var legal
1386         capture #ep
1387         set epc #ep
1388       endif
1389     endif
1390     set ep false
1391   endif
1392   if != space #to moved and onboard where #to 0 #pzs
1393     die "You may not promote a Pawn until it reaches the promotion zone."
1394   endif
1395   if not onboard where #to 0 1
1396     if == P space #to
1397       askpromote #wprom
1398     elseif not match space #to var wprom
1399       set np space #to
1400       die "You may not promote your Pawn to a" #np
1401     endif
1402   endif
1403 endsub
1404 sub p from to
1405   if == file #from file #to and not capture
1406     set legal checkaleap #from #to 0 -1
1407     if var legal
1408       set ep false
1409     else
1410       set legal checkaride #from #to 0 -1 and <= distance #from #to #fps and or == rankname #from #bpr > #bpr lastrank
1411       set ep #to
1412     endif
1413     set epc false
1414   elseif capture or #ep
1415     set legal checkaleap #from #to -1 -1 or checkaleap #from #to 1 -1
1416     set epc false
1417     if not capture and var legal
1418       set legal < rank #to rank #ep and > rankname #to #wpr and == file #to file #ep
1419       if var legal
1420         capture #ep
1421         set epc #ep
1422       endif
1423     endif
1424     set ep false
1425   endif
1426   if != space #to moved and onboard where #to 0 neg #pzs
1427     die You may not promote a Pawn until it reaches the promotion zone.
1428   endif
1429   if not onboard where #to 0 -1
1430     if == p space #to
1431       askpromote #bprom
1432     elseif not match space #to var bprom
1433       set np space #to
1434       die You may not promote your Pawn to a #np
1435     endif
1436   endif
1437 endsub
1438 sub K from to
1439   if match #to var wcastle and flag #from
1440     set legal sub castle
1441   else
1442     set legal fn K #from #to
1443   endif
1444   set K #to
1445   unsetflag e1
1446 endsub
1447 sub k from to
1448   if match #to var bcastle and flag #from
1449     set legal sub castle
1450   else
1451     set legal fn k #from #to
1452   endif
1453   set k #to
1454   unsetflag e8
1455 endsub
1456 sub castle
1457   local ATTACKED c RPOS RDEST xdir
1458   if not flag #from
1459     die A King may not castle after it moves.
1460   endif
1461   if capture
1462     die A King may not castle to an occupied space.
1463   endif
1464   set xdir sign minus file #to file #from
1465   if not checkaride #from #to #xdir 0
1466     die A King may not castle across any occupied space.
1467   endif
1468   set c #to
1469   do
1470     set c where #c #xdir 0
1471     if flag #c
1472       break
1473     elseif not onboard #c
1474       die No piece was found to castle with.
1475     elseif not empty #c
1476       die The King cannot castle with the piece at #c
1477     endif
1478   loop
1479   set RPOS #c
1480   set ATTACKED ATTACKEDBYW unless isupper moved ATTACKEDBYB
1481   if fn var ATTACKED #from
1482     die A King may not castle out of check.
1483   endif
1484   for c path #from #to
1485     if fn var ATTACKED #c
1486       die A King may not castle through check.
1487     endif
1488   next
1489   if == count var subargs 0
1490     set RDEST where #to neg #xdir 0
1491   else
1492     set RDEST elem 0 subarg
1493   endif
1494   unsetflag #RPOS
1495   move #RPOS #RDEST
1496   return true
1497 endsub
1498 sub checkedthru king loc
1499   my dir c
1500   set c revealed #king #loc
1501   verify fn space #c #c #king and not samecase space #king space #c and onboard #c and #c
1502   return #c
1503 endsub
1504 def fn checkedfrom fn space #1 #0 and xor isupper space #0 isupper space #1 and not empty #1
1505 sub P1 from to
1506   if == file #from file #to
1507     return not capture
1508   elseif capture
1509     return true
1510   elseif == file #to file #ep and == rank #from rank #ep and #ep
1511     capture #ep
1512     return true
1513   endif
1514   return false
1515 endsub
1516 sub PP from to
1517   if checkatwostep #from #to 0 1 0 1 or checkaleap #from #to 0 1
1518     return empty #to
1519   elseif not checkaleap #from #to 1 1 and not checkaleap #from #to -1 1
1520     return false
1521   elseif not empty #to
1522     return true
1523   elseif == file #to file #ep and == rank #from rank #ep and #ep
1524     capture #ep
1525     return true
1526   endif
1527   return false
1528 endsub
1529 sub pp from to
1530   if checkatwostep #from #to 0 -1 0 -1 or checkaleap #from #to 0 -1
1531     return empty #to
1532   elseif not checkaleap #from #to 1 -1 and not checkaleap #from #to -1 -1
1533     return false
1534   elseif not empty #to
1535     return true
1536   elseif == file #to file #ep and == rank #from rank #ep and #ep
1537     capture #ep
1538     return true
1539   endif
1540   return false
1541 endsub
1542 endlib

functions

Array ( [N] => Array ( [0] => checkleap [1] => #0 [2] => #1 [3] => 1 [4] => 2 ) [B] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 1 ) [R] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 0 ) [Q] => Array ( [0] => fn [1] => B [2] => #0 [3] => #1 [4] => or [5] => fn [6] => R [7] => #0 [8] => #1 ) [K] => Array ( [0] => checkleap [1] => #0 [2] => #1 [3] => 1 [4] => 1 [5] => or [6] => checkleap [7] => #0 [8] => #1 [9] => 1 [10] => 0 ) [M] => Array ( [0] => fn [1] => N [2] => #0 [3] => #1 [4] => or [5] => fn [6] => R [7] => #0 [8] => #1 ) [A] => Array ( [0] => fn [1] => N [2] => #0 [3] => #1 [4] => or [5] => fn [6] => B [7] => #0 [8] => #1 ) [n] => Array ( [0] => checkleap [1] => #0 [2] => #1 [3] => 1 [4] => 2 ) [b] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 1 ) [r] => Array ( [0] => checkride [1] => #0 [2] => #1 [3] => 1 [4] => 0 ) [q] => Array ( [0] => fn [1] => b [2] => #0 [3] => #1 [4] => or [5] => fn [6] => r [7] => #0 [8] => #1 ) [k] => Array ( [0] => checkleap [1] => #0 [2] => #1 [3] => 1 [4] => 1 [5] => or [6] => checkleap [7] => #0 [8] => #1 [9] => 1 [10] => 0 ) [m] => Array ( [0] => fn [1] => n [2] => #0 [3] => #1 [4] => or [5] => fn [6] => r [7] => #0 [8] => #1 ) [a] => Array ( [0] => fn [1] => n [2] => #0 [3] => #1 [4] => or [5] => fn [6] => b [7] => #0 [8] => #1 ) [P] => Array ( [0] => remove [1] => var [2] => ep [3] => and [4] => checkleap [5] => #0 [6] => #1 [7] => 1 [8] => 1 [9] => and [10] => == [11] => var [12] => ep [13] => join [14] => filename [15] => #1 [16] => rankname [17] => #0 [18] => or [19] => and [20] => checkride [21] => #0 [22] => #1 [23] => 0 [24] => 1 [25] => == [26] => rankname [27] => #0 [28] => var [29] => wpr [30] => or [31] => checkleap [32] => #0 [33] => #1 [34] => 0 [35] => 1 [36] => and [37] => empty [38] => #1 [39] => or [40] => and [41] => islower [42] => space [43] => #1 [44] => checkleap [45] => #0 [46] => #1 [47] => 1 [48] => 1 [49] => and [50] => <= [51] => distance [52] => #0 [53] => #1 [54] => var [55] => fps [56] => and [57] => > [58] => rank [59] => #1 [60] => rank [61] => #0 ) [p] => Array ( [0] => remove [1] => var [2] => ep [3] => and [4] => checkleap [5] => #0 [6] => #1 [7] => 1 [8] => 1 [9] => and [10] => == [11] => var [12] => ep [13] => join [14] => filename [15] => #1 [16] => rankname [17] => #0 [18] => or [19] => and [20] => checkride [21] => #0 [22] => #1 [23] => 0 [24] => 1 [25] => == [26] => rankname [27] => #0 [28] => var [29] => bpr [30] => or [31] => checkleap [32] => #0 [33] => #1 [34] => 0 [35] => 1 [36] => and [37] => empty [38] => #1 [39] => or [40] => and [41] => isupper [42] => space [43] => #1 [44] => checkleap [45] => #0 [46] => #1 [47] => 1 [48] => 1 [49] => and [50] => <= [51] => distance [52] => #0 [53] => #1 [54] => var [55] => fps [56] => and [57] => < [58] => rank [59] => #1 [60] => rank [61] => #0 ) [PL] => Array ( [0] => array [1] => where [2] => #0 [3] => 0 [4] => 2 [5] => where [6] => #0 [7] => 0 [8] => 1 [9] => where [10] => #0 [11] => -1 [12] => 1 [13] => where [14] => #0 [15] => 1 [16] => 1 ) [pL] => Array ( [0] => array [1] => where [2] => #0 [3] => 0 [4] => -2 [5] => where [6] => #0 [7] => 0 [8] => -1 [9] => where [10] => #0 [11] => -1 [12] => -1 [13] => where [14] => #0 [15] => 1 [16] => -1 ) [NL] => Array ( [0] => leaps [1] => #0 [2] => 1 [3] => 2 ) [BL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 1 ) [RL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 0 ) [VL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 1 ) [CL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 0 ) [QL] => Array ( [0] => merge [1] => rays [2] => #0 [3] => 1 [4] => 0 [5] => rays [6] => #0 [7] => 1 [8] => 1 ) [KL] => Array ( [0] => merge [1] => leaps [2] => #0 [3] => 1 [4] => 0 [5] => leaps [6] => #0 [7] => 1 [8] => 1 ) [AL] => Array ( [0] => merge [1] => leaps [2] => #0 [3] => 1 [4] => 2 [5] => rays [6] => #0 [7] => 1 [8] => 1 ) [ML] => Array ( [0] => merge [1] => rays [2] => #0 [3] => 1 [4] => 0 [5] => leaps [6] => #0 [7] => 1 [8] => 2 ) [nL] => Array ( [0] => leaps [1] => #0 [2] => 1 [3] => 2 ) [bL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 1 ) [rL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 0 ) [vL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 1 ) [cL] => Array ( [0] => rays [1] => #0 [2] => 1 [3] => 0 ) [qL] => Array ( [0] => merge [1] => rays [2] => #0 [3] => 1 [4] => 0 [5] => rays [6] => #0 [7] => 1 [8] => 1 ) [kL] => Array ( [0] => merge [1] => leaps [2] => #0 [3] => 1 [4] => 0 [5] => leaps [6] => #0 [7] => 1 [8] => 1 ) [aL] => Array ( [0] => merge [1] => leaps [2] => #0 [3] => 1 [4] => 2 [5] => rays [6] => #0 [7] => 1 [8] => 1 ) [mL] => Array ( [0] => merge [1] => rays [2] => #0 [3] => 1 [4] => 0 [5] => leaps [6] => #0 [7] => 1 [8] => 2 ) [WPAWN] => Array ( [0] => match [1] => P [2] => what [3] => #0 [4] => 1 [5] => -1 [6] => what [7] => #0 [8] => -1 [9] => -1 ) [BPAWN] => Array ( [0] => match [1] => p [2] => what [3] => #0 [4] => 1 [5] => 1 [6] => what [7] => #0 [8] => -1 [9] => 1 ) [KNIGHT] => Array ( [0] => check [1] => what [2] => #0 [3] => 1 [4] => 2 [5] => check [6] => what [7] => #0 [8] => -1 [9] => 2 [10] => check [11] => what [12] => #0 [13] => 1 [14] => -2 [15] => check [16] => what [17] => #0 [18] => -1 [19] => -2 [20] => check [21] => what [22] => #0 [23] => 2 [24] => 1 [25] => check [26] => what [27] => #0 [28] => -2 [29] => 1 [30] => check [31] => what [32] => #0 [33] => 2 [34] => -1 [35] => check [36] => what [37] => #0 [38] => -2 [39] => -1 [40] => target [41] => #1 ) [WAZIR] => Array ( [0] => check [1] => what [2] => #0 [3] => 0 [4] => -1 [5] => check [6] => what [7] => #0 [8] => -1 [9] => 0 [10] => check [11] => what [12] => #0 [13] => 0 [14] => 1 [15] => check [16] => what [17] => #0 [18] => 1 [19] => 0 [20] => target [21] => #1 ) [FERZ] => Array ( [0] => check [1] => what [2] => #0 [3] => -1 [4] => -1 [5] => check [6] => what [7] => #0 [8] => -1 [9] => 1 [10] => check [11] => what [12] => #0 [13] => 1 [14] => -1 [15] => check [16] => what [17] => #0 [18] => 1 [19] => 1 [20] => target [21] => #1 ) [KING] => Array ( [0] => fn [1] => WAZIR [2] => #0 [3] => #1 [4] => or [5] => fn [6] => FERZ [7] => #0 [8] => #1 ) [ROOK] => Array ( [0] => check [1] => insight [2] => #0 [3] => 0 [4] => -1 [5] => check [6] => insight [7] => #0 [8] => -1 [9] => 0 [10] => check [11] => insight [12] => #0 [13] => 0 [14] => 1 [15] => check [16] => insight [17] => #0 [18] => 1 [19] => 0 [20] => target [21] => #1 ) [BISHOP] => Array ( [0] => check [1] => insight [2] => #0 [3] => -1 [4] => -1 [5] => check [6] => insight [7] => #0 [8] => -1 [9] => 1 [10] => check [11] => insight [12] => #0 [13] => 1 [14] => -1 [15] => check [16] => insight [17] => #0 [18] => 1 [19] => 1 [20] => target [21] => #1 ) [ATTACKEDBYB] => Array ( [0] => fn [1] => KING [2] => #0 [3] => k [4] => or [5] => fn [6] => BPAWN [7] => #0 [8] => or [9] => fn [10] => KNIGHT [11] => #0 [12] => Array ( [0] => n [1] => a [2] => m ) [13] => or [14] => fn [15] => ROOK [16] => #0 [17] => Array ( [0] => r [1] => q [2] => m ) [18] => or [19] => fn [20] => BISHOP [21] => #0 [22] => Array ( [0] => b [1] => q [2] => a ) ) [ATTACKEDBYW] => Array ( [0] => fn [1] => KING [2] => #0 [3] => K [4] => or [5] => fn [6] => WPAWN [7] => #0 [8] => or [9] => fn [10] => KNIGHT [11] => #0 [12] => Array ( [0] => N [1] => A [2] => M ) [13] => or [14] => fn [15] => ROOK [16] => #0 [17] => Array ( [0] => R [1] => Q [2] => M ) [18] => or [19] => fn [20] => BISHOP [21] => #0 [22] => Array ( [0] => B [1] => Q [2] => A ) ) [fn] => Array ( [0] => checkedfrom [1] => fn [2] => space [3] => #1 [4] => #0 [5] => and [6] => xor [7] => isupper [8] => space [9] => #0 [10] => isupper [11] => space [12] => #1 [13] => and [14] => not [15] => empty [16] => #1 ) )

uservar

Array ( [0] => Array ( [main] => Array ( [wpr] => 2 [bpr] => 7 [fps] => 2 [pzs] => 1 [wcastle] => Array ( [0] => g1 [1] => c1 ) [bcastle] => Array ( [0] => g8 [1] => c8 ) [wprom] => Array ( [0] => Q [1] => R [2] => B [3] => N ) [bprom] => Array ( [0] => q [1] => r [2] => b [3] => n ) [bw] => 4 [rank1] => Array ( [0] => a1 [1] => b1 [2] => c1 [3] => d1 [4] => e1 [5] => f1 [6] => g1 [7] => h1 ) [i] => 73 [normal] => 1 [mv] => c2-c1; q-c1 [pm] => Array ( [0] => c2-c1; [1] => q-c1 ) [m] => q-c1 [od] => Array ( [0] => q [1] => c1 ) [o] => q [d] => c1 [pp] => [b2] => 10 1 1 100 10000 1000 100000 1000 [bp] => 0 [changed] => [rooks] => 2 [sp] => h1 [os] => 56 [leftking] => [rghtking] => [kp] => g1 [leftside] => Array ( [0] => a1 [1] => b1 [2] => c1 [3] => d1 [4] => e1 [5] => f1 ) [rightside] => Array ( [0] => h1 ) [betweenrooks] => Array ( [0] => g1 ) [ra2] => Array ( [0] => g1 ) [p] => c2-c1; ) ) [2] => Array ( [calc_original_position] => Array ( [subargs] => Array ( ) ) [main] => Array ( [a1] => 2 [b1] => 1 [c1] => 1 [d1] => 4 [e1] => 16 [f1] => 8 [g1] => 32 [h1] => 8 [n] => 1 [bb] => 2 [w] => 0 [b] => 6 [r] => 8 [q] => 16 [k] => 32 [K] => 1 [Q] => 1 [R] => 2 [B] => 2 [N] => 2 [ra] => Array ( [0] => a1 [1] => d1 [2] => e1 [3] => f1 [4] => g1 [5] => h1 ) [firstr] => f1 [lastr] => h1 [last] => 2 ) ) )

mline

Array ( [0] => MoveLine Object ( [movenum] => 1 [move] => f2-f3 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 1 ) [1] => MoveLine Object ( [movenum] => 2 [move] => c7-c6 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 1 ) [2] => MoveLine Object ( [movenum] => 3 [move] => b2-b3 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 2 ) [3] => MoveLine Object ( [movenum] => 4 [move] => d8-b6 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 2 ) [4] => MoveLine Object ( [movenum] => 5 [move] => e2-e3 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 3 ) [5] => MoveLine Object ( [movenum] => 6 [move] => d7-d6 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 3 ) [6] => MoveLine Object ( [movenum] => 7 [move] => e1-g3 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 4 ) [7] => MoveLine Object ( [movenum] => 8 [move] => e7-e5 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 4 ) [8] => MoveLine Object ( [movenum] => 9 [move] => d2-d4 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 5 ) [9] => MoveLine Object ( [movenum] => 10 [move] => e5-d4 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 5 ) [10] => MoveLine Object ( [movenum] => 11 [move] => e3-d4 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 6 ) [11] => MoveLine Object ( [movenum] => 12 [move] => e8-e3 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 6 ) [12] => MoveLine Object ( [movenum] => 13 [move] => f1-f2 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 7 ) [13] => MoveLine Object ( [movenum] => 14 [move] => b6-d4 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 7 ) [14] => MoveLine Object ( [movenum] => 15 [move] => a1-d4 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 8 ) [15] => MoveLine Object ( [movenum] => 16 [move] => e3-d4 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 8 ) [16] => MoveLine Object ( [movenum] => 17 [move] => c1-e2 [level] => 0 [comment] => [length] => 8 [newturn] => 1 [turn] => 9 ) [17] => MoveLine Object ( [movenum] => 18 [move] => d4-d1 [level] => 0 [comment] => [length] => 10 [newturn] => [turn] => 9 ) [18] => MoveLine Object ( [movenum] => 19 [move] => f2-f1 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 10 ) [19] => MoveLine Object ( [movenum] => 20 [move] => d1-e2 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 10 ) [20] => MoveLine Object ( [movenum] => 21 [move] => b1-c3 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 11 ) [21] => MoveLine Object ( [movenum] => 22 [move] => e2-c2 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 11 ) [22] => MoveLine Object ( [movenum] => 23 [move] => c3-e4 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 12 ) [23] => MoveLine Object ( [movenum] => 24 [move] => c2-b2 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 12 ) [24] => MoveLine Object ( [movenum] => 25 [move] => e4-d6 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 13 ) [25] => MoveLine Object ( [movenum] => 26 [move] => b2-d4 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 13 ) [26] => MoveLine Object ( [movenum] => 27 [move] => f1-f2 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 14 ) [27] => MoveLine Object ( [movenum] => 28 [move] => d4-d6 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 14 ) [28] => MoveLine Object ( [movenum] => 29 [move] => g3-d6 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 15 ) [29] => MoveLine Object ( [movenum] => 30 [move] => c8-d6 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 15 ) [30] => MoveLine Object ( [movenum] => 31 [move] => h2-h3 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 16 ) [31] => MoveLine Object ( [movenum] => 32 [move] => g7-g6 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 16 ) [32] => MoveLine Object ( [movenum] => 33 [move] => g1-h2 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 17 ) [33] => MoveLine Object ( [movenum] => 34 [move] => f8-e8 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 17 ) [34] => MoveLine Object ( [movenum] => 35 [move] => h1-d1 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 18 ) [35] => MoveLine Object ( [movenum] => 36 [move] => d6-f5 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 18 ) [36] => MoveLine Object ( [movenum] => 37 [move] => g2-g4 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 19 ) [37] => MoveLine Object ( [movenum] => 38 [move] => f5-h4 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 19 ) [38] => MoveLine Object ( [movenum] => 39 [move] => h2-g3 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 20 ) [39] => MoveLine Object ( [movenum] => 40 [move] => g6-g5 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 20 ) [40] => MoveLine Object ( [movenum] => 41 [move] => d1-d3 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 21 ) [41] => MoveLine Object ( [movenum] => 42 [move] => g8-g7 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 21 ) [42] => MoveLine Object ( [movenum] => 43 [move] => f3-f4 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 22 ) [43] => MoveLine Object ( [movenum] => 44 [move] => h7-h6 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 22 ) [44] => MoveLine Object ( [movenum] => 45 [move] => f4-g5 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 23 ) [45] => MoveLine Object ( [movenum] => 46 [move] => h6-g5 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 23 ) [46] => MoveLine Object ( [movenum] => 47 [move] => d3-d4 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 24 ) [47] => MoveLine Object ( [movenum] => 48 [move] => e8-e7 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 24 ) [48] => MoveLine Object ( [movenum] => 49 [move] => a2-a4 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 25 ) [49] => MoveLine Object ( [movenum] => 50 [move] => h8-e8 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 25 ) [50] => MoveLine Object ( [movenum] => 51 [move] => d4-d2 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 26 ) [51] => MoveLine Object ( [movenum] => 52 [move] => e7-e3 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 26 ) [52] => MoveLine Object ( [movenum] => 53 [move] => g3-h2 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 27 ) [53] => MoveLine Object ( [movenum] => 54 [move] => h4-f3 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 27 ) [54] => MoveLine Object ( [movenum] => 55 [move] => f2-f3 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 28 ) [55] => MoveLine Object ( [movenum] => 56 [move] => e3-f3 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 28 ) [56] => MoveLine Object ( [movenum] => 57 [move] => b3-b4 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 29 ) [57] => MoveLine Object ( [movenum] => 58 [move] => f3-e3 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 29 ) [58] => MoveLine Object ( [movenum] => 59 [move] => b4-b5 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 30 ) [59] => MoveLine Object ( [movenum] => 60 [move] => e3-e2 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 30 ) [60] => MoveLine Object ( [movenum] => 61 [move] => d2-e2 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 31 ) [61] => MoveLine Object ( [movenum] => 62 [move] => e8-e2 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 31 ) [62] => MoveLine Object ( [movenum] => 63 [move] => h2-g1 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 32 ) [63] => MoveLine Object ( [movenum] => 64 [move] => c6-c5 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 32 ) [64] => MoveLine Object ( [movenum] => 65 [move] => a4-a5 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 33 ) [65] => MoveLine Object ( [movenum] => 66 [move] => c5-c4 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 33 ) [66] => MoveLine Object ( [movenum] => 67 [move] => b5-b6 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 34 ) [67] => MoveLine Object ( [movenum] => 68 [move] => c4-c3 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 34 ) [68] => MoveLine Object ( [movenum] => 69 [move] => b6-a7 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 35 ) [69] => MoveLine Object ( [movenum] => 70 [move] => c3-c2 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 35 ) [70] => MoveLine Object ( [movenum] => 71 [move] => g1-f1 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 36 ) [71] => MoveLine Object ( [movenum] => 72 [move] => e2-d2 [level] => 0 [comment] => [length] => 11 [newturn] => [turn] => 36 ) [72] => MoveLine Object ( [movenum] => 73 [move] => f1-g1 [level] => 0 [comment] => [length] => 9 [newturn] => 1 [turn] => 37 ) [73] => MoveLine Object ( [movenum] => 74 [move] => c2-c1; q-c1 [level] => 0 [comment] => [length] => 17 [newturn] => [turn] => 37 ) )

allmoves

Array ( [0] => moveindex 73;MOVE: c2-c1; MOVE: q-c1;postauto2 [1] => moveindex 72;MOVE: f1-g1;postauto1 [2] => moveindex 71;MOVE: e2-d2;postauto2 [3] => moveindex 70;MOVE: g1-f1;postauto1 [4] => moveindex 69;MOVE: c3-c2;postauto2 [5] => moveindex 68;MOVE: b6-a7;postauto1 [6] => moveindex 67;MOVE: c4-c3;postauto2 [7] => moveindex 66;MOVE: b5-b6;postauto1 [8] => moveindex 65;MOVE: c5-c4;postauto2 [9] => moveindex 64;MOVE: a4-a5;postauto1 [10] => moveindex 63;MOVE: c6-c5;postauto2 [11] => moveindex 62;MOVE: h2-g1;postauto1 [12] => moveindex 61;MOVE: e8-e2;postauto2 [13] => moveindex 60;MOVE: d2-e2;postauto1 [14] => moveindex 59;MOVE: e3-e2;postauto2 [15] => moveindex 58;MOVE: b4-b5;postauto1 [16] => moveindex 57;MOVE: f3-e3;postauto2 [17] => moveindex 56;MOVE: b3-b4;postauto1 [18] => moveindex 55;MOVE: e3-f3;postauto2 [19] => moveindex 54;MOVE: f2-f3;postauto1 [20] => moveindex 53;MOVE: h4-f3;postauto2 [21] => moveindex 52;MOVE: g3-h2;postauto1 [22] => moveindex 51;MOVE: e7-e3;postauto2 [23] => moveindex 50;MOVE: d4-d2;postauto1 [24] => moveindex 49;MOVE: h8-e8;postauto2 [25] => moveindex 48;MOVE: a2-a4;postauto1 [26] => moveindex 47;MOVE: e8-e7;postauto2 [27] => moveindex 46;MOVE: d3-d4;postauto1 [28] => moveindex 45;MOVE: h6-g5;postauto2 [29] => moveindex 44;MOVE: f4-g5;postauto1 [30] => moveindex 43;MOVE: h7-h6;postauto2 [31] => moveindex 42;MOVE: f3-f4;postauto1 [32] => moveindex 41;MOVE: g8-g7;postauto2 [33] => moveindex 40;MOVE: d1-d3;postauto1 [34] => moveindex 39;MOVE: g6-g5;postauto2 [35] => moveindex 38;MOVE: h2-g3;postauto1 [36] => moveindex 37;MOVE: f5-h4;postauto2 [37] => moveindex 36;MOVE: g2-g4;postauto1 [38] => moveindex 35;MOVE: d6-f5;postauto2 [39] => moveindex 34;MOVE: h1-d1;postauto1 [40] => moveindex 33;MOVE: f8-e8;postauto2 [41] => moveindex 32;MOVE: g1-h2;postauto1 [42] => moveindex 31;MOVE: g7-g6;postauto2 [43] => moveindex 30;MOVE: h2-h3;postauto1 [44] => moveindex 29;MOVE: c8-d6;postauto2 [45] => moveindex 28;MOVE: g3-d6;postauto1 [46] => moveindex 27;MOVE: d4-d6;postauto2 [47] => moveindex 26;MOVE: f1-f2;postauto1 [48] => moveindex 25;MOVE: b2-d4;postauto2 [49] => moveindex 24;MOVE: e4-d6;postauto1 [50] => moveindex 23;MOVE: c2-b2;postauto2 [51] => moveindex 22;MOVE: c3-e4;postauto1 [52] => moveindex 21;MOVE: e2-c2;postauto2 [53] => moveindex 20;MOVE: b1-c3;postauto1 [54] => moveindex 19;MOVE: d1-e2;postauto2 [55] => moveindex 18;MOVE: f2-f1;postauto1 [56] => moveindex 17;MOVE: d4-d1;postauto2 [57] => moveindex 16;MOVE: c1-e2;postauto1 [58] => moveindex 15;MOVE: e3-d4;postauto2 [59] => moveindex 14;MOVE: a1-d4;postauto1 [60] => moveindex 13;MOVE: b6-d4;postauto2 [61] => moveindex 12;MOVE: f1-f2;postauto1 [62] => moveindex 11;MOVE: e8-e3;postauto2 [63] => moveindex 10;MOVE: e3-d4;postauto1 [64] => moveindex 9;MOVE: e5-d4;postauto2 [65] => moveindex 8;MOVE: d2-d4;postauto1 [66] => moveindex 7;MOVE: e7-e5;postauto2 [67] => moveindex 6;MOVE: e1-g3;postauto1 [68] => moveindex 5;MOVE: d7-d6;postauto2 [69] => moveindex 4;MOVE: e2-e3;postauto1 [70] => moveindex 3;MOVE: d8-b6;postauto2 [71] => moveindex 2;MOVE: b2-b3;postauto1 [72] => moveindex 1;MOVE: c7-c6;postauto2 [73] => moveindex 0;MOVE: f2-f3;postauto1 )

movelist

1. f2-f3 1... c7-c6 2. b2-b3 2... d8-b6 3. e2-e3 3... d7-d6 4. e1-g3 4... e7-e5 5. d2-d4 5... e5-d4 6. e3-d4 6... e8-e3 7. f1-f2 7... b6-d4 8. a1-d4 8... e3-d4 9. c1-e2 9... d4-d1 10. f2-f1 10... d1-e2 11. b1-c3 11... e2-c2 12. c3-e4 12... c2-b2 13. e4-d6 13... b2-d4 14. f1-f2 14... d4-d6 15. g3-d6 15... c8-d6 16. h2-h3 16... g7-g6 17. g1-h2 17... f8-e8 18. h1-d1 18... d6-f5 19. g2-g4 19... f5-h4 20. h2-g3 20... g6-g5 21. d1-d3 21... g8-g7 22. f3-f4 22... h7-h6 23. f4-g5 23... h6-g5 24. d3-d4 24... e8-e7 25. a2-a4 25... h8-e8 26. d4-d2 26... e7-e3 27. g3-h2 27... h4-f3 28. f2-f3 28... e3-f3 29. b3-b4 29... f3-e3 30. b4-b5 30... e3-e2 31. d2-e2 31... e8-e2 32. h2-g1 32... c6-c5 33. a4-a5 33... c5-c4 34. b5-b6 34... c4-c3 35. b6-a7 35... c3-c2 36. g1-f1 36... e2-d2 37. f1-g1 37... c2-c1; q-c1

constants

Array ( )