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

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

space f2 is P

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

11011 111101 111011 111101 111011 111101 111011 11101

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

space d7 is p

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

11011 111101 111011 111101 111011 111101 111011 11101

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

space d2 is P

2 P d2-d4 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

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

space f7 is p

3 p f7-f6 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

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

space f4 is P

4 P f4-f5 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

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

space h7 is p

5 p h7-h6 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

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

space g2 is P

6 P g2-g4 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

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

space c7 is p

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

11011 111101 111011 111101 111011 111101 111011 11101

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

space d1 is d1

8 d1 d1-e3 27 61 59 61 59 61 59 29

11011 111101 111011 111101 111011 111101 111011 11101

5 one bits in var d1

11011 111101 111011 1 111011 111101 111011 11101

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

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

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

firstr is a1, and lastr is h1

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

first 27 61 59 1 59 61 59 29

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

space d6 is p

9 p d6-d5 27 61 59 1 59 61 59 29

11011 111101 111011 1 111011 111101 111011 11101

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

space b1 is b1

10 b1 b1-c3 27 61 59 1 59 61 59 29

11011 111101 111011 1 111011 111101 111011 11101

5 one bits in var b1

11011 1 111011 1 111011 111101 111011 11101

q end b1-c3 27 1 59 1 59 61 59 29

bb end b1-c3 27 1 59 1 59 61 59 29

bw end b1-c3 27 1 59 1 59 61 59 29

firstr is a1, and lastr is h1

r b1-c3 27 1 59 1 59 61 59 29

first 27 1 59 1 59 61 59 29

11010 1 111010 1 111010 111100 111010 11100

q end b1-c3 26 1 58 1 58 60 58 28

bb end b1-c3 26 1 58 1 58 60 58 28

bw end b1-c3 26 1 58 1 58 60 58 28

firstr is a1, and lastr is h1

r b1-c3 26 1 58 1 58 60 58 28

first 26 1 58 1 58 60 58 28

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

space a7 is p

11 p a7-a6 26 1 58 1 58 60 58 28

11010 1 111010 1 111010 111100 111010 11100

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

space c1 is c1

12 c1 c1-d2 26 1 58 1 58 60 58 28

11010 1 111010 1 111010 111100 111010 11100

4 one bits in var c1

11010 1 110010 1 111010 111100 111010 11100

q end c1-d2 26 1 50 1 58 60 58 28

bb end c1-d2 26 1 50 1 58 60 58 28

bw end c1-d2 26 1 50 1 58 60 58 28

firstr is a1, and lastr is h1

r c1-d2 26 1 50 1 58 60 58 28

first 26 1 50 1 58 60 58 28

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

space g8 is g1

13 g1 g8-h7 26 1 50 1 58 60 58 28

11010 1 110010 1 111010 111100 111010 11100

4 one bits in var g1

11010 1 110010 1 111010 111100 110010 11100

q end g8-h7 26 1 50 1 58 60 50 28

bb end g8-h7 26 1 50 1 58 60 50 28

bw end g8-h7 26 1 50 1 58 60 50 28

firstr is a1, and lastr is h1

r g8-h7 26 1 50 1 58 60 50 28

first 26 1 50 1 58 60 50 28

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

space c3 is b1

14 b1 c3-a4 26 1 50 1 58 60 50 28

11010 1 110010 1 111010 111100 110010 11100

1 one bits in var b1

11010 1 110010 1 111010 111100 110010 11100

q end c3-a4 26 1 50 1 58 60 50 28

bb end c3-a4 26 1 50 1 58 60 50 28

bw end c3-a4 26 1 50 1 58 60 50 28

firstr is a1, and lastr is h1

r c3-a4 26 1 50 1 58 60 50 28

first 26 1 50 1 58 60 50 28

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

space g7 is p

15 p g7-g6 26 1 50 1 58 60 50 28

11010 1 110010 1 111010 111100 110010 11100

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

space a4 is b1

16 b1 a4-b6 26 1 50 1 58 60 50 28

11010 1 110010 1 111010 111100 110010 11100

1 one bits in var b1

11010 1 110010 1 111010 111100 110010 11100

q end a4-b6 26 1 50 1 58 60 50 28

bb end a4-b6 26 1 50 1 58 60 50 28

bw end a4-b6 26 1 50 1 58 60 50 28

firstr is a1, and lastr is h1

r a4-b6 26 1 50 1 58 60 50 28

first 26 1 50 1 58 60 50 28

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

space c8 is c1

17 c1 c8-c7 26 1 50 1 58 60 50 28

11010 1 110010 1 111010 111100 110010 11100

3 one bits in var c1

11010 1 110000 1 111010 111100 110010 11100

q end c8-c7 26 1 48 1 58 60 50 28

bb end c8-c7 26 1 48 1 58 60 50 28

bw end c8-c7 26 1 48 1 58 60 50 28

firstr is a1, and lastr is h1

r c8-c7 26 1 48 1 58 60 50 28

first 26 1 48 1 58 60 50 28

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

space b6 is b1

18 b1 b6-a8 26 1 48 1 58 60 50 28

11010 1 110000 1 111010 111100 110010 11100

1 one bits in var b1

11010 1 110000 1 111010 111100 110010 11100

q end b6-a8 26 1 48 1 58 60 50 28

bb end b6-a8 26 1 48 1 58 60 50 28

bw end b6-a8 26 1 48 1 58 60 50 28

firstr is a1, and lastr is h1

r b6-a8 26 1 48 1 58 60 50 28

first 26 1 48 1 58 60 50 28

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

space c7 is c1

19 c1 c7-d7 26 1 48 1 58 60 50 28

11010 1 110000 1 111010 111100 110010 11100

2 one bits in var c1

11010 1 110000 1 111010 111100 110010 11100

q end c7-d7 26 1 48 1 58 60 50 28

bb end c7-d7 26 1 48 1 58 60 50 28

bw end c7-d7 26 1 48 1 58 60 50 28

firstr is a1, and lastr is h1

r c7-d7 26 1 48 1 58 60 50 28

first 26 1 48 1 58 60 50 28

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

space d2 is c1

20 c1 d2-a5 26 1 48 1 58 60 50 28

11010 1 110000 1 111010 111100 110010 11100

2 one bits in var c1

11010 1 10000 1 111010 111100 110010 11100

queen before d2-a5 26 1 16 1 58 60 50 28

queen after d2-a5 10 1 16 1 42 44 34 12

q end d2-a5 10 1 16 1 42 44 34 12

bb end d2-a5 10 1 16 1 42 44 34 12

bw end d2-a5 10 1 16 1 42 44 34 12

firstr is a1, and lastr is h1

r d2-a5 10 1 16 1 42 44 34 12

first 10 1 16 1 42 44 34 12

1010 1 10000 1 101010 101100 100010 1100

q end d2-a5 10 1 16 1 42 44 34 12

bb end d2-a5 10 1 16 1 42 44 34 12

bw end d2-a5 10 1 16 1 42 44 34 12

firstr is a1, and lastr is h1

r d2-a5 10 1 16 1 42 44 34 12

first 10 1 16 1 42 44 34 12

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

space b7 is p

21 p b7-b5 10 1 16 1 42 44 34 12

1010 1 10000 1 101010 101100 100010 1100

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

space a5 is c1

22 c1 a5-c7 10 1 16 1 42 44 34 12

1010 1 10000 1 101010 101100 100010 1100

1 one bits in var c1

1010 1 10000 1 101010 101100 100010 1100

q end a5-c7 10 1 16 1 42 44 34 12

bb end a5-c7 10 1 16 1 42 44 34 12

bw end a5-c7 10 1 16 1 42 44 34 12

firstr is a1, and lastr is h1

r a5-c7 10 1 16 1 42 44 34 12

first 10 1 16 1 42 44 34 12

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

space g6 is p

23 p g6-f5 10 1 16 1 42 44 34 12

1010 1 10000 1 101010 101100 100010 1100

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

space c7 is c1

24 c1 c7-b8 10 1 16 1 42 44 34 12

1010 1 10000 1 101010 101100 100010 1100

1 one bits in var c1

1010 1 10000 1 101010 101100 100010 1100

q end c7-b8 10 1 16 1 42 44 34 12

bb end c7-b8 10 1 16 1 42 44 34 12

bw end c7-b8 10 1 16 1 42 44 34 12

firstr is a1, and lastr is h1

r c7-b8 10 1 16 1 42 44 34 12

first 10 1 16 1 42 44 34 12

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

space e8 is e1

25 e1 e8-f7 10 1 16 1 42 44 34 12

1010 1 10000 1 101010 101100 100010 1100

3 one bits in var e1

1010 1 10000 1 100010 101100 100010 1100

q end e8-f7 10 1 16 1 34 44 34 12

bb end e8-f7 10 1 16 1 34 44 34 12

bw end e8-f7 10 1 16 1 34 44 34 12

firstr is a1, and lastr is h1

r e8-f7 10 1 16 1 34 44 34 12

first 10 1 16 1 34 44 34 12

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

space b8 is c1

26 c1 b8-c7 10 1 16 1 34 44 34 12

1010 1 10000 1 100010 101100 100010 1100

1 one bits in var c1

1010 1 10000 1 100010 101100 100010 1100

q end b8-c7 10 1 16 1 34 44 34 12

bb end b8-c7 10 1 16 1 34 44 34 12

bw end b8-c7 10 1 16 1 34 44 34 12

firstr is a1, and lastr is h1

r b8-c7 10 1 16 1 34 44 34 12

first 10 1 16 1 34 44 34 12

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

space d7 is c1

27 c1 d7-c7 10 1 16 1 34 44 34 12

1010 1 10000 1 100010 101100 100010 1100

1 one bits in var c1

1010 1 10000 1 100010 101100 100010 1100

q end d7-c7 10 1 16 1 34 44 34 12

bb end d7-c7 10 1 16 1 34 44 34 12

bw end d7-c7 10 1 16 1 34 44 34 12

firstr is a1, and lastr is h1

r d7-c7 10 1 16 1 34 44 34 12

first 10 1 16 1 34 44 34 12

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

space a8 is b1

28 b1 a8-c7 10 1 16 1 34 44 34 12

1010 1 10000 1 100010 101100 100010 1100

1 one bits in var b1

1010 1 10000 1 100010 101100 100010 1100

q end a8-c7 10 1 16 1 34 44 34 12

bb end a8-c7 10 1 16 1 34 44 34 12

bw end a8-c7 10 1 16 1 34 44 34 12

firstr is a1, and lastr is h1

r a8-c7 10 1 16 1 34 44 34 12

first 10 1 16 1 34 44 34 12

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

space f5 is p

29 p f5-g4 10 1 16 1 34 44 34 12

1010 1 10000 1 100010 101100 100010 1100

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

space e1 is e1

30 e1 e1-c1 10 1 16 1 34 44 34 12

1010 1 10000 1 100010 101100 100010 1100

2 one bits in var e1

rook ride

King castling by moving 2+ spaces

1000 1 10000 1 100000 101100 100010 1100

q end e1-c1 8 1 16 1 32 12 2 12

bb end e1-c1 8 1 16 1 32 12 2 12

bw end e1-c1 8 1 16 1 32 12 2 12

firstr is a1, and lastr is h1

One Rook found

b1 1

c1 16

d1 1

e1 32

r e1-c1 8 1 16 1 32 12 2 12

first 8 1 16 1 32 12 2 12

1000 1 10000 1 100000 1100 10 1100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

q end e1-c1 8 1 16 1 32 12 2 12

bb end e1-c1 8 1 16 1 32 12 2 12

bw end e1-c1 8 1 16 1 32 12 2 12

firstr is a1, and lastr is h1

One Rook found

b1 1

c1 16

d1 1

e1 32

r e1-c1 8 1 16 1 32 12 2 12

first 8 1 16 1 32 12 2 12

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

space h6 is p

31 p h6-h5 8 1 16 1 32 12 2 12

1000 1 10000 1 100000 1100 10 1100

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

space c7 is b1

32 b1 c7-a6 8 1 16 1 32 12 2 12

1000 1 10000 1 100000 1100 10 1100

1 one bits in var b1

1000 1 10000 1 100000 1100 10 1100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

q end c7-a6 8 1 16 1 32 12 2 12

bb end c7-a6 8 1 16 1 32 12 2 12

bw end c7-a6 8 1 16 1 32 12 2 12

firstr is a1, and lastr is h1

One Rook found

b1 1

c1 16

d1 1

e1 32

r c7-a6 8 1 16 1 32 12 2 12

first 8 1 16 1 32 12 2 12

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

space e7 is p

33 p e7-e5 8 1 16 1 32 12 2 12

1000 1 10000 1 100000 1100 10 1100

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

space d4 is P

34 P d4-e5 8 1 16 1 32 12 2 12

1000 1 10000 1 100000 1100 10 1100

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

space f7 is e1

35 e1 f7-e6 8 1 16 1 32 12 2 12

1000 1 10000 1 100000 1100 10 1100

1 one bits in var e1

1000 1 10000 1 100000 1100 10 1100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

q end f7-e6 8 1 16 1 32 12 2 12

bb end f7-e6 8 1 16 1 32 12 2 12

bw end f7-e6 8 1 16 1 32 12 2 12

firstr is a1, and lastr is h1

One Rook found

b1 1

c1 16

d1 1

e1 32

r f7-e6 8 1 16 1 32 12 2 12

first 8 1 16 1 32 12 2 12

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

space e5 is P

36 P e5-f6 8 1 16 1 32 12 2 12

1000 1 10000 1 100000 1100 10 1100

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

space h8 is h1

37 h1 h8-f6 8 1 16 1 32 12 2 12

1000 1 10000 1 100000 1100 10 1100

2 one bits in var h1

1000 1 10000 1 100000 1100 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space c2 is P

38 P c2-c3 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space f8 is f1

39 f1 f8-f7 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var f1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space e3 is d1

40 d1 e3-c2 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var d1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space f6 is h1

41 h1 f6-g5 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space g1 is g1

42 g1 g1-e3 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var g1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space h7 is g1

43 g1 h7-c2 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var g1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space c1 is e1

44 e1 c1-c2 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var e1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space g5 is h1

45 h1 g5-e3 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space f1 is f1

46 f1 f1-f7 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var f1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space d8 is d1

47 d1 d8-f7 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var d1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space d1 is a1

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

1000 1 10000 1 100000 1000 10 100

1 one bits in var a1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space e3 is h1

49 h1 e3-f4 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space h2 is P

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

1000 1 10000 1 100000 1000 10 100

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

space f7 is d1

51 d1 f7-e5 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var d1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space a6 is b1

52 b1 a6-c5 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var b1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space e6 is e1

53 e1 e6-e7 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var e1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space d3 is a1

54 a1 d3-d1 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var a1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space g4 is p

55 p g4-h3 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space c5 is b1

56 b1 c5-d3 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var b1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space f4 is h1

57 h1 f4-g3 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space d3 is b1

58 b1 d3-e5 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var b1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space g3 is h1

59 h1 g3-e5 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space e2 is P

60 P e2-e4 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space d5 is p

61 p d5-e4 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space h1 is h1

62 h1 h1-e4 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space c6 is p

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

1000 1 10000 1 100000 1000 10 100

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

space d1 is a1

64 a1 d1-d5 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var a1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space e7 is e1

65 e1 e7-e6 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var e1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space d5 is a1

66 a1 d5-c5 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var a1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space h3 is p

67 p h3-h2 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space c5 is a1

68 a1 c5-b5 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var a1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space h5 is p

69 p h5-h4 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space a2 is P

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

1000 1 10000 1 100000 1000 10 100

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

space h4 is p

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

1000 1 10000 1 100000 1000 10 100

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

space a4 is P

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

1000 1 10000 1 100000 1000 10 100

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

space h2 is p

73 p h2-h1 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space e4 is h1

74 h1 e4-h1 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space h3 is p

75 p h3-h2 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space a5 is P

76 P a5-a6 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space e5 is h1

77 h1 e5-c3 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

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

space a6 is P

78 P a6-a7 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

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

space c3 is h1

79 h1 c3-b2 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

1 one bits in var h1

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

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

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

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

first 8 1 16 1 32 8 2 4

mv is a7-a8; Q-a8, p is a7-a8;, o is Q

space Q is

80 a7-a8; Q-a8 8 1 16 1 32 8 2 4

1000 1 10000 1 100000 1000 10 100

0 one bits in var

1000 1 10000 1 100000 1000 10 100

e1

Array
(
    [0] => a1
    [1] => b1
    [2] => c1
    [3] => d1
)

q end a7-a8; Q-a8 8 1 16 1 32 8 2 4

bb end a7-a8; Q-a8 8 1 16 1 32 8 2 4

bw end a7-a8; Q-a8 8 1 16 1 32 8 2 4

first 8 1 16 1 32 8 2 4

\count is 3

Syntax Error on line 1145

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

Edit the Settings File for Fischer Random Chess

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

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

mline

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

allmoves

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

movelist

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

constants

Array ( )