Talk:FuturePosition
|
From old wiki
Way cool. I have seen a discussion about this somewhere else, but no solution. Yet, could you enlighten us about when this could be useful? AntiMirrorTargeting comes to mind, is that correct? -- PEZ
I'm experimenting with two ideas that need it: first one is DodgingBullets (coded a prototype that makes FloodMicro to score 0.3 hits in average per round), second one is to build a SandBoxFlattener with pattern repetition avoidance. Right now, none of them works as expected :-( Anyway, I think there can be lots of uses for it, and it's this kind of basic routine that speeds up development (Robocode is much funnier if you can test your ideas without spending much time programming). Also, another use that comes to my mind is to avoid collitions between team mates in a team competition -- Albert
Wow. I'm impressed; this code seems to handle wall collisions and everything. Back when I had the good old SineSweep, I had a class similar to this, but it didn't do wall collisions and IIRC it didn't do acceleration properly. Nonetheless, since it rarely changed acceleration, it could predict it's future position with like 99.9999999% accuracy, and before shooting it's gun it always checked to make sure it was within a millionth of a degree of where it predicted it should be; any less accurate would risk missing the bullet interception. This plus it's mathematical algorithm for intersecting the bullet trails at their midpoints made for an extremely complicated robot framework because the gunning and movement were so integrated. I can't wait for summer so I can start rebuilding it... -- Vuen
I know I need to use this, but I am trying to figure where and how, it figures where I am going to be according to my set turn and ahead? -- AvihooI
If using a targeting method that tries to predict where the opponent will be in order to hit him with a bullet, you need to simulate their predicted movement within the constraints of the Robocode engine. Similarly if you are trying to predict where your movement will take you so that you don't run into walls, robots, or anticipated bullet trajectories, you will need the same tool. I don't use this code, but I made my own version, and I use it for the prediction I described. -- Martin
Yep, what he said. I only use it for WaveSurfing, predicting several movement options and finding exactly where I'd be when the bullet hits me (if it would hit me). The simple way to use it is, like you said, to use setAhead, setBack, and/or setTurnXXX, and then call _instanceOfMoveSim.futurePos(steps, _robot); that returns an array of MovSimStat objects, indexed zero (next tick) to steps-1 (steps ticks in future). Here's a pretty simple code snippet that is a good example:
public static double nextY(AdvancedRobot robot) {
if (moveSimulator == null) {
moveSimulator = new MovSim();
}
MovSimStat[] next = moveSimulator.futurePos(1, robot);
return next[0].y;
}
When you do setXXX a second time, it overwrites whatever you did the first time. I also made that last method "public", and interact with it directly, because there are certain things I recalculate each tick (like WallSmoothing and distancing). Beware that the heading and turn rate (w) are in radians. -- Voidious
Ok, it seems that this allows me to create some sort of continuous movement by checking where I am going to be, and adjust my movement if I don't like it. Now that I think about it, it's much more logical this way because I can't be mistaken about my movement, I'd just keep checking it until I am satisfied, ohh and just for the record, I prefer to use Radians in any case. -- AvihooI
Really, really handy. Thanks for putting in all the extra work so the rest of us don't have to. For the record, I hate java coding standards. Line breaks and aligned parenthesis make everything so much easier to read. What's with the fear of whitespace these days? Oh well, I guess that's just me. Again, very nice work. --Speal
Nice code, I just ran a test of it on a surfer I have in the works (not seraphim who is still running a badly written version of my own(which may explain its ranking)), but i'm sure I got something wrong. I'm attempting to use it on a go-To surfer type deal, so I am directly calling the last method. I have a question, for the distanceRemaining, what would be the value to put there? I am currently using 100. Also how do you get it to correctly map a oribit, I use the angleToEnemy+Math.PI/2 and angleToEnemy-Math.PI/2 for both the heading and angleToTurn (I tried others but it didn't work as well as this has so far) for each direction. --Chase-san
Well, one thing noteworthy about this code is that you can just pass it an AdvancedRobot and have it predict the position based on the commands currently given to the robot with the setXXX methods. The "distance remaining" would be the distance the robot still has to travel until it has completed its movements and comes to a stop; it should be negative if you're moving backwards and positive if you're not. The heading is your current heading, and the "amount to turn" would be (angle you want to move at - your current heading), all in radians. In the current Dookious, you could look at my usage in /voidious/utils/DUtils.java, it should be relatively clear and is definitely correct. -- Voidious
Yah, I noticed when I got home that I had that exact file up, I was searching through your code looking for how dookious used MovSim, I had to break off my saerch for it early for class. However, I wanted to know the best distanceREmaining for prediction multiple turns into the future, as so I can get the positions leading up to when the closest wave would hit. --Chase-san
I just use 1000 or -1000, it would tick 125+ ticks to go that far and it doesn't matter how big it is. -- Voidious
Well, I made a version of this that has built in smoothing (via Voidious' method), however it seems to not work for the left side(which may be due to shortcuts I took in simplifing the method, but I doupt this). But at any rate, now I need to tell the bot how to orbit with a combination of TurnAngle and the maxTurnAngle. --Chase-san
- [View source↑]
- [History↑]