Re: Multithreading and Variables Question About Robocode

fnl <[email protected]> Thu, 9 Jun 2016 13:38:48 -0700 (PDT)
Newsgroups gmane.comp.java.robocode
Message-ID <[email protected]>
Robocode keeps a queue for each robot with the "intents" from commands like 
setAhead(), setTurnLeft(), setFire() etc. but it if multible setAhead() 
commands are fired within the same turn, the last setAhead() counts.

So if multiple threads are involved in sending commands like setAhead() 
etc. these will be put into the robot queue in the order they occur based 
on the time.

Please notice that Robocode divides movement into velocity, direction for 
body, direction for gun, direction for radar.
So if two threads both give instructions for a new velocity (e.g. one 
calling setAhead(50) and another setBack(7)), the thread gets to write its 
instruction in the queue, as the last one, will gets its velocity 
instruction executed.

Hence, you will need to figure out a way to avoid raise conditions.

I recommend that you have one thread responsible for all movement of the 
tank - period.
Other threads should have other tasks like e.g. figure out where to aim the 
gun, pick out a new target, avoid collisions etc.

Cheers,
- Flemming

Den torsdag den 9. juni 2016 kl. 19.11.43 UTC+2 skrev David Hsieh:
>
> Hi! If you implement multithreading in Robocode, what happens if the two 
> parts of your code that are involved contradict each other in some way? 
> What would happen if one part told the robot to move one way, and the other 
> part of the code told it to move a different way? Would the processes occur 
> simultaneously as usually happens in multithreading, and if so how?
>
> For my second question, how do you carry information over between rounds? 
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.