Courses‎ > ‎AP Computer Science 2‎ > ‎konstantinovich‎ > ‎

### 2018-05-14

posted May 14, 2018, 6:19 AM by Konstantinovich Samuel   [ updated May 14, 2018, 11:28 AM ]
 You should have 3 modes for your solve:Depth First Breadth First Best-FirstAdding A* is now very easy:+Your maze needs a toggle    setAStar(boolean)   -default is false.+Your maze can calculate the distance by including how many steps have already been taken in addition to the distance to the goal.Either:   -add an extra variable to each node (distanceSoFar) which is always 1 larger than the previous node's distanceSoFar.   -calculate it each time by seeing how many previous nodes you have to visit before you reach the start    (caution this is linear counting but based on distance to start, not based on total nodes in most cases)+When setAStar is true, the maze includes the distanceSoFar when calculating the distance variable for each constructed node. Sample maze that tests A* versus Best First:  (best first goes the long way)##########     S### ####  ## ##### ##   ### ## #  E# ##  ###  ###     ###########