test rules
1 immutable b0 = Board([Point.empty, Point.empty, Point.empty, Point.empty, 2 Point.empty, Point.black, Point.white, Point.empty, 3 Point.empty, Point.empty, Point.black, Point.empty, 4 Point.empty, Point.empty, Point.empty, Point.empty].sliced(4, 4)); 5 assert(!b0.put(true, 0, 4).valid); // out-of-bounds 6 assert(!b0.put(true, 1, 1).valid); // non empty 7 assert(!b0.put(true, 0, 0).valid); // begin 8 assert(!b0.put(true, 3, 3).valid); // end 9 assert(!b0.put(true, 0, 1).valid); // no reverse neighbor 10 11 immutable b1 = b0.put(true, 1, 3); 12 assert(b1 == [Point.empty, Point.empty, Point.empty, Point.empty, 13 Point.empty, Point.black, Point.black, Point.black, 14 Point.empty, Point.empty, Point.black, Point.empty, 15 Point.empty, Point.empty, Point.empty, Point.empty].sliced(4, 4)); 16 assert(b1.valid); 17 assert(b1.pass(true)); 18 assert(b1.pass(false)); 19 20 immutable b5x5 = Board([Point.white, Point.empty, Point.white, Point.white, Point.white, 21 Point.empty, Point.black, Point.black, Point.black, Point.empty, 22 Point.black, Point.black, Point.empty, Point.black, Point.white, 23 Point.empty, Point.black, Point.black, Point.black, Point.empty, 24 Point.white, Point.empty, Point.white, Point.white, Point.white].sliced(5, 5)); 25 auto b5x5_ = b5x5.put(false, 2, 2); 26 assert(b5x5_.toString == 27 ` 0 1 2 3 4 28 0[o][ ][o][o][o] 0 29 1[ ][o][o][o][ ] 1 30 2[x][x][o][o][o] 2 31 3[ ][o][o][o][ ] 3 32 4[o][ ][o][o][o] 4 33 0 1 2 3 4 34 `); 35 assert(b5x5_.count == [Point.empty: 6, Point.white: 17, Point.black: 2]); 36 assert(!b5x5_.pass(true)); 37 assert(!b5x5_.pass(false)); 38 39 immutable b2 = Board([Point.empty, Point.empty, Point.empty, Point.empty, 40 Point.empty, Point.black, Point.black, Point.black, 41 Point.empty, Point.empty, Point.black, Point.empty, 42 Point.empty, Point.empty, Point.white, Point.empty].sliced(4, 4)); 43 assert(b2.pass(true)); 44 assert(!b2.pass(false)); 45 46 /* 47 0 1 2 3 48 0[x][ ][ ][ ] 0 49 1[x][o][o][ ] 1 50 2[x][o][o][ ] 2 51 3[o][o][o][ ] 3 52 0 1 2 3 53 >>> 3 0 54 >>> 3 2 55 >>> 1 0 56 */ 57 immutable b3 = Board([Point.black, Point.empty, Point.empty, Point.empty, 58 Point.black, Point.white, Point.white, Point.empty, 59 Point.black, Point.white, Point.white, Point.empty, 60 Point.white, Point.white, Point.white, Point.empty].sliced(4, 4)); 61 assert(!b3.pass(true)); 62 assert(b3.pass(false)); 63 64 /* 65 0 1 2 3 4 5 6 7 66 0[ ][ ][ ][ ][ ][ ][ ][ ] 0 67 1[ ][ ][ ][ ][ ][ ][ ][ ] 1 68 2[ ][ ][ ][ ][ ][ ][ ][ ] 2 69 3[ ][ ][o][o][o][o][o][ ] 3 70 4[x][x][x][x][o][ ][ ][ ] 4 71 5[x][x][x][x][x][o][x][x] 5 72 6[x][x][x][x][x][x][o][ ] 6 73 7[x][x][x][x][x][x][x][x] 7 74 0 1 2 3 4 5 6 7 75 */ 76 enum _ = Point.empty; 77 enum x = Point.black; 78 enum o = Point.white; 79 immutable b4 = Board([_, _, _, _, _, _, _, _, 80 _, _, _, _, _, _, _, _, 81 _, _, _, _, _, _, _, _, 82 _, _, o, o, o, o, o, _, 83 x, x, x, x, o, _, _, _, 84 x, x, x, x, x, o, x, x, 85 x, x, x, x, x, x, o, _, 86 x, x, x, x, x, x, x, x].sliced(8, 8)); 87 assert(!b4.put(false, 0, 0).valid);
returns true if no next move for the color