[Home]BasicGTSurfer

Robo Home | Changes | Preferences | AllPages

Showing revision 6
This code is based largely on BasicSurfer, but with a few tricks that make it surf GoTo? style. I've seen several people say they want to try GoTo? surfing, and I seem to have made a strong (ie bug free) implementation, so I'll give back some of what I've learned =).

OK, an explanation of the changes (and additions) I made to BasicSurfer to get BasicGTSurfer:

The most important were changing the precise prediction, the checkDanger, adding a getBestPoint? method, and (obviously) adding a goTo method.

For the precise prediction, I modified it so that, instead of returning a single point, it returns an ArrayList of all the predicted points that the bot covered. Another important part is removing the last point of the prediction, because we have to remember that we need to be stopped by the time the wave hits us. If we left the last point, the bot would decelerate as it approached the point, and we wouldn't get there in time. Thus, the last point has to go.

Then next change is quite simple. We change the checkDanger method to take a point as a parameter, instead of a direction. This actually simplifies the checkDanger method, because it now has nothing to do with the PrecisePrediction.

Adding the getBestPoint? method is probably the most complicated. It takes an EnemyWave as an argument. Let me explain what this method does (though I think the source code is fairly clear): First we check if we have already generated points to go to. If not, we call the precise prediction, in each direction, and store the points. We go though each point and find which has the lowest danger. We then know that you need to go in the direction of that point, so we discard the points from the other direction. We also discard the points that are further than this 'safe point'. (As an implementation decision, I stored this ArrayList of points in the EnemyWave, but you could easily store it as a class object.) We then need to decide which point to return to feed the 'goTo' method. If the point is less than 20 pixels away from our current position, we won't reach top speed (8 + 6 + 4 + 2 = 20). So we loop through the ArrayList of points, and find one that is more than 20 pixels away, which we return. If there isn't a point 20 pixels away, we return the last point, which is the safe point we decided on earlier. And that is the most complicated piece of code that I added!

The goTo method is completely standard, but be careful about using the ones that decrease your speed as you go around corners. Our precise prediction doesn't do this, so neither should our goTo method.

Other small changes were:

Things which should still be implemented in a competitive goTo surfer:

-- Skilgannon

Comments

Very nice. It looks like there's still lots of room for improvements, which is impressive given DrussGT's strength in the rumble. I do plan to try my hand at this somewhere along the way, thank you for the jump start! -- Simonton

Hey Skilgannon, what is the difference between go-to direct to that position and go-to for every 20px? --Nat


Robo Home | Changes | Preferences | AllPages
Edit revision 6 of this page | View other revisions | View current revision
Edited February 28, 2009 12:37 EST by Nat (diff)
Search: