Showing x when a move to certain position is impossible, showing o when it is fine. Adding Board.findMove method to keep the allowed move logic.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * The contents of this file are subject to the terms of either the GNU
5 * General Public License Version 2 only ("GPL") or the Common
6 * Development and Distribution License("CDDL") (collectively, the
7 * "License"). You may not use this file except in compliance with the
8 * License. You can obtain a copy of the License at
9 * http://www.netbeans.org/cddl-gplv2.html
10 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
11 * specific language governing permissions and limitations under the
12 * License. When distributing the software, include this License Header
13 * Notice in each file and include the License file at
14 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
15 * particular file as subject to the "Classpath" exception as provided
16 * by Sun in the GPL Version 2 section of the License file that
17 * accompanied this code. If applicable, add the following below the
18 * License Header, with the fields enclosed by brackets [] replaced by
19 * your own identifying information:
20 * "Portions Copyrighted [year] [name of copyright owner]"
24 * Portions Copyrighted 2009 Jaroslav Tulach
26 package cz.xelfi.quoridor;
28 import cz.xelfi.quoridor.Fence.Orientation;
29 import cz.xelfi.quoridor.Player.Direction;
30 import java.io.IOException;
31 import java.io.StringReader;
32 import java.io.StringWriter;
33 import java.util.List;
34 import junit.framework.TestCase;
38 * @author Jaroslav Tulach <jtulach@netbeans.org>
40 public abstract class BoardCase extends TestCase {
41 protected Board board;
43 protected BoardCase(String n) {
45 board = Board.empty();
48 protected abstract Board move(Board b, int player, Player.Direction... where)
49 throws IllegalPositionException;
51 protected abstract Board fence(Board b, int player, char x, int y, Fence.Orientation orie)
52 throws IllegalPositionException;
54 protected abstract Board apply(Board b, Move move) throws IllegalPositionException;
57 public void testResignWhite() throws IllegalPositionException {
58 List<Player> list = board.getPlayers();
59 assertEquals ("Two", 2, list.size ());
60 Board b = board.apply(Move.RESIGN);
61 assertEquals(b.getPlayers().get(1), b.getWinner());
64 fail("No more moves allowed, the player resigned");
65 } catch (IllegalPositionException ex) {
68 assertNull("No player", b.getCurrentPlayer());
70 public void testResignBlack() throws IllegalPositionException {
71 List<Player> list = board.getPlayers();
72 assertEquals ("Two", 2, list.size ());
73 Board b = board.apply(Move.NORTH).apply(Move.RESIGN);
74 assertEquals(b.getPlayers().get(0), b.getWinner());
77 fail("No more moves allowed, the player resigned");
78 } catch (IllegalPositionException ex) {
81 assertNull("No player", b.getCurrentPlayer());
83 public void testTwoPlayers () {
84 List<Player> list = board.getPlayers();
85 assertEquals ("Two", 2, list.size ());
86 assertFalse ("Both are non-null", list.contains (null));
89 fail ("Modifications are not allowed");
90 } catch (UnsupportedOperationException ex) {
95 fail ("Modifications are not allowed");
96 } catch (UnsupportedOperationException ex) {
101 assertEquals (8, list.get (0).getXInternal());
102 assertEquals (0, list.get (0).getYInternal());
103 assertEquals (10, list.get (0).getFences ());
104 assertEquals (8, list.get (1).getXInternal());
105 assertEquals (16, list.get (1).getYInternal());
106 assertEquals (10, list.get (1).getFences ());
109 public void testFences () throws IllegalPositionException {
110 assertEquals ("No on board", 0, board.getFences ().size ());
112 board.getFences ().add (null);
113 fail ("Should be unmodifiable");
114 } catch (java.lang.UnsupportedOperationException ex) {
119 Board b = board.apply(Move.fence('A', 1, Orientation.HORIZONTAL));
120 assertEquals("One fence placed: ", 1, b.getFences().size());
121 Fence f = b.getFences().iterator().next();
122 assertEquals("Row", 1, f.getRow());
123 assertEquals("Column", 'A', f.getColumn());
127 Board b = board.apply(Move.fence('A', 1, Orientation.VERTICAL));
128 assertEquals("One fence placed: ", 1, b.getFences().size());
129 Fence f = b.getFences().iterator().next();
130 assertEquals("Row", 1, f.getRow());
131 assertEquals("Column", 'A', f.getColumn());
135 Board b = board.apply(Move.fence('H', 8, Orientation.HORIZONTAL));
136 assertEquals("One fence placed: ", 1, b.getFences().size());
137 Fence f = b.getFences().iterator().next();
138 assertEquals("Row", 8, f.getRow());
139 assertEquals("Column", 'H', f.getColumn());
143 Board b = board.apply(Move.fence('H', 8, Orientation.VERTICAL));
144 assertEquals("One fence placed: ", 1, b.getFences().size());
145 Fence f = b.getFences().iterator().next();
146 assertEquals("Row", 8, f.getRow());
147 assertEquals("Column", 'H', f.getColumn());
150 public void testTwoFencesInTheSamePosition() throws IllegalPositionException {
151 assertEquals ("No on board", 0, board.getFences ().size ());
152 Board one = board.apply(Move.fence('A', 1, Orientation.HORIZONTAL));
154 Board snd = one.apply(Move.fence('A', 1, Orientation.HORIZONTAL));
155 fail("Cannot place fence twice to the same place");
156 } catch (IllegalPositionException ex) {
161 public void testSelfDestructionForbidden() throws Exception {
164 b = fence(b, 0, 'D', 1, Orientation.VERTICAL);
165 b = move(b, 1, Player.Direction.SOUTH);
166 b = fence(b, 0, 'E', 1, Orientation.VERTICAL);
167 b = move(b, 1, Player.Direction.SOUTH);
169 b = fence(b, 0, 'E', 2, Orientation.HORIZONTAL);
170 fail ("Forbidden. Player 0 has no way to reach the end");
171 } catch (IllegalPositionException ex) {
176 public void testRealSelfDestructionForbidden() throws Exception {
180 " A B C D E F G H\n" +
181 " | | | | | | | |\n" +
182 " +*----------------------------------+\n" +
184 " 8--|-------+-------+-------+-------+ |--8\n" +
186 " 7--| + + + |-------+ | + |--7\n" +
188 " 6--| + + + + + | + + |--6\n" +
190 " 5--| + + + + |-------+ + |--5\n" +
192 " 4--| + + + + +-------+ + |--4\n" +
194 " 3--| + + + + + + | | |--3\n" +
196 " 2--| + + + + + + + + |--2\n" +
198 " 1--| + + + + + | +-------|--1\n" +
200 " +||||-------------------------------+\n" +
201 " | | | | | | | |\n" +
202 " A B C D E F G H\n" +
206 b = picture2board(b).toString();
207 Board begin = Board.valueOf(b);
210 Board bad = fence(begin, 0, 'G', 2, Orientation.HORIZONTAL);
211 fail("Not allowed move:\n" + bad.toString());
212 } catch (IllegalPositionException ex) {
216 public void testFourTimesInAgainstEachOtherResultsInInvalidPosition () throws Exception {
219 for (int i = 0; i < 3; i++) {
220 b = move(b, 0, Player.Direction.NORTH);
221 b = move(b, 1, Player.Direction.SOUTH);
224 b = move(b, 0, Player.Direction.NORTH);
226 b = move(b, 1, Player.Direction.SOUTH);
227 fail ("Now the positions of two players are supposed to be the same, this results in exception");
228 } catch (IllegalPositionException ex) {
233 public void testCanNorth() {
234 Move m = board.findMove(board.getCurrentPlayer(), 4, 1);
235 assertEquals("Go north", Move.NORTH, m);
237 public void testCanEast() {
238 Move m = board.findMove(board.getCurrentPlayer(), 5, 0);
239 assertEquals("Go east", Move.EAST, m);
241 public void testCanWest() {
242 Move m = board.findMove(board.getCurrentPlayer(), 3, 0);
243 assertEquals("Go west", Move.WEST, m);
245 public void testCannotWestAndNorth() {
246 Move m = board.findMove(board.getCurrentPlayer(), 3, 1);
247 assertNull("No way", m);
249 public void testCanJumpStraight () throws Exception {
252 for (int i = 0; i < 3; i++) {
253 b = move(b, 0, Player.Direction.NORTH);
254 b = move(b, 1, Player.Direction.SOUTH);
256 b = apply(b, Move.NORTH);
257 Move m = b.findMove(b.getPlayers().get(0), 4, 6);
258 assertEquals("N+N", Move.jump(Direction.NORTH, Direction.NORTH), m);
260 public void testCanJumSptraightAndTurn () throws Exception {
263 for (int i = 0; i < 3; i++) {
264 b = move(b, 0, Player.Direction.NORTH);
265 b = move(b, 1, Player.Direction.SOUTH);
267 b = apply(b, Move.fence('A', 1, Orientation.HORIZONTAL));
268 b = apply(b, Move.SOUTH);
269 b = apply(b, Move.fence('D', 5, Orientation.HORIZONTAL));
270 b = apply(b, Move.fence('A', 8, Orientation.HORIZONTAL));
272 Move m = b.findMove(b.getCurrentPlayer(), 4, 5);
273 assertNull("No N+N", m);
274 m = b.findMove(b.getCurrentPlayer(), 5, 4);
275 assertEquals("N+E is OK", Move.jump(Direction.NORTH, Direction.EAST), m);
278 public void testCrossFences () throws Exception {
279 Board b1 = board.fence (board.getPlayers ().get(0), 'A', 1, Fence.Orientation.HORIZONTAL);
282 b1.fence (b1.getPlayers ().get(1), 'A', 1, Fence.Orientation.VERTICAL);
283 fail ("This must fail, as the fences overlap");
284 } catch (IllegalPositionException ex) {
289 public void testPawnsCanJumpOverEachOther () throws Exception {
292 for (int i = 0; i < 3; i++) {
293 b = move(b, 0, Player.Direction.NORTH);
294 b = move(b, 1, Player.Direction.SOUTH);
297 b = move(b, 0, Player.Direction.NORTH);
300 b = move(b, 1, Player.Direction.SOUTH, Player.Direction.SOUTH);
303 public void testJumpBackForbidden() throws Exception {
306 for (int i = 0; i < 3; i++) {
307 b = move(b, 0, Player.Direction.NORTH);
308 b = move(b, 1, Player.Direction.SOUTH);
311 b = move(b, 0, Player.Direction.NORTH);
313 b = fence(b, 1, 'D', 6, Orientation.HORIZONTAL);
316 b = move(b, 0, Player.Direction.NORTH, Player.Direction.NORTH);
317 fail("Can't jump over a pawn when there is a fence");
318 } catch (IllegalPositionException ex) {
323 b = move(b, 0, Player.Direction.NORTH, Player.Direction.SOUTH);
324 fail("Can't bounce from the fence back neither");
325 } catch (IllegalPositionException ex) {
330 public void testCannotJumpOverFence () throws Exception {
331 Board b = fence (board, 0, 'D', 8, Fence.Orientation.HORIZONTAL);
332 assertEquals("One fence is present", 1, b.getFences().size());
333 final Fence f = b.getFences().iterator().next();
334 assertEquals("Row is 8", 8, f.getRow());
335 assertEquals("Column is D", 'D', f.getColumn());
337 move(b, 1, Player.Direction.SOUTH);
338 fail ("This shall not be allowed, as there is the fence");
339 } catch (IllegalPositionException ex) {
345 public void testSideJumpsNotAllowedWhenThereIsNoFence () throws Exception {
348 for (int i = 0; i < 3; i++) {
349 b = move(b, 0, Player.Direction.NORTH);
350 b = move(b, 1, Player.Direction.SOUTH);
353 b = move(b, 0, Player.Direction.NORTH);
356 b = move(b, 1, Player.Direction.SOUTH, Player.Direction.WEST);
357 fail ("Cannot just jump aside");
358 } catch (IllegalPositionException ex) {
363 public void testSideJumpsAllowedWhenThereAFence () throws Exception {
366 for (int i = 0; i < 3; i++) {
367 b = move(b, 0, Player.Direction.NORTH);
368 b = move(b, 1, Player.Direction.SOUTH);
371 b = move(b, 0, Player.Direction.NORTH);
373 assertEquals (8, b.getPlayers ().get (0).getXInternal());
374 assertEquals (8, b.getPlayers ().get (0).getYInternal());
376 b = fence(b, 0, 'D', 4, Fence.Orientation.HORIZONTAL);
378 // we can over jump to west
379 move(b, 1, Player.Direction.SOUTH, Player.Direction.WEST);
381 move(b, 1, Player.Direction.SOUTH, Player.Direction.EAST);
384 public void testPlaceAllFences() throws Exception {
387 public void testPlaceAllFences2() throws Exception {
391 private void doPlaceAllFences(int player) throws Exception {
395 for (int i = 1; i <= 5; i++) {
396 b = fence(b, player, 'A', i, Fence.Orientation.HORIZONTAL);
397 b = fence(b, player, 'D', i, Fence.Orientation.HORIZONTAL);
399 assertEquals("Two less" + i, cnt, b.getPlayers().get(player).getFences());
403 fence(b, player, 'F', 7, Fence.Orientation.VERTICAL);
404 fail("We shall run out of fences");
405 } catch (IllegalPositionException ex) {
410 public void testAlwaysHasToHaveAccessToEndLine () throws Exception {
413 b = b.fence (b.getPlayers ().get (0), 'E', 1, Fence.Orientation.HORIZONTAL);
414 b = b.fence (b.getPlayers ().get (0), 'F', 1, Fence.Orientation.VERTICAL);
417 b = b.fence (b.getPlayers ().get (0), 'D', 1, Fence.Orientation.VERTICAL);
418 fail ("This is not allowed as player 0 cannot now reach the final line");
419 } catch (IllegalPositionException ex) {
425 public void testEqualsOfPlayers () throws Exception {
426 Player p1 = new Player (1, 1, 10, Player.Direction.EAST);
427 Player p2 = new Player (1, 1, 10, Player.Direction.EAST);
428 Player p3 = new Player (2, 1, 10, Player.Direction.EAST);
429 Player p4 = new Player (1, 1, 10, Player.Direction.WEST);
430 Player p5 = new Player (1, 2, 10, Player.Direction.EAST);
431 Player p6 = new Player (1, 1, 5, Player.Direction.EAST);
433 assertEquals ("p1 == p2", p1, p2);
434 if (p2.equals (p3)) fail ();
435 if (p2.equals (p4)) fail ();
436 if (p2.equals (p5)) fail ();
437 if (p2.equals (p6)) fail ();
438 if (p3.equals (p6)) fail ();
439 if (p4.equals (p3)) fail ();
440 if (p6.equals (p3)) fail ();
441 if (p5.equals (p3)) fail ();
442 if (p5.equals (p3)) fail ();
443 if (p4.equals (p3)) fail ();
444 if (p3.equals (p4)) fail ();
445 if (p3.equals (p5)) fail ();
446 if (p4.equals (p5)) fail ();
447 if (p5.equals (p4)) fail ();
450 public void testEqualsOfFences () throws Exception {
451 Fence f1 = new Fence (1, 1, Fence.Orientation.HORIZONTAL);
452 Fence f2 = new Fence (1, 1, Fence.Orientation.HORIZONTAL);
453 Fence f3 = new Fence (3, 1, Fence.Orientation.HORIZONTAL);
454 Fence f4 = new Fence (1, 3, Fence.Orientation.HORIZONTAL);
455 Fence f5 = new Fence (1, 1, Fence.Orientation.VERTICAL);
457 assertEquals ("f1 == f2", f1, f2);
458 if (f1.equals (f3)) fail ();
459 if (f3.equals (f1)) fail ();
460 if (f5.equals (f1)) fail ();
461 if (f1.equals (f5)) fail ();
462 if (f4.equals (f1)) fail ();
463 if (f1.equals (f4)) fail ();
466 public void testEqualsOfBoards1 () throws Exception {
467 Board b1 = board.move (board.getPlayers ().get (0), Player.Direction.NORTH);
468 Board b2 = board.move (board.getPlayers ().get (0), Player.Direction.NORTH);
469 Board b3 = board.move (board.getPlayers ().get (0), Player.Direction.EAST);
471 if (b1.equals (b3)) fail ();
472 if (b3.equals (b1)) fail ();
474 assertEquals ("b1 == b2", b1, b2);
476 public void testEqualsOfBoards2 () throws Exception {
477 Board b1 = board.fence (board.getPlayers ().get (0), 'E', 3, Fence.Orientation.HORIZONTAL);
478 Board b2 = board.fence (board.getPlayers ().get (0), 'E', 3, Fence.Orientation.HORIZONTAL);
479 Board b3 = board.fence (board.getPlayers ().get (0), 'D', 3, Fence.Orientation.HORIZONTAL);
480 Board b4 = board.fence (board.getPlayers ().get (0), 'E', 4, Fence.Orientation.HORIZONTAL);
481 Board b5 = board.fence (board.getPlayers ().get (0), 'E', 3, Fence.Orientation.VERTICAL);
483 if (b1.equals (b3)) fail ();
484 if (b3.equals (b1)) fail ();
485 if (b1.equals (b4)) fail ();
486 if (b1.equals (b5)) fail ();
487 if (b5.equals (b1)) fail ();
488 if (b4.equals (b1)) fail ();
490 assertEquals ("b1 == b2", b1, b2);
492 public void testEqualsOfBoardsWhenJumpOver () throws Exception {
495 for (int i = 0; i < 3; i++) {
496 b = move(b, 0, Player.Direction.NORTH);
497 b = move(b, 1, Player.Direction.SOUTH);
500 Board b1 = move(b, 0, Player.Direction.NORTH);
502 Board b2 = move(b, 1, Player.Direction.SOUTH);
503 b2 = b2.move (b2.getPlayers ().get (0), Player.Direction.NORTH, Player.Direction.NORTH);
505 if (b1.equals (b2)) fail ("Not the same, pawns are reverted");
506 if (b2.equals (b1)) fail ("Not the same, pawns are reverted");
509 public void testMoveAltersCurrentPlayer() throws Exception {
510 assertEquals("First player ready", board.getCurrentPlayer(), board.getPlayers().get(0));
511 Board b = apply(board, Move.EAST);
513 for (int i = 0; i < 7; i++) {
514 assertEquals("Snd player ready", b.getCurrentPlayer(), b.getPlayers().get(1));
515 b = apply(b, Move.SOUTH);
516 assertEquals("First player ready", b.getCurrentPlayer(), b.getPlayers().get(0));
517 b = apply(b, Move.NORTH);
520 Board fin = b.apply(Move.NORTH).apply(Move.NORTH);
521 assertNotNull("There is a winner", fin.getWinner());
522 assertEquals("And the winner is", fin.getPlayers().get(0), fin.getWinner());
524 assertFalse("No next move can be applied", fin.isApplicable(Move.fence('D', 3, Fence.Orientation.HORIZONTAL)));
527 fin.apply(Move.EAST);
528 fail("No moves allow when we are in final position");
529 } catch (IllegalPositionException ex) {
535 public void testDetectInvalidFence() {
537 Move m = Move.fence('D', 9, Orientation.HORIZONTAL);
538 fail("Move shall not be allowed: " + m);
539 } catch (IllegalPositionException ex) {
544 public void testEqualityOfMoves() throws Exception {
546 for (Direction m1 : Direction.values()) {
547 for (Direction m2 : Direction.values()) {
548 Move both1 = Move.jump(m1, m2);
549 Move both2 = Move.jump(m1, m2);
550 Move opposite = Move.jump(m2, m1);
552 assertTrue("Both boths are equal", both1.equals(both2));
553 assertFalse("Not north", Move.NORTH.equals(both1));
554 assertFalse("Not east", Move.EAST.equals(both1));
555 assertFalse("Not west", Move.WEST.equals(both1));
556 assertFalse("Not south", Move.SOUTH.equals(both1));
560 assertFalse("Not equal to opposite", both1.equals(opposite));
564 Move f1 = Move.fence('D', 6, Orientation.HORIZONTAL);
565 Move f2 = Move.fence('D', 6, Orientation.HORIZONTAL);
566 Move f3 = Move.fence('D', 6, Orientation.VERTICAL);
567 Move f4 = Move.fence('E', 6, Orientation.VERTICAL);
568 Move f5 = Move.fence('E', 5, Orientation.VERTICAL);
570 assertEquals(f1, f2);
571 assertFalse(f1.equals(f3));
572 assertFalse(f4.equals(f5));
573 assertFalse(f3.equals(f5));
576 public void testBrokenWriteOfAGameDanVsJarda() throws Exception {
577 Board b = board.apply(Move.NORTH).apply(Move.SOUTH).
578 apply(Move.NORTH).apply(Move.SOUTH).
579 apply(Move.NORTH).apply(Move.SOUTH).
580 apply(Move.WEST).apply(Move.fence('C', 6, Orientation.HORIZONTAL)).
581 apply(Move.EAST).apply(Move.SOUTH).
582 apply(Move.fence('E', 2, Orientation.HORIZONTAL)).apply(Move.fence('E', 5, Orientation.HORIZONTAL)).
583 apply(Move.fence('F', 3, Orientation.VERTICAL)).apply(Move.fence('D', 6, Orientation.VERTICAL)).
584 apply(Move.jump(Direction.NORTH, Direction.EAST)).apply(Move.fence('F', 5, Orientation.VERTICAL)).
585 apply(Move.fence('E', 1, Orientation.VERTICAL)).apply(Move.fence('E', 4, Orientation.VERTICAL)).
586 apply(Move.fence('D', 8, Orientation.HORIZONTAL)).apply(Move.fence('D', 7, Orientation.HORIZONTAL)).
587 apply(Move.fence('D', 4, Orientation.HORIZONTAL)).apply(Move.fence('E', 8, Orientation.VERTICAL)).
588 apply(Move.fence('C', 3, Orientation.HORIZONTAL)).apply(Move.WEST).
589 apply(Move.fence('D', 2, Orientation.VERTICAL)).apply(Move.fence('A', 4, Orientation.HORIZONTAL)).
590 apply(Move.fence('B', 2, Orientation.HORIZONTAL)).apply(Move.WEST).
591 apply(Move.SOUTH).apply(Move.SOUTH).
592 apply(Move.SOUTH).apply(Move.WEST);
593 Board m = move(b, 0, Direction.WEST);
594 Board f = fence(m, 1, 'A', 1, Orientation.VERTICAL);
595 Board l = fence(f, 0, 'A', 3, Orientation.VERTICAL);
598 public void testTomasHolyCannotJumpWS() throws Exception {
604 Board b = apply(board, Move.NORTH);
605 b = apply(b, Move.SOUTH);
606 b = apply(b, Move.NORTH);
607 b = apply(b, Move.SOUTH);
608 b = apply(b, Move.NORTH);
609 b = apply(b, Move.SOUTH);
616 b = fence(b, 0, 'D', 3, Orientation.HORIZONTAL);
617 b = fence(b, 1, 'E', 6, Orientation.HORIZONTAL);
618 b = fence(b, 0, 'B', 6, Orientation.HORIZONTAL);
619 b = fence(b, 1, 'G', 3, Orientation.HORIZONTAL);
620 b = fence(b, 0, 'E', 3, Orientation.VERTICAL);
621 b = fence(b, 1, 'D', 4, Orientation.HORIZONTAL);
622 b = fence(b, 0, 'A', 4, Orientation.HORIZONTAL);
623 b = fence(b, 1, 'B', 5, Orientation.VERTICAL);
631 b = fence(b, 0, 'E', 1, Orientation.VERTICAL);
632 b = fence(b, 1, 'C', 5, Orientation.HORIZONTAL);
633 b = fence(b, 0, 'E', 5, Orientation.VERTICAL);
634 b = fence(b, 1, 'F', 2, Orientation.HORIZONTAL);
635 b = fence(b, 0, 'H', 2, Orientation.VERTICAL);
636 b = fence(b, 1, 'H', 1, Orientation.HORIZONTAL);
637 b = fence(b, 0, 'B', 3, Orientation.HORIZONTAL);
638 b = fence(b, 1, 'F', 1, Orientation.HORIZONTAL);
639 b = fence(b, 0, 'A', 1, Orientation.HORIZONTAL);
640 b = apply(b, Move.SOUTH);
648 b = apply(b, Move.WEST);
649 b = apply(b, Move.WEST);
650 b = apply(b, Move.WEST);
651 b = fence(b, 1, 'C', 8, Orientation.HORIZONTAL);
652 b = fence(b, 0, 'C', 1, Orientation.HORIZONTAL);
653 b = fence(b, 1, 'E', 8, Orientation.HORIZONTAL);
654 b = apply(b, Move.NORTH);
656 b = move(b, 1, Direction.WEST, Direction.SOUTH);
657 assertNotNull("Board is OK", b);
660 static String toPicture(Board b) throws IOException {
661 StringWriter sw = new StringWriter();
663 return sw.toString();
666 static Board picture2board(String text) throws IOException, IllegalPositionException {
667 StringReader sr = new StringReader(text);
668 return Board.read(sr);