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 g2-g3, p is #p, o is g2

space g2 is P

0 P g2-g3 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

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

space b8 is b1

1 b1 b8-c6 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

5 one bits in var b1

11011 1 111011 111101 111011 111101 111011 11101

q end b8-c6 27 1 59 61 59 61 59 29

bb end b8-c6 27 1 59 61 59 61 59 29

bw end b8-c6 27 1 59 61 59 61 59 29

firstr is a1, and lastr is h1

r b8-c6 27 1 59 61 59 61 59 29

first 27 1 59 61 59 61 59 29

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

space f1 is f1

2 f1 f1-g2 27 1 59 61 59 61 59 29

11011 1 111011 111101 111011 111101 111011 11101

5 one bits in var f1

11011 1 111011 111101 111011 110100 111011 11101

q end f1-g2 27 1 59 61 59 52 59 29

bb end f1-g2 27 1 59 61 59 52 59 29

bw end f1-g2 27 1 59 61 59 52 59 29

firstr is a1, and lastr is h1

r f1-g2 27 1 59 61 59 52 59 29

first 27 1 59 61 59 52 59 29

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

space g7 is p

3 p g7-g6 27 1 59 61 59 52 59 29

11011 1 111011 111101 111011 110100 111011 11101

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

space c2 is P

4 P c2-c3 27 1 59 61 59 52 59 29

11011 1 111011 111101 111011 110100 111011 11101

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

space e7 is p

5 p e7-e6 27 1 59 61 59 52 59 29

11011 1 111011 111101 111011 110100 111011 11101

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

space b2 is P

6 P b2-b4 27 1 59 61 59 52 59 29

11011 1 111011 111101 111011 110100 111011 11101

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

space a7 is p

7 p a7-a6 27 1 59 61 59 52 59 29

11011 1 111011 111101 111011 110100 111011 11101

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

space d2 is P

8 P d2-d4 27 1 59 61 59 52 59 29

11011 1 111011 111101 111011 110100 111011 11101

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

space d7 is p

9 p d7-d6 27 1 59 61 59 52 59 29

11011 1 111011 111101 111011 110100 111011 11101

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

space d1 is d1

10 d1 d1-e3 27 1 59 61 59 52 59 29

11011 1 111011 111101 111011 110100 111011 11101

5 one bits in var d1

11011 1 111011 1 111011 110100 111011 11101

q end d1-e3 27 1 59 1 59 52 59 29

bb end d1-e3 27 1 59 1 59 52 59 29

bw end d1-e3 27 1 59 1 59 52 59 29

firstr is a1, and lastr is h1

r d1-e3 27 1 59 1 59 52 59 29

first 27 1 59 1 59 52 59 29

11010 1 111010 1 111010 110100 111010 11100

q end d1-e3 26 1 58 1 58 52 58 28

bb end d1-e3 26 1 58 1 58 52 58 28

bw end d1-e3 26 1 58 1 58 52 58 28

firstr is a1, and lastr is h1

r d1-e3 26 1 58 1 58 52 58 28

first 26 1 58 1 58 52 58 28

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

space f8 is f1

11 f1 f8-g7 26 1 58 1 58 52 58 28

11010 1 111010 1 111010 110100 111010 11100

3 one bits in var f1

11010 1 111010 1 111010 110100 111010 11100

q end f8-g7 26 1 58 1 58 52 58 28

bb end f8-g7 26 1 58 1 58 52 58 28

bw end f8-g7 26 1 58 1 58 52 58 28

firstr is a1, and lastr is h1

r f8-g7 26 1 58 1 58 52 58 28

first 26 1 58 1 58 52 58 28

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

space g2 is f1

12 f1 g2-c6 26 1 58 1 58 52 58 28

11010 1 111010 1 111010 110100 111010 11100

3 one bits in var f1

11010 1 111010 1 111010 10100 111010 11100

q end g2-c6 26 1 58 1 58 20 58 28

bb end g2-c6 26 1 58 1 58 20 58 28

bw end g2-c6 26 1 58 1 58 20 58 28

firstr is a1, and lastr is h1

r g2-c6 26 1 58 1 58 20 58 28

first 26 1 58 1 58 20 58 28

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

space d8 is d1

13 d1 d8-c6 26 1 58 1 58 20 58 28

11010 1 111010 1 111010 10100 111010 11100

1 one bits in var d1

11010 1 111010 1 111010 10100 111010 11100

q end d8-c6 26 1 58 1 58 20 58 28

bb end d8-c6 26 1 58 1 58 20 58 28

bw end d8-c6 26 1 58 1 58 20 58 28

firstr is a1, and lastr is h1

r d8-c6 26 1 58 1 58 20 58 28

first 26 1 58 1 58 20 58 28

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

space d4 is P

14 P d4-d5 26 1 58 1 58 20 58 28

11010 1 111010 1 111010 10100 111010 11100

mv is e6-d5, p is #p, o is e6

space e6 is p

15 p e6-d5 26 1 58 1 58 20 58 28

11010 1 111010 1 111010 10100 111010 11100

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

space h1 is h1

16 h1 h1-d5 26 1 58 1 58 20 58 28

11010 1 111010 1 111010 10100 111010 11100

3 one bits in var h1

11010 1 111010 1 111010 10100 111010 10100

q end h1-d5 26 1 58 1 58 20 58 20

bb end h1-d5 26 1 58 1 58 20 58 20

bw end h1-d5 26 1 58 1 58 20 58 20

firstr is a1, and lastr is g1

r h1-d5 26 1 58 1 58 20 26 20

first 26 1 58 1 58 20 26 20

11010 1 111010 1 111010 10100 11010 10100

q end h1-d5 26 1 58 1 58 20 26 20

bb end h1-d5 26 1 58 1 58 20 26 20

bw end h1-d5 26 1 58 1 58 20 26 20

firstr is a1, and lastr is g1

r h1-d5 26 1 58 1 58 20 26 20

first 26 1 58 1 58 20 26 20

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

space g7 is f1

17 f1 g7-c3 26 1 58 1 58 20 26 20

11010 1 111010 1 111010 10100 11010 10100

2 one bits in var f1

11010 1 111010 1 111010 10100 11010 10100

q end g7-c3 26 1 58 1 58 20 26 20

bb end g7-c3 26 1 58 1 58 20 26 20

bw end g7-c3 26 1 58 1 58 20 26 20

firstr is a1, and lastr is g1

r g7-c3 26 1 58 1 58 20 26 20

first 26 1 58 1 58 20 26 20

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

space b1 is b1

18 b1 b1-c3 26 1 58 1 58 20 26 20

11010 1 111010 1 111010 10100 11010 10100

1 one bits in var b1

11010 1 111010 1 111010 10100 11010 10100

q end b1-c3 26 1 58 1 58 20 26 20

bb end b1-c3 26 1 58 1 58 20 26 20

bw end b1-c3 26 1 58 1 58 20 26 20

firstr is a1, and lastr is g1

r b1-c3 26 1 58 1 58 20 26 20

first 26 1 58 1 58 20 26 20

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

space h8 is h1

19 h1 h8-c3 26 1 58 1 58 20 26 20

11010 1 111010 1 111010 10100 11010 10100

2 one bits in var h1

11010 1 111010 1 111010 10100 11010 10100

q end h8-c3 26 1 58 1 58 20 26 20

bb end h8-c3 26 1 58 1 58 20 26 20

bw end h8-c3 26 1 58 1 58 20 26 20

firstr is a1, and lastr is g1

r h8-c3 26 1 58 1 58 20 26 20

first 26 1 58 1 58 20 26 20

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

space e3 is d1

20 d1 e3-c2 26 1 58 1 58 20 26 20

11010 1 111010 1 111010 10100 11010 10100

1 one bits in var d1

11010 1 111010 1 111010 10100 11010 10100

q end e3-c2 26 1 58 1 58 20 26 20

bb end e3-c2 26 1 58 1 58 20 26 20

bw end e3-c2 26 1 58 1 58 20 26 20

firstr is a1, and lastr is g1

r e3-c2 26 1 58 1 58 20 26 20

first 26 1 58 1 58 20 26 20

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

space c6 is d1

21 d1 c6-b4 26 1 58 1 58 20 26 20

11010 1 111010 1 111010 10100 11010 10100

1 one bits in var d1

11010 1 111010 1 111010 10100 11010 10100

q end c6-b4 26 1 58 1 58 20 26 20

bb end c6-b4 26 1 58 1 58 20 26 20

bw end c6-b4 26 1 58 1 58 20 26 20

firstr is a1, and lastr is g1

r c6-b4 26 1 58 1 58 20 26 20

first 26 1 58 1 58 20 26 20

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

space d5 is h1

22 h1 d5-d1 26 1 58 1 58 20 26 20

11010 1 111010 1 111010 10100 11010 10100

2 one bits in var h1

rook ride

h1 currently set to 20

h1 now set to 16

11010 1 111010 1 111010 10100 11010 10000

queen before d5-d1 26 1 58 1 58 20 26 16

queen after d5-d1 10 1 42 1 42 4 10 16

q end d5-d1 10 1 42 1 42 4 10 16

bb end d5-d1 10 1 42 1 42 4 10 16

bw end d5-d1 10 1 42 1 42 4 10 16

firstr is a1, and lastr is g1

r d5-d1 10 1 42 1 42 4 10 16

first 10 1 42 1 42 4 10 16

1010 1 101010 1 101010 100 1010 10000

q end d5-d1 10 1 42 1 42 4 10 16

bb end d5-d1 10 1 42 1 42 4 10 16

bw end d5-d1 10 1 42 1 42 4 10 16

firstr is a1, and lastr is g1

r d5-d1 10 1 42 1 42 4 10 16

first 10 1 42 1 42 4 10 16

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

space c3 is h1

23 h1 c3-c2 10 1 42 1 42 4 10 16

1010 1 101010 1 101010 100 1010 10000

1 one bits in var h1

1010 1 101010 1 101010 100 1010 10000

q end c3-c2 10 1 42 1 42 4 10 16

bb end c3-c2 10 1 42 1 42 4 10 16

bw end c3-c2 10 1 42 1 42 4 10 16

firstr is a1, and lastr is g1

r c3-c2 10 1 42 1 42 4 10 16

first 10 1 42 1 42 4 10 16

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

space d1 is h1

24 h1 d1-c2 10 1 42 1 42 4 10 16

1010 1 101010 1 101010 100 1010 10000

1 one bits in var h1

1010 1 101010 1 101010 100 1010 10000

q end d1-c2 10 1 42 1 42 4 10 16

bb end d1-c2 10 1 42 1 42 4 10 16

bw end d1-c2 10 1 42 1 42 4 10 16

firstr is a1, and lastr is g1

r d1-c2 10 1 42 1 42 4 10 16

first 10 1 42 1 42 4 10 16

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

space b4 is d1

25 d1 b4-c2 10 1 42 1 42 4 10 16

1010 1 101010 1 101010 100 1010 10000

1 one bits in var d1

1010 1 101010 1 101010 100 1010 10000

q end b4-c2 10 1 42 1 42 4 10 16

bb end b4-c2 10 1 42 1 42 4 10 16

bw end b4-c2 10 1 42 1 42 4 10 16

firstr is a1, and lastr is g1

r b4-c2 10 1 42 1 42 4 10 16

first 10 1 42 1 42 4 10 16

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

space c1 is c1

26 c1 c1-c2 10 1 42 1 42 4 10 16

1010 1 101010 1 101010 100 1010 10000

3 one bits in var c1

1010 1 101000 1 101010 100 1010 10000

q end c1-c2 10 1 40 1 42 4 10 16

bb end c1-c2 10 1 40 1 42 4 10 16

bw end c1-c2 10 1 40 1 42 4 10 16

firstr is a1, and lastr is g1

r c1-c2 10 1 40 1 42 4 10 16

first 10 1 40 1 42 4 10 16

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

space f7 is p

27 p f7-f5 10 1 40 1 42 4 10 16

1010 1 101000 1 101010 100 1010 10000

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

space f2 is P

28 P f2-f3 10 1 40 1 42 4 10 16

1010 1 101000 1 101010 100 1010 10000

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

space c8 is c1

29 c1 c8-d7 10 1 40 1 42 4 10 16

1010 1 101000 1 101010 100 1010 10000

2 one bits in var c1

1010 1 100000 1 101010 100 1010 10000

q end c8-d7 10 1 32 1 10 4 10 16

bb end c8-d7 10 1 32 1 10 4 10 16

bw end c8-d7 10 1 32 1 10 4 10 16

firstr is a1, and lastr is g1

One Rook found

b1 1

c1 32

r c8-d7 8 1 32 1 10 4 10 16

first 8 1 32 1 10 4 10 16

1000 1 100000 1 1010 100 1010 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end c8-d7 8 1 32 1 10 4 10 16

bb end c8-d7 8 1 32 1 10 4 10 16

bw end c8-d7 8 1 32 1 10 4 10 16

firstr is a1, and lastr is g1

One Rook found

b1 1

c1 32

r c8-d7 8 1 32 1 10 4 10 16

first 8 1 32 1 10 4 10 16

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

space e2 is P

30 P e2-e4 8 1 32 1 10 4 10 16

1000 1 100000 1 1010 100 1010 10000

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

space f5 is p

31 p f5-e4 8 1 32 1 10 4 10 16

1000 1 100000 1 1010 100 1010 10000

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

space f3 is P

32 P f3-e4 8 1 32 1 10 4 10 16

1000 1 100000 1 1010 100 1010 10000

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

space e8 is e1

33 e1 e8-e6 8 1 32 1 10 4 10 16

1000 1 100000 1 1010 100 1010 10000

2 one bits in var e1

rook ride

e1 currently set to 10

e1 now set to 8

1000 1 100000 1 1000 100 1010 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space a1 is a1

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

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space a8 is a1

35 a1 a8-e8 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space g1 is g1

36 g1 g1-c5 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var g1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space e6 is e1

37 e1 e6-e4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var e1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space e1 is e1

38 e1 e1-e4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var e1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space e8 is a1

39 a1 e8-e4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space c2 is c1

40 c1 c2-d3 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space e4 is a1

41 a1 e4-c4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space c5 is g1

42 g1 c5-f2 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var g1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space c4 is a1

43 a1 c4-a4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end c4-a4 8 1 32 1 8 4 2 16

bb end c4-a4 8 1 32 1 8 4 2 16

bw end c4-a4 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

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

space g3 is P

44 P g3-g4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

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

space a4 is a1

45 a1 a4-a2 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end a4-a2 8 1 32 1 8 4 2 16

bb end a4-a2 8 1 32 1 8 4 2 16

bw end a4-a2 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

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

space f2 is g1

46 g1 f2-a7 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var g1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space b7 is p

47 p b7-b6 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

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

space d1 is a1

48 a1 d1-f1 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space g8 is g1

49 g1 g8-e6 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var g1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space f1 is a1

50 a1 f1-f8 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space a2 is a1

51 a1 a2-h2 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space f8 is a1

52 a1 f8-b8 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space e6 is g1

53 g1 e6-g4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var g1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end e6-g4 8 1 32 1 8 4 2 16

bb end e6-g4 8 1 32 1 8 4 2 16

bw end e6-g4 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

mv is b8-b7, p is #p, o is b8

space b8 is a1

54 a1 b8-b7 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end b8-b7 8 1 32 1 8 4 2 16

bb end b8-b7 8 1 32 1 8 4 2 16

bw end b8-b7 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

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

space d7 is c1

55 c1 d7-c6 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end d7-c6 8 1 32 1 8 4 2 16

bb end d7-c6 8 1 32 1 8 4 2 16

bw end d7-c6 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

mv is b7-b8, p is #p, o is b7

space b7 is a1

56 a1 b7-b8 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end b7-b8 8 1 32 1 8 4 2 16

bb end b7-b8 8 1 32 1 8 4 2 16

bw end b7-b8 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

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

space h7 is p

57 p h7-h5 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

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

space b8 is a1

58 a1 b8-g8 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space g4 is g1

59 g1 g4-f5 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var g1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space d3 is c1

60 c1 d3-d4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space h2 is a1

61 a1 h2-h4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space d4 is c1

62 c1 d4-e3 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space a6 is p

63 p a6-a5 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

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

space g8 is a1

64 a1 g8-g7 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space c6 is c1

65 c1 c6-b7 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end c6-b7 8 1 32 1 8 4 2 16

bb end c6-b7 8 1 32 1 8 4 2 16

bw end c6-b7 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

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

space e3 is c1

66 c1 e3-f3 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space a5 is p

67 p a5-a4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

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

space a7 is g1

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

1000 1 100000 1 1000 100 10 10000

1 one bits in var g1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end a7-b6 8 1 32 1 8 4 2 16

bb end a7-b6 8 1 32 1 8 4 2 16

bw end a7-b6 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

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

space b7 is c1

69 c1 b7-b6 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end b7-b6 8 1 32 1 8 4 2 16

bb end b7-b6 8 1 32 1 8 4 2 16

bw end b7-b6 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

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

space f3 is c1

70 c1 f3-g3 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space h4 is a1

71 a1 h4-h3 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space g3 is c1

72 c1 g3-f4 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

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

space a4 is p

73 p a4-a3 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

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

space f4 is c1

74 c1 f4-g5 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var c1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end f4-g5 8 1 32 1 8 4 2 16

bb end f4-g5 8 1 32 1 8 4 2 16

bw end f4-g5 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

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

space a3 is p

75 p a3-a2 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

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

space g7 is a1

76 a1 g7-f7 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

1 one bits in var a1

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

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

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

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

first 8 1 32 1 8 4 2 16

mv is a2-a1; q-a1, p is a2-a1;, o is q

space q is

77 a2-a1; q-a1 8 1 32 1 8 4 2 16

1000 1 100000 1 1000 100 10 10000

0 one bits in var

1000 1 100000 1 1000 100 10 10000

c1

Array
(
    [0] => a1
    [1] => b1
)

q end a2-a1; q-a1 8 1 32 1 8 4 2 16

bb end a2-a1; q-a1 8 1 32 1 8 4 2 16

bw end a2-a1; q-a1 8 1 32 1 8 4 2 16

first 8 1 32 1 8 4 2 16

\count is 3

Syntax Error on line 1130

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

mline

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

allmoves

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

movelist

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

constants

Array ( )