View Javadoc
1   /******************************************************************************
2    * DumpBoard.java - A little utility to parse a board and dump it to stdout. 
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright© 2011 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.6  2011/09/23 03:01:52  dick
10   * Add t6, a tigergammon board.
11   *
12   * Revision 1.5  2011/07/04 03:45:41  dick
13   * Add canMove().
14   *
15   * Revision 1.4  2011/06/19 04:16:00  dick
16   * More descriptive turn display.
17   *
18   * Revision 1.3  2011/06/13 04:45:16  dick
19   * Let's of testing/debugging going on here.
20   *
21   * Revision 1.2  2011/06/10 20:37:41  dick
22   * DumpBoard updates.
23   *
24   * Revision 1.1  2011/06/02 18:52:50  dick
25   * A little utility to parse a board and dump it to stdout.
26   *
27   */
28  
29  /* 
30   * This program is free software: you can redistribute it and/or modify
31   * it under the terms of the GNU General Public License as published by
32   * the Free Software Foundation, either version 3 of the License, or
33   * (at your option) any later version.
34   *
35   * This program is distributed in the hope that it will be useful,
36   * but WITHOUT ANY WARRANTY; without even the implied warranty of
37   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
38   * GNU General Public License for more details.
39   *
40   * You should have received a copy of the GNU General Public License
41   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
42   *
43   * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
44   * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
45   * 
46   */
47  package com.buckosoft.fibs.domain;
48  
49  import org.junit.Ignore;
50  
51  import com.buckosoft.fibs.domain.Board;
52  
53  /** A little utility to parse a board and dump it to stdout. 
54   * <b>Not</b> a JUnit test.
55   * @author Dick Balaska
56   * @since 2011/06/02
57   * @version $Revision$ <br> $Date$
58   * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/test/java/com/buckosoft/fibs/test/BuckoFIBS/domain/DumpBoard.java">cvs DumpBoard.java</a>
59   *
60   */
61  @Ignore
62  public class DumpBoard {
63  	static String s0 = "board:bucko:BuckoFIBS:1:0:0:0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0:-1:-1:-1:3:5:1:1:1:0:1:-1:0:25:0:0:0:0:0:0:0:0";
64  	static String t0 = "board:bucko:dickbalaska:3:0:1:0:0:0:-1:2:2:3:0:2:0:0:0:-4:5:-1:0:0:-2:0:-4:-3:0:0:0:1:0:1:0:0:0:0:1:1:1:0:1:-1:0:25:0:0:0:0:2:0:0:0";
65  	static String t1 = "board:You:BuckoFIBS:5:0:0:0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0:1:0:0:3:6:1:1:1:0:-1:1:25:0:0:0:0:0:0:0:0:0";
66  	static String t2 = "board:You:dickbalaska:5:4:1:-1:-2:0:0:0:0:5:2:2:2:0:0:-2:2:0:0:0:-2:-2:-5:-2:1:0:0:0:2:1:3:2:0:0:2:1:0:0:1:-1:0:25:0:0:1:0:2:0:0:0";
67  	// jIBS wants You to move 4 pieces, but there are only 3 moves.
68  	static String t3 = "You:BuckoFIBS:5:0:0:-1:2:-2:2:2:2:2:2:3:0:0:0:0:0:0:0:0:0:0:0:0:-1:-2:-4:-6:1:-1:2:2:0:0:2:1:0:0:-1:1:25:0:0:0:0:0:4:0:0:0";
69  	static String t4 = "board:BuckoFIBS:dickbalaska:3:0:0:0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0:-1:3:1:0:0:1:1:1:0:-1:1:25:0:0:0:0:0:2:0:0:0";
70  	static String t5 = "board:You:dickbalaska:5:4:3:0:-2:0:0:0:0:5:2:2:0:0:0:-5:4:0:0:0:-2:0:-4:0:-2:0:0:2:0:1:1:5:0:0:1:0:0:0:1:-1:0:25:0:0:0:0:2:0:0:0";
71  	// tigergammon
72  	static String t6 = "board:You:tigergammon_bot_III:3:0:0:0:-1:1:0:0:0:5:0:2:0:0:0:-3:7:0:0:0:-5:0:-2:0:0:-2:0:-2:0:1:0:0:0:0:2:1:0:1:1:-1:0:25:0:0:0:0:2:0:0:0";	
73  	
74  	public static void main(String[] args) {
75  		printBoard(t4);
76  		printBoard(t6);
77  	}
78  
79  	private static void printBoard(String s) {
80  		System.out.println("********************************");
81  		Board b = new Board();
82  		b.parseFibsBoard(s, true);
83  		System.out.println(s);
84  		System.out.println("pl1=" + b.getPlayerName()[0] + " pl2=" + b.getPlayerName()[1]);
85  		System.out.println("match len= " + b.getMatchLength());
86  		System.out.println("match score= " + b.getMatchScore()[0] + "-" + b.getMatchScore()[1]);
87  		StringBuffer sb = new StringBuffer();
88  		for (int i=1; i<25; i++) {
89  			if (i != 1)
90  				sb.append(":");
91  			sb.append(b.getPoints()[i]);
92  		}
93  		System.out.println(sb.toString());
94  		System.out.println("board 0/25 =" + b.getPoints()[0] + "/" + b.getPoints()[25]);
95  		System.out.println("Turn= " + b.getWhosTurn() + " turn" 
96  				+ (b.getWhosTurn() == Board.turnX ? "X" : "O"));
97  		int[][] dice = b.getDice();
98  		System.out.println("dice= " + dice[0][0] + "-" + dice[0][1] + "  " + dice[1][0] + "-" + dice[1][1]);
99  		System.out.println("cube= " + b.getCube() + " hasCube=" + b.getHasCube()) ;
100 		System.out.println("may double you= " + b.isYouMayDouble() + " opp=" + b.isOpponentMayDouble());
101 		System.out.println("color= " + b.getXO() + " dir=" + b.getDirection());
102 		System.out.println("home=" + b.getHome()[0] + "/" + b.getHome()[1] + " bar=" + b.getBar()[0] + "/"+ b.getBar()[1]);
103 		System.out.println("canMove=" + b);
104 		System.out.println("");
105 
106 	}
107 }