Commit 27f0aae5 authored by nachtgold's avatar nachtgold Committed by Hubert Denkmair
Browse files

doc is improved according to the current demo bot

parent 3f8b9d45
--- This is a brief overview of all usable functions within the bot logic.
--- Main cycle
-- Run is executed each frame.
-- @param current_heading first parameter
-- @usage function run(current_heading)
-- return (current_heading + 45) % 360
--- That method is called each frame.
-- Here you can implement you bot logic. The return value must be an radiant angle.
-- A negative angle means turn left and a positive angle
-- means turn right. With 0, the snake keeps its direction.
-- @return new angle relative to the head direction
-- @usage function step()
-- return 45
-- end
function run(current_heading)
x = 2
for n=1,x do
current_heading = current_heading + api:get_rotation_speed()
end
return current_heading
function step()
return 45
end
--- API #1
-- @return allowed rotation speed by the game engine
-- @usage local x = current_heading + api:get_rotation_speed()
function api:get_rotation_speed()
--- That method returns all food as list.
-- @param max_distance all food within the distance is included
-- @param minimum_food_value all lower food values are filtered (min: 0, max: unknown)
-- @usage local food = findFood(max_distance, 0.8)
-- for i, item in food:pairs() do
-- item.d -- angle in radian
-- item.dist -- distance
-- end
function findFood(max_distance, minimum_food_value)
end
--- That method returns all segments of all snakes within a certain radius as list.
-- All attributes of each item in the segments list are measured between the center of your head the the center of the item center.
-- @param max_distance all segements within that distance are included
-- @param include_own If true, your snake segments are included. Otherwise you get only enemy segments
-- @usage local segments = findSegments(50.0, false)
-- for i, item in segments:pairs() do
-- item.d -- angle in radian
-- item.r -- radius of the item
-- item.dist -- distance
-- item.bot -- id of the other snake
-- end
function findSegments(max_distance, include_own)
end
\ No newline at end of file
......@@ -27,13 +27,16 @@
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#run">run (current_heading)</a></td>
<td class="summary">Main cycle
Run is executed each frame.</td>
<td class="name" nowrap><a href="#step">step ()</a></td>
<td class="summary">That method is called each frame.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#api:get_rotation_speed">api:get_rotation_speed ()</a></td>
<td class="summary">API #1</td>
<td class="name" nowrap><a href="#findFood">findFood (max_distance, minimum_food_value)</a></td>
<td class="summary">That method returns all food as list.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#findSegments">findSegments (max_distance, include_own)</a></td>
<td class="summary">That method returns all segments of all snakes within a certain radius as list.</td>
</tr>
</table>
......@@ -42,18 +45,48 @@
<dl class="function">
<dt>
<a name = "run"></a>
<strong>run (current_heading)</strong>
<a name = "step"></a>
<strong>step ()</strong>
</dt>
<dd>
That method is called each frame.
Here you can implement you bot logic. The return value must be an radiant angle.
A negative angle means turn left and a positive angle
means turn right. With 0, the snake keeps its direction.
<h4>Returns:</h4>
<ol>
new angle relative to the head direction
</ol>
<h4>Usage:</h4>
<ul>
<pre class="usage"><code class="lua"> <span class="keyword">function</span> step()
<span class="keyword">return</span> <span class="number">45</span>
<span class="keyword">end</span></code></pre>
</ul>
</dd>
<dt>
<a name = "findFood"></a>
<strong>findFood (max_distance, minimum_food_value)</strong>
</dt>
<dd>
Main cycle
Run is executed each frame.
That method returns all food as list.
<h4>Parameters:</h4>
<ul>
<li><code>current_heading</code>
first parameter
<li><code>max_distance</code>
all food within the distance is included
</li>
<li><code>minimum_food_value</code>
all lower food values are filtered (min: 0, max: unknown)
</li>
</ul>
......@@ -62,32 +95,45 @@
<h4>Usage:</h4>
<ul>
<pre class="usage"><code class="lua"> <span class="keyword">function</span> run(current_heading)
<span class="keyword">return</span> (current_heading + <span class="number">45</span>) % <span class="number">360</span>
<span class="keyword">end</span></code></pre>
<pre class="usage"><code class="lua"> <span class="keyword">local</span> food = findFood(max_distance, <span class="number">0.8</span>)
<span class="keyword">for</span> i, item <span class="keyword">in</span> food:<span class="global">pairs</span>() <span class="keyword">do</span>
item.d <span class="comment">-- angle in radian
</span> item.dist <span class="comment">-- distance
</span> <span class="keyword">end</span></code></pre>
</ul>
</dd>
<dt>
<a name = "api:get_rotation_speed"></a>
<strong>api:get_rotation_speed ()</strong>
<a name = "findSegments"></a>
<strong>findSegments (max_distance, include_own)</strong>
</dt>
<dd>
API #1
That method returns all segments of all snakes within a certain radius as list.
All attributes of each item in the segments list are measured between the center of your head the the center of the item center.
<h4>Returns:</h4>
<ol>
<h4>Parameters:</h4>
<ul>
<li><code>max_distance</code>
all segements within that distance are included
</li>
<li><code>include_own</code>
If true, your snake segments are included. Otherwise you get only enemy segments
</li>
</ul>
allowed rotation speed by the game engine
</ol>
<h4>Usage:</h4>
<ul>
<pre class="usage"><code class="lua"><span class="keyword">local</span> x = current_heading + api:get_rotation_speed()</code></pre>
<pre class="usage"><code class="lua"> <span class="keyword">local</span> segments = findSegments(<span class="number">50.0</span>, <span class="keyword">false</span>)
<span class="keyword">for</span> i, item <span class="keyword">in</span> segments:<span class="global">pairs</span>() <span class="keyword">do</span>
item.d <span class="comment">-- angle in radian
</span> item.r <span class="comment">-- radius of the item
</span> item.dist <span class="comment">-- distance
</span> item.bot <span class="comment">-- id of the other snake
</span> <span class="keyword">end</span></code></pre>
</ul>
</dd>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment