Discussion:
Wall Smoothing With Random Movement
David Hsieh
2016-06-10 17:46:45 UTC
Permalink
Hi guys! Can someone tell me how this Simple Iterative Wall Smoothing by
PEZ works, statement by statement? I also want to integrate it into random
movement, so can someone provide details on how that would be implemented?
The wall smoothing code below by PEZ is also used for random movement in
other bots.
*static* *double* direction; *//1 for clockwise or -1 for counterclockwise*
...
*// this is the absolute heading I want to move in to go clockwise or*
*// counterclockwise around my enemy if I want to move closer to them,*
*// I would use less of an offset from absBearing (I'll go right toward*
*// them if I move at absBearing)*
*double* goalDirection = absBearing-*Math*.PI/2*direction;
*Rectangle2D* fieldRect = *new* *Rectangle2D.**Double*(18, 18,
getBattleFieldWidth()-36,
getBattleFieldHeight()-36);
*while* (!fieldRect.contains(getX()+*Math*.sin(goalDirection)*120, getY()+
*Math*.cos(goalDirection)*120))
{
goalDirection += direction*.1; *//turn a little toward enemy and try again*
}
*double* turn =
robocode.util.Utils.normalRelativeAngle(goalDirection-getHeadingRadians(
));
*if* (*Math*.abs(turn) > *Math*.PI/2)
{
turn = robocode.util.Utils.normalRelativeAngle(turn + *Math*.PI);
setBack(100);
}
*else*
setAhead(100);
setTurnRightRadians(turn);
--
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 robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...