[Commit] RRbot RicochetRecursive.java,1.6,1.7

Christian L. Platt commit at keithp.com
Tue Jun 10 12:24:13 PDT 2003


Committed by: plattc

Update of /local/src/CVS/RRbot
In directory home.keithp.com:/tmp/cvs-serv618

Modified Files:
	RicochetRecursive.java 
Log Message:
Added the stuff I did to have the RRbot use a board fed to it from the server as a
string.


Index: RicochetRecursive.java
===================================================================
RCS file: /local/src/CVS/RRbot/RicochetRecursive.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- RicochetRecursive.java	10 Jun 2003 18:03:48 -0000	1.6
+++ RicochetRecursive.java	10 Jun 2003 18:24:11 -0000	1.7
@@ -51,7 +51,7 @@
         int numArgs = args.length;
         if ( args.length != 0 ) {
             //parseArgs ( args );
-            readInBoard();
+            readInBoard( args[0] );
         } else {
             getData();
         }
@@ -276,78 +276,84 @@
 
     // this method is only used for reading in a board from the rrserver and
     // converting it to our internal representation
-    public static void readInBoard ( ) {
-        try {
-            InputStreamReader is = new InputStreamReader( System.in );
-            BufferedReader br = new BufferedReader( is );
-            String lineStr;
-            int robotNum = 1;
-            int rowPos = 0;
+    public static void readInBoard ( String boardStr ) {
+        String lineStr;
+        int robotNum = 1;
+        int rowPos = 0;
+        int strPos = 0;
+ 
+        System.out.println();
+        System.out.println();
 
-            while ( (lineStr = br.readLine()) != null ) {
-                System.out.println( lineStr );
+        //while ( (lineStr = br.readLine()) != null ) {
+        boolean done = false;
+        while (rowPos < 33) {
+            lineStr = "";
+      
+            //while ( boardStr.charAt(strPos) != '\n' ) { 
+            for (int i=66*rowPos; i < (66 * rowPos) + 66; i++ ) {
+                lineStr += boardStr.charAt(strPos++);
+            }
+            //strPos++;
 
-                for ( int colPos =0; colPos < lineStr.length(); colPos++ ) {
-                    switch ( lineStr.charAt(colPos) ) {
-                        case '|': 
-                            //add blocker
-                            board.addRowBlock( rowPos/3, colPos/3 );
-                            break;
+            System.out.println( "X" + lineStr );
 
-                        case 'y':  
-                        case 'g':
-                        case 'r':
-                        case 'b':
-                            if ( lineStr.charAt(colPos) == lineStr.charAt(++colPos) ){
-                                robots[robotNum] = new Robot ( rowPos/3, colPos/3 
-                                        , lineStr.charAt(colPos));
-                                board.placeRobot( (rowPos/3), (colPos/3), robotNum++);
-                            }
-                            break;
+            for ( int colPos =0; colPos < lineStr.length(); colPos++ ) {
+                switch ( lineStr.charAt(colPos) ) {
+                    case '|': 
+                        //add blocker
+                        board.addRowBlock( rowPos/2, colPos/4 );
+                        break;
+
+                    case 'y':  
+                    case 'g':
+                    case 'r':
+                    case 'b':
+                        if ( lineStr.charAt(++colPos) == '.' ){
+                            robots[robotNum] = new Robot ( rowPos/2, colPos/4 
+                                                           , lineStr.charAt(colPos));
+                            board.placeRobot( (rowPos/2), (colPos/4), robotNum++);
+                        }
+                        break;
 
 
-                        case '=':
-                            //add blocker
-                            board.addColBlock( rowPos/3, colPos/3 );
-                            colPos++;
-                            break;
+                    case '=':
+                        //add blocker
+                        board.addColBlock( rowPos/2, colPos/4 );
+                        colPos += 2;
+                        break;
 
-                        case 'Y':
-                        case 'G':
-                        case 'R':
-                        case 'B':
-                        case 'W':
-                            if ( lineStr.charAt(colPos) == lineStr.charAt(colPos+1) ){
-                                robots[0] = new Robot ( rowPos/3, colPos/3
-                                        , lineStr.charAt(colPos));
-                                board.placeRobot( (rowPos/3), (colPos/3), 0);
-                            } else if ( lineStr.charAt(colPos+1) == 'S' ||
+                    case 'Y':
+                    case 'G':
+                    case 'R':
+                    case 'B':
+                    case 'W':
+                        //if ( lineStr.charAt(colPos) == lineStr.charAt(colPos+1) ){
+                        if ( lineStr.charAt(colPos+1) == '.'  ){
+                            robots[0] = new Robot ( rowPos/2, colPos/4
+                                                      , lineStr.charAt(colPos));
+                            board.placeRobot( (rowPos/2), (colPos/4), 0);
+                        } else if ( lineStr.charAt(colPos+1) == 'S' ||
                                     lineStr.charAt(colPos+1) == 'T' ||
                                     lineStr.charAt(colPos+1) == 'C' ||
                                     lineStr.charAt(colPos+1) == 'O' ||
                                     lineStr.charAt(colPos+1) == 'W' ) {
 
-                                board.placeGoal ( rowPos/3, colPos/3 );
-                                goalRow = rowPos/3;
-                                goalCol = colPos/3;
-                            }
-                            ++colPos;
-                            break;
-
-                    }
+                            board.placeGoal ( rowPos/2, colPos/4 );
+                            goalRow = rowPos/2;
+                            goalCol = colPos/4;
+                        }
+                        colPos += 2;
+                        break;
 
                 }
 
-                ++rowPos;
-            } 
-
+            }
 
-        } catch ( IOException ioe ) {
-            System.out.println( "Input Error" + ioe );
-        }
+            ++rowPos;
+        } 
 
         return;
-
     }
 
 




More information about the Commit mailing list