# GJR

Robo Home | Changes | Preferences | AllPages

I'm a robocode newbie, trying to remember my high-school trig. :-)

welcome to the wiki. --deathcon

#### Questions

I have a question already. I'm working on putting anti-gravity movement into one of my test bots. I think I've got the basics working, but my bot seems to like to run into walls, and then stay there - despite the walls having repulsive force. This happens even in one-on-one: my bot will sometimes run away from the enemy until it hits a wall, and then stay there for the rest of the round. Can anyone tell me where my error is? The code below is from my run method.

```...
while(true) {
Iterator keys = enemies.keySet().iterator();
double xForce = 0.0;
double yForce = 0.0;
while( keys.hasNext() ) {
Enemy enemy = (Enemy) enemies.get(keys.next());

}

execute();
}
...
```

• Welcome to the wiki, GJR. As far as I can tell your robot does not reverse when it hits a wall. That is why it sticks. The reason you run into the wall in the first place is probably because the turn your bot wants to make to avoid the wall is not sharp enough. You could fix this by increasing the repulsive force of the walls, or by reducing speed when near a wall. But, of course I've never seen your robot in action, so this is just an (un)educated guess after seeing the code. Cheers. --Vic

• It turns out the problem was in my code that calculates the position of the enemies, and not in the code above. --GJR

• You should try Minimum Risk Movement, it gave me better results then my anti-gravity ever did, though the theory of them are very simular. (point calculations seem to give better results and themsleves can be used to avoid the walls). Don't worry about the trig, if your robocoding, you'll be a expert in no time. -- Chase-san

Robo Home | Changes | Preferences | AllPages