Little Problem...

Post Reply
DJSigmund
Posts: 6
Joined: Thu Mar 19, 2009 10:24 pm
Location: Munich
Contact:

Little Problem...

Post by DJSigmund »

Hey Folks,

I've got a little Problem with my Bot, for it ignores my instructions...

Could you just please check if the following line are OK?

Code: Select all

class AristoWorm
{
public static int[][]$offsets ={{1,0},{0,-1},{-1,0},{0,1}};
public int think(int $dx, int $dy, int[][]$board, int $x, int $y, int $dir, int[][]$enemies)
	{

Code: Select all

int $my_direction = $dir;

Code: Select all

return $my_direction;
	}
}
I#M switching $my_direction multiple times and have some elementrs fo the wall avoider included, so I guess that something in the above lines is not right...
If you were MEANT to understand it, we wouldn't have called it code
Karian
Posts: 75
Joined: Wed Jan 09, 2008 10:21 am

Post by Karian »

I just compiled the code you have given and it seems to compile fine. I can even play a bit with my_direction and get it to respond accordingly. Although maybe it is best to make your class public, then you can also run it natively.

Are you sure that your code really does what it should do? Be sure to check the console while running the simulator to see if you aren't generating any errors. Some commands (like print/println) aren't allowed in the simulator, and if your function fails, he will take a default direction.

If you want to generate output to the console, you have to check the run natively in the bot simulator (and make your class public). Then you can use prints to check if your code is really doing what you think it is, but don't forget to remove those while compiling the final version, because else, your bot will keep going to the right, because of the generated errors.
DJSigmund
Posts: 6
Joined: Thu Mar 19, 2009 10:24 pm
Location: Munich
Contact:

Post by DJSigmund »

Thank you for the quick help, I'll try that later -->work ;)
If you were MEANT to understand it, we wouldn't have called it code
Post Reply