[Pogamut-list] Fwd: Fwd: Logic Exception
Jakub Gemrot
jakub.gemrot at gmail.com
Mon Jul 11 19:30:44 CEST 2011
Hi!
The problem is, that the "belief base", that is "WorldView" object of
the bot does not get updated while
you are in the logic. That is done in order for you as a user to be
spared of inconsistencies which
may otherwise arise.
You must not write busy-waiting while-cycles like that. If you wish to
wait till the opponent gets to your field of view,
you have to create a "state" (something like ...
WAITING_FOR_ENEMY_TO_APPEAR) and if you are in this
state then check this players.getNearestVisibleEnemy().
That is ... logic() method must not contain busy-waiting as that gets
you nowhere. Instead, you have to
remember what you want to achieve and check it in the next iteration
of the logic.
Does it help?
Cheers!
Jakub
2011/7/11 Sören Dierkes <soeren.dierkes at informatik.uni-oldenburg.de>:
> Maybe Im not.
> I rewrote it and now I am caught in an infinite loop.
> I don't know why I fail at such a simple method, but it doesn't work.
> The method looks like this:
>
> protected void stateHit() {
> log.info("Decision is: HIT");
> if (oldAction != Action.GET_ATTACKED) {
> while(players.getNearestVisibleEnemy() != null) {
> getAct().act(new Rotate(2000,"left"));
> }
> oldAction = Action.GET_ATTACKED;
> }
> }
>
> Is there any mistake?
>
> Thanks
> Sören
>
> _______________________________________________
> Pogamut-list mailing list
> Pogamut-list at amis.mff.cuni.cz
> https://artemis.ms.mff.cuni.cz/mailman/listinfo/pogamut-list
>
>
More information about the Pogamut-list
mailing list