<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://robowiki.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%2FMovement%2FRandom</id>
	<title>Module/Movement/Random - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://robowiki.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%2FMovement%2FRandom"/>
	<link rel="alternate" type="text/html" href="http://robowiki.net/w/index.php?title=Module/Movement/Random&amp;action=history"/>
	<updated>2026-04-23T10:38:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>http://robowiki.net/w/index.php?title=Module/Movement/Random&amp;diff=16783&amp;oldid=prev</id>
		<title>RednaxelaBot: Using &lt;syntaxhighlight&gt;.</title>
		<link rel="alternate" type="text/html" href="http://robowiki.net/w/index.php?title=Module/Movement/Random&amp;diff=16783&amp;oldid=prev"/>
		<updated>2010-07-01T08:29:23Z</updated>

		<summary type="html">&lt;p&gt;Using &amp;lt;syntaxhighlight&amp;gt;.&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 08:29, 1 July 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;pre&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;syntaxhighlight&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;package jab.movement;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;package jab.movement;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l92&quot; &gt;Line 92:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 92:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;pre&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;syntaxhighlight&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>RednaxelaBot</name></author>
		
	</entry>
	<entry>
		<id>http://robowiki.net/w/index.php?title=Module/Movement/Random&amp;diff=1967&amp;oldid=prev</id>
		<title>Jab: Module movement Random</title>
		<link rel="alternate" type="text/html" href="http://robowiki.net/w/index.php?title=Module/Movement/Random&amp;diff=1967&amp;oldid=prev"/>
		<updated>2008-03-23T22:57:26Z</updated>

		<summary type="html">&lt;p&gt;Module movement Random&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
package jab.movement;&lt;br /&gt;
&lt;br /&gt;
import java.awt.geom.Point2D;&lt;br /&gt;
import java.awt.geom.RoundRectangle2D;&lt;br /&gt;
&lt;br /&gt;
import robocode.util.Utils;&lt;br /&gt;
&lt;br /&gt;
import jab.Module;&lt;br /&gt;
import jab.Movement;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Credits&lt;br /&gt;
 * This code is released under the RoboWiki Public Code License (RWPCL),&lt;br /&gt;
 * RandomMovementBot, by PEZ. Demonstrating a simple, extensible&lt;br /&gt;
 * way to go about random 1v1 movement.&lt;br /&gt;
 */&lt;br /&gt;
public class Random extends Movement {&lt;br /&gt;
&lt;br /&gt;
	public Random(Module bot) {&lt;br /&gt;
		super(bot);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	private static final double MAX_VELOCITY = 8;&lt;br /&gt;
	private static final double WALL_MARGIN = 25;&lt;br /&gt;
	private double movementLateralAngle = 0.2;&lt;br /&gt;
&lt;br /&gt;
	public void move() {&lt;br /&gt;
		considerChangingDirection();&lt;br /&gt;
		Point2D robotDestination = null;&lt;br /&gt;
		double tries = 0;&lt;br /&gt;
		do {&lt;br /&gt;
			robotDestination = vectorToLocation(absoluteBearing(&lt;br /&gt;
					new Point2D.Double(bot.enemy.x, bot.enemy.y),&lt;br /&gt;
					new Point2D.Double(bot.getX(), bot.getY()))&lt;br /&gt;
					+ movementLateralAngle, bot.enemy.distance&lt;br /&gt;
					* (1.1 - tries / 100.0), new Point2D.Double(bot.enemy.x,&lt;br /&gt;
					bot.enemy.y));&lt;br /&gt;
			tries++;&lt;br /&gt;
		} while (tries &amp;lt; 100&lt;br /&gt;
				&amp;amp;&amp;amp; !fieldRectangle(WALL_MARGIN).contains(robotDestination));&lt;br /&gt;
		goTo(robotDestination);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	private void considerChangingDirection() {&lt;br /&gt;
		// Change lateral direction at random&lt;br /&gt;
		// Tweak this to go for flat movement&lt;br /&gt;
		double flattenerFactor = 0.05;&lt;br /&gt;
		if (Math.random() &amp;lt; flattenerFactor) {&lt;br /&gt;
			movementLateralAngle *= -1;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	private RoundRectangle2D fieldRectangle(double margin) {&lt;br /&gt;
		return new RoundRectangle2D.Double(margin, margin, bot&lt;br /&gt;
				.getBattleFieldWidth()&lt;br /&gt;
				- margin * 2, bot.getBattleFieldHeight() - margin * 2, 75, 75);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	private void goTo(Point2D destination) {&lt;br /&gt;
		double angle = Utils.normalRelativeAngle(absoluteBearing(&lt;br /&gt;
				new Point2D.Double(bot.getX(), bot.getY()), destination)&lt;br /&gt;
				- bot.getHeadingRadians());&lt;br /&gt;
		double turnAngle = Math.atan(Math.tan(angle));&lt;br /&gt;
		bot.setTurnRightRadians(turnAngle);&lt;br /&gt;
		bot.setAhead(new Point2D.Double(bot.getX(), bot.getY())&lt;br /&gt;
				.distance(destination)&lt;br /&gt;
				* (angle == turnAngle ? 1 : -1));&lt;br /&gt;
		// Hit the brake pedal hard if we need to turn sharply&lt;br /&gt;
		bot.setMaxVelocity(Math.abs(bot.getTurnRemaining()) &amp;gt; 33 ? 0&lt;br /&gt;
				: MAX_VELOCITY);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	private static Point2D vectorToLocation(double angle, double length,&lt;br /&gt;
			Point2D sourceLocation) {&lt;br /&gt;
		return vectorToLocation(angle, length, sourceLocation,&lt;br /&gt;
				new Point2D.Double());&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	private static Point2D vectorToLocation(double angle, double length,&lt;br /&gt;
			Point2D sourceLocation, Point2D targetLocation) {&lt;br /&gt;
		targetLocation.setLocation(sourceLocation.getX() + Math.sin(angle)&lt;br /&gt;
				* length, sourceLocation.getY() + Math.cos(angle) * length);&lt;br /&gt;
		return targetLocation;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	private static double absoluteBearing(Point2D source, Point2D target) {&lt;br /&gt;
		return Math.atan2(target.getX() - source.getX(), target.getY()&lt;br /&gt;
				- source.getY());&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jab</name></author>
		
	</entry>
</feed>