-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
118 lines (99 loc) · 5.06 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html>
<head>
<title>Robo Duel</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
<link href='http://fonts.googleapis.com/css?family=Iceland' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<script src="lib/jquery-1.8.3.min.js"></script>
<script src="lib/underscore.js"></script>
<script src="http://www.parsecdn.com/js/parse-1.2.2.min.js"></script>
<script src="lib/backbone.js"></script>
<script src="peg/roboParser.js"></script>
<script src="js/interpret.js"></script>
<script src="js/robot.js"></script>
<script src="js/robotCollection.js"></script>
<script src="js/missile.js"></script>
<script src="js/missileCollection.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<div class="main">
<div class="topbar">
<span class="navitem logic"><a href="http://logicmason.com">Site Home</a></span>
<span class="navitem instructions">Instructions</span>
<span class="navitem addRobot">Create Robot</span>
<span class="navitem loadRobot">Load Robot</span>
<span class="navitem loadEnemy">Load Enemy</span>
<span class="navitem start">Start Duel</span>
</div>
<div class="arena"></div>
<div class="rightbar"></div>
</div>
<div class="loader">
<h3></h3>
<input type="text" value="" class="botsearch"/>
<ul></ul>
</div>
<div class="help">
<h1>Robo Duel Instructions</h1>
<h2>Code a mighty dueling robot!</h2>
<ul>
<li>Robots start with 500hp and fight until one is dead and the other is victorious</li>
<li>Robots are programmed with a script that they execute again and again in a loop</li>
<li>You can name and save your robots and fight them against your friends' robots </li>
</ul>
<h3>Each robot understands the following commands</h3>
<ul>
<li><strong>move</strong>: moves the robot forward</li>
<li><strong>right</strong>: turns the robot clockwise by 1/3 of a degree</li>
<li><strong>left</strong>: turns the robot counter-clockwise by 1/3 of a degree</li>
<li><strong>idle</strong>: does nothing</li>
<li><strong>fire</strong>: fires a missile</li>
<li><strong>set</strong>: sets a variable to a value. The command <code>set num:5</code> will define a variable named <em>num</em> and store the value 5 for later use.</li>
<li><strong>locateSelf</strong>: loads its position and direction into memory as x, y and dir (see examples below)</li>
<li><strong>locateEnemy</strong>: loads enemy's position and direction into memory as ex, ey and edir (see examples below)</li>
</ul>
<h3>Robocode has the following features:</h3>
<p><strong>check</strong>: checks some condition and then does one thing if it's true or another thing if it's not true.</p>
<pre><code>locateSelf
check (dir > 180)
yes:fire
no:right
</code></pre>
<p>The above block of code will do the following:
<br/>
<ol><li> Run locate self, which sets <strong>x</strong> to the robot's current x position, <strong>y</strong> to its current y position and <strong>dir</strong> to its current direction (in degrees). Later commands can now use <strong>x</strong>, <strong>y</strong> and <strong>dir</strong>.
</li>
<li> check to see if the direction it's pointing towards is > 180 degrees (i.e. downward)</li>
<li> If it's pointing downward, it will fire</li>
<li> Otherwise the robot will turn clockwise.</li></ol></p>
<p><strong>do</strong>: Do starts a loop of commands. It's useful with <strong>check</strong>.</p>
<pre><code>check (something = someotherthing)
yes: do (fire fire fire fire)
no: do (left move)
</code></pre>
<p>The above code will check some condition, and if it's true the robots next four actions will be to fire. If not, the robot will turn left and move.</p>
<h3>Logical conjuctions: "and", "or"</h3>
<p>Some condition <strong>and</strong> some other condition will return true only if <em>both</em> conditions are true.
<br/>Some condition <strong>or</strong> some other condition will return true if <em>either</em> of them are true.</p>
<pre><code>locateEnemy
check (edir > 170 and edir < 190)
yes: move
no: idle
</code></pre>
<p>is the same as...</p>
<pre><code>locateEnemy
check (edir > 170)
yes: check (edir < 190)
yes: move
no: idle
no: idle
</code></pre>
<p>Both of the above snippets will load in the enemy's location and direction and then fire only if the enemy is pointing almost straight up. The execution is the same, but code with <strong>and</strong>s or <strong>or</strong>s is much more readable than nested <strong>check</strong> statements.</p>
<h3>Mathematical operators in RoboCode</h3>
<p>The basic operations are available + - * / for addition, subtraction, multiplication and division. You can also use % for modulous (getting the remainder of a division answer). For example 10 % 3 will return 1 since one is the remainder of 10 / 3.</p>
<p>The order of operations is the same as in arithmetic (multiplication before addition, etc...) and you can use parenthesis to change the order.
<br/><code>1 + 2 * 4 == 9</code><br/>However...<br/><code>(1 + 2) * 4 == 12</code></div>
</body>
</html>