[Commit] RRbot RicochetRecursive.java,1.1,1.2

Christian L. Platt commit at keithp.com
Tue Jun 10 00:31:04 PDT 2003


Committed by: plattc

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

Modified Files:
	RicochetRecursive.java 
Log Message:
Modified stop list removal section int IDAstr().  Seems to fix problem.  
We now generate fast optimal solutions.


Index: RicochetRecursive.java
===================================================================
RCS file: /local/src/CVS/RRbot/RicochetRecursive.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- RicochetRecursive.java	10 Jun 2003 06:03:19 -0000	1.1
+++ RicochetRecursive.java	10 Jun 2003 06:31:01 -0000	1.2
@@ -129,7 +129,17 @@
                     solutionFound( newMoves );
                 }
                 //calculate h for new node
-                h = (int) (1.5 * distMatrix[robMatrixPos][goalMatrixPos]);
+                //h = (int) (1.5 * distMatrix[robMatrixPos][goalMatrixPos]);
+                h =  distMatrix[robMatrixPos][goalMatrixPos];
+
+
+                if ( g + h > maxDepth ) {
+                    board.takeBackMove ( robots[i], oldRow, oldCol, robots[i].rpos()
+                            , robots[i].cpos() );
+                    continue;
+                }
+
+
                 //create a new node
                 newNode = new Node( g, h, newMoves );
                 // store robot's positions in the new node
@@ -144,7 +154,7 @@
                     return rc;
                 }
               */ 
-                
+               
                 Long zkey = stopT.getKey( robots );
                 Node old = (Node) stopT.get( zkey );
                 boolean prune = 
@@ -157,19 +167,24 @@
                             , robots[i].cpos() );
                     continue;
                 }
-                if ( old != null ) {
-                    removedNodes++;
-                    stopT.remove(zkey);
-                } else { 
+                //if ( old != null ) {
+                    //removedNodes++;
+                    //stopT.remove(zkey);
+                //} else { 
+
                     IDAstar( curDepth, maxDepth, newNode );
+
                     stopT.put( zkey, newNode );
-                }
+                //}
+
               
                 // undo the move
                 board.takeBackMove ( robots[i], oldRow, oldCol, robots[i].rpos()
                         , robots[i].cpos() );
             }
         }
+        //Long zkey = stopT.getKey( robots );
+        //stopT.put( zkey, newNode );
         return 0;
     }
 




More information about the Commit mailing list