Talk:GravityWave/Versions

From Robowiki
< Talk:GravityWave
Revision as of 00:27, 13 June 2009 by J Litewski (talk | contribs) (→‎Future Position: My painful attempt (includes code))
Jump to navigation Jump to search

Future Position

I use Future Position in Dookious and Diamond. I just made the main simulation method public, so I can change movement tick by tick (as one needs to in simulating Wave Surfing), then some additional wrapper methods in DUtils and DiaUtils, if you want to take a look. --Voidious 20:25, 12 June 2009 (UTC)

I did, which is where I got the idea. I'm just having problems making it work. --Jacob Litewski 21:02, 12 June 2009 (UTC)
Ah, ok... Well, I was hoping my more readable wrapper code would make it more clear how it works. =) Any specific questions? A MovSim represents a robot state at a point in time, basically get one of those back from the simulator and use it as input for the next tick's simulation... --Voidious 22:19, 12 June 2009 (UTC)
I made a Point2D.Double function that calls the MovSim and returns the projected x and y fine. It's just then getting it to work like the function in BasicSurfer. This is how it's set up:
public Point2D.Double predictPosition(AdvancedRobot _robot, int future) {
	if (moveSimulator == null) { moveSimulator = new MovSim(); }
	System.out.println(future);
	if(future <= 0) { future = 1; }
	
	MovSimStat[] next = moveSimulator.futurePos(future, _robot); //predict into the future
	Point2D.Double nextPosition = new Point2D.Double(next[future-1].x, next[future-1].y);
	
	return nextPosition;
}

Now I know this is the problem, this is how I call it:

int index = getFactorIndex(surfWave,
            predictPosition(this, 1));

I'm thinking I'm going to need to write a new getFactorIndex to better suit the MovSim function. I'm not sure though. --Jacob Litewski 23:27, 12 June 2009 (UTC)