Commit ed14adaf authored by Hubert Denkmair's avatar Hubert Denkmair
Browse files

Merge branch 'master' of git.bingo-ev.de:GPN18Programmierspiel/website

parents e3397bd6 97542e42
...@@ -30,7 +30,6 @@ INSTALLED_APPS = [ ...@@ -30,7 +30,6 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'widget_tweaks',
'core', 'core',
'visualization', 'visualization',
'ide', 'ide',
......
...@@ -19,4 +19,9 @@ ...@@ -19,4 +19,9 @@
.markdown-body dl dt { .markdown-body dl dt {
font-size: 1.2em; font-size: 1.2em;
}
table thead tr td {
background: rgb(0,0,0,.50);
font-weight: 700;
} }
\ No newline at end of file
...@@ -63,12 +63,24 @@ return [==[ ...@@ -63,12 +63,24 @@ return [==[
# for kind,items in module.kinds() do # for kind,items in module.kinds() do
<h2><a href="#$(no_spaces(kind))">$(kind)</a></h2> <h2><a href="#$(no_spaces(kind))">$(kind)</a></h2>
<table class="function_list"> <table class="function_list">
<thead>
<tr>
<td>
Function name
</td>
<td>
Description
</td>
</tr>
</thead>
<tbody>
# for item in items() do # for item in items() do
<tr> <tr>
<td class="name" $(nowrap)><a href="#$(item.name)">$(display_name(item))</a></td> <td class="name" $(nowrap)><a href="#$(item.name)">$(display_name(item))</a></td>
<td class="summary">$(M(item.summary,item))</td> <td class="summary">$(M(item.summary,item))</td>
</tr> </tr>
# end -- for items # end -- for items
</tbody>
</table> </table>
#end -- for kinds #end -- for kinds
......
...@@ -2,27 +2,96 @@ ...@@ -2,27 +2,96 @@
--- Every bot is allowed to store 100MB within the global namespace and the --- Every bot is allowed to store 100MB within the global namespace and the
--- data persists until the bot dies. So the bot can save data from frame --- data persists until the bot dies. So the bot can save data from frame
--- to frame. --- to frame.
--- <h2>Lua global namespace</h2>
--- <p>The following Lua standard functions are allowed:</p>
--- <p><a href="http://pgl.yoyo.org/luai/i/assert">assert</a>,
--- <a href="http://pgl.yoyo.org/luai/i/print">print</a>,
--- <a href="http://pgl.yoyo.org/luai/i/ipairs">ipairs</a>,
--- <a href="http://pgl.yoyo.org/luai/i/error">error</a>,
--- <a href="http://pgl.yoyo.org/luai/i/next">next</a>,
--- <a href="http://pgl.yoyo.org/luai/i/pairs">pairs</a>,
--- <a href="http://pgl.yoyo.org/luai/i/pcall">pcall</a>,
--- <a href="http://pgl.yoyo.org/luai/i/select">select</a>,
--- <a href="http://pgl.yoyo.org/luai/i/tonumber">tonumber</a>,
--- <a href="http://pgl.yoyo.org/luai/i/tostring">tostring</a>,
--- <a href="http://pgl.yoyo.org/luai/i/type">type</a>,
--- <a href="http://pgl.yoyo.org/luai/i/unpack">unpack</a>,
--- <a href="http://pgl.yoyo.org/luai/i/_VERSION">_VERSION</a>,
--- <a href="http://pgl.yoyo.org/luai/i/xpcall">xpcall</a></p>
--- <p>From the module <code>math</code> you can use:</p>
--- <p><a href="http://pgl.yoyo.org/luai/i/math.abs">abs</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.acos">acos</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.asin">asin</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.atan">atan</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.atan2">atan2</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.ceil">ceil</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.cos">cos</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.cosh">cosh</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.deg">deg</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.exp">exp</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.floor">floor</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.fmod">fmod</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.frexp">frexp</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.huge">huge</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.ldexp">ldexp</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.log">log</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.log10">log10</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.max">max</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.min">min</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.modf">modf</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.pi">pi</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.pow">pow</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.rad">rad</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.random">random</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.randomseed">randomseed</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.sin">sin</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.sinh">sinh</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.sqrt">sqrt</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.tan">tan</a>,
--- <a href="http://pgl.yoyo.org/luai/i/math.tanh">tanh</a></p>
--- <p>From the module <code>os</code> you can use:</p>
--- <p><a href="http://pgl.yoyo.org/luai/i/os.clock">clock</a>,
--- <a href="http://pgl.yoyo.org/luai/i/os.difftime">difftime</a>,
--- <a href="http://pgl.yoyo.org/luai/i/os.time">time</a></p>
--- <p>From the module <code>table</code> you can use:</p>
--- <a href="http://pgl.yoyo.org/luai/i/table.maxn">maxn</a>,
--- <a href="http://pgl.yoyo.org/luai/i/table.insert">insert</a>,
--- <a href="http://pgl.yoyo.org/luai/i/table.remove">remove</a>,
--- <a href="http://pgl.yoyo.org/luai/i/table.sort">sort</a></p>
--- <p>Every snake can describe itself with the following attributes of the global variable <code>self</code>:</p>
--- <table>
--- <thead>
--- <tr><td>Variable within self</td><td>Type</td><td>Description</td></tr>
--- </thead>
--- <tbody>
--- <tr><td>id</td><td>number</td><td>internal identifier</td></tr>
--- <tr><td>segment_radius</td><td>number</td><td>the size of the snake</td></tr>
--- <tr><td>mass</td><td>number</td><td>the weight of the snake</td></tr>
--- <tr><td>sight_radius</td><td>number</td><td>the field of view of the snake, which increases with the size of the snake</td></tr>
--- <tr><td>consume_radius</td><td>number</td><td>the field of feed of the snake, which increases with the size of the snake</td></tr>
--- <tr><td>max_step_angle</td><td>number</td><td>unknown definition</td></tr>
--- <tr><td>start_frame</td><td>number</td><td>the game frame, when the snake was born</td></tr>
--- <tr><td>current_frame</td><td>number</td><td>the current game frame</td></tr>
--- <tr><td>speed</td><td>number</td><td>default speed is 1, but it can change if a snake is using boost</td></tr>
--- <tr><td>food_consumed_natural</td><td>number</td><td>unknown definition</td></tr>
--- <tr><td>food_consumed_hunted_self</td><td>number</td><td>unknown definition</td></tr>
--- <tr><td>food_consumed_hunted_by_others</td><td>number</td><td>unknown definition</td></tr>
--- <tr><td>colors</td><td>{number}</td><td>table of colors (default color is 0x0000FF00, maximum count is 100, set is available in <a href="#init">init</a>)</td></tr>
--- <tr><td>face</td><td>number</td><td>not implemented yet (returns 0, set is available in <a href="#init">init</a>)</td></tr>
--- <tr><td>logo</td><td>number</td><td>not implemented yet (returns 0, set is available in <a href="#init">init</a>)</td></tr></tr>
--- </tbody></table>
--- 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 0.005
-- end
function step()
return 0.005
end
--- This method is called upon creation of a bot --- This function is called upon creation of a bot
-- Initialialize your environment here. -- Initialialize your environment here.
-- you can also access the "self" object here and, e.g. set your snake's colors -- You can also access the "self" module here and, e.g. set your snake's colors.
-- @usage function init()
-- self.colors = { 0xFF0000, 0xFFBF00, 0x80FF00, 0x00FF40, 0x00FFFF, 0x0015FF, 0x8000FF }
-- end
function init() function init()
self.colors = { 0xFF0000, 0xFFBF00, 0x80FF00, 0x00FF40, 0x00FFFF, 0x0015FF, 0x8000FF }
end end
--- That method returns all food as list. --- That function returns all food as list.
-- @param max_distance all food within the distance is included -- @param max_distance all food within the distance is included
-- @param minimum_food_value all lower food values are filtered (min: 0, max: unknown) -- @param minimum_food_value all lower food values are filtered (min: 0, max: unknown)
-- @usage local food = findFood(max_distance, 0.8) -- @usage local food = findFood(max_distance, 0.8)
...@@ -33,7 +102,7 @@ end ...@@ -33,7 +102,7 @@ end
function findFood(max_distance, minimum_food_value) function findFood(max_distance, minimum_food_value)
end end
--- That method returns all segments of all snakes within a certain radius as list. --- That function 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. -- 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 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 -- @param include_own If true, your snake segments are included. Otherwise you get only enemy segments
...@@ -47,7 +116,22 @@ end ...@@ -47,7 +116,22 @@ end
function findSegments(max_distance, include_own) function findSegments(max_distance, include_own)
end end
--- That method sends messages to the development console. --- That function sends messages to the development console.
-- @param message this string will be transfered to the console -- @param message this string will be transfered to the console
function log(message) function log(message)
end end
\ No newline at end of file
--- That function 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
--@return if true the snake will use boost, otherwise false or empty (optional)
-- @usage function step()
-- return 0.005
-- end
-- @usage function step()
-- return 0.005, true
-- end
function step()
end
{% extends 'core/base.html' %} {% extends 'core/base.html' %}
{% load static %} {% load static %}
{% block title %} {% block earlycss %}
<title>Docs - Schlangenprogrammiernacht 2018</title> <link rel="stylesheet" type="text/css" href="{% static "docs/github-markdown.css" %}" />
{% endblock %} {% endblock %}
{% block earlycss %} {% block css %}
<link rel="stylesheet" type="text/css" href="{% static "docs/github-markdown.css" %}" /> <link rel="stylesheet" type="text/css" href="{% static "core/highlight.js/styles/agate.css" %}" />
{% endblock %} <link rel="stylesheet" type="text/css" href="{% static "docs/docs.css" %}" />
{% endblock %}
{% block css %}
<link rel="stylesheet" type="text/css" href="{% static "core/highlight.js/styles/agate.css" %}" /> {% block js%}
<link rel="stylesheet" type="text/css" href="{% static "docs/docs.css" %}" /> <script src="{% static "core/highlight.js/highlight.pack.js" %}"></script>
{% endblock %} <script>hljs.initHighlightingOnLoad();</script>
{% endblock %}
{% block js%}
<script src="{% static "core/highlight.js/highlight.pack.js" %}"></script> {% block content %}
<script>hljs.initHighlightingOnLoad();</script>
{% endblock %} <div class="docs_container markdown-body">
{% block content %}
<h1>Bot Documentation</h1>
<div class="docs_container markdown-body">
<div id="docs_content">
<h1>Bot Documentation</h1> <p>This is a brief overview of all usable functions within the bot logic.</p>
<p>
<div id="docs_content"> Every bot is allowed to store 100MB within the global namespace and the
data persists until the bot dies. So the bot can save data from frame
<p>This is a brief overview of all usable functions within the bot logic.</p> to frame.
<p> <h2>Lua global namespace</h2>
Every bot is allowed to store 100MB within the global namespace and the <p>The following Lua standard functions are allowed:</p>
data persists until the bot dies. So the bot can save data from frame <p><a href="http://pgl.yoyo.org/luai/i/assert">assert</a>,
to frame.</p> <a href="http://pgl.yoyo.org/luai/i/print">print</a>,
<a href="http://pgl.yoyo.org/luai/i/ipairs">ipairs</a>,
<a href="http://pgl.yoyo.org/luai/i/error">error</a>,
<h2><a href="#Functions">Functions</a></h2> <a href="http://pgl.yoyo.org/luai/i/next">next</a>,
<table class="function_list"> <a href="http://pgl.yoyo.org/luai/i/pairs">pairs</a>,
<tr> <a href="http://pgl.yoyo.org/luai/i/pcall">pcall</a>,
<td class="name" nowrap><a href="#step">step ()</a></td> <a href="http://pgl.yoyo.org/luai/i/select">select</a>,
<td class="summary">That method is called each frame.</td> <a href="http://pgl.yoyo.org/luai/i/tonumber">tonumber</a>,
</tr> <a href="http://pgl.yoyo.org/luai/i/tostring">tostring</a>,
<tr> <a href="http://pgl.yoyo.org/luai/i/type">type</a>,
<td class="name" nowrap><a href="#init">init ()</a></td> <a href="http://pgl.yoyo.org/luai/i/unpack">unpack</a>,
<td class="summary">This method is called upon creation of a bot <a href="http://pgl.yoyo.org/luai/i/_VERSION">_VERSION</a>,
Initialialize your environment here.</td> <a href="http://pgl.yoyo.org/luai/i/xpcall">xpcall</a></p>
</tr> <p>From the module <code>math</code> you can use:</p>
<tr> <p><a href="http://pgl.yoyo.org/luai/i/math.abs">abs</a>,
<td class="name" nowrap><a href="#findFood">findFood (max_distance, minimum_food_value)</a></td> <a href="http://pgl.yoyo.org/luai/i/math.acos">acos</a>,
<td class="summary">That method returns all food as list.</td> <a href="http://pgl.yoyo.org/luai/i/math.asin">asin</a>,
</tr> <a href="http://pgl.yoyo.org/luai/i/math.atan">atan</a>,
<tr> <a href="http://pgl.yoyo.org/luai/i/math.atan2">atan2</a>,
<td class="name" nowrap><a href="#findSegments">findSegments (max_distance, include_own)</a></td> <a href="http://pgl.yoyo.org/luai/i/math.ceil">ceil</a>,
<td class="summary">That method returns all segments of all snakes within a certain radius as list.</td> <a href="http://pgl.yoyo.org/luai/i/math.cos">cos</a>,
</tr> <a href="http://pgl.yoyo.org/luai/i/math.cosh">cosh</a>,
<tr> <a href="http://pgl.yoyo.org/luai/i/math.deg">deg</a>,
<td class="name" nowrap><a href="#log">log (message)</a></td> <a href="http://pgl.yoyo.org/luai/i/math.exp">exp</a>,
<td class="summary">That method sends messages to the development console.</td> <a href="http://pgl.yoyo.org/luai/i/math.floor">floor</a>,
</tr> <a href="http://pgl.yoyo.org/luai/i/math.fmod">fmod</a>,
</table> <a href="http://pgl.yoyo.org/luai/i/math.frexp">frexp</a>,
<a href="http://pgl.yoyo.org/luai/i/math.huge">huge</a>,
<a href="http://pgl.yoyo.org/luai/i/math.ldexp">ldexp</a>,
<h2><a name="Functions"></a>Functions</h2> <a href="http://pgl.yoyo.org/luai/i/math.log">log</a>,
<a href="http://pgl.yoyo.org/luai/i/math.log10">log10</a>,
<dl class="function"> <a href="http://pgl.yoyo.org/luai/i/math.max">max</a>,
<dt> <a href="http://pgl.yoyo.org/luai/i/math.min">min</a>,
<a name = "step"></a> <a href="http://pgl.yoyo.org/luai/i/math.modf">modf</a>,
<strong>step ()</strong> <a href="http://pgl.yoyo.org/luai/i/math.pi">pi</a>,
</dt> <a href="http://pgl.yoyo.org/luai/i/math.pow">pow</a>,
<dd> <a href="http://pgl.yoyo.org/luai/i/math.rad">rad</a>,
That method is called each frame. <a href="http://pgl.yoyo.org/luai/i/math.random">random</a>,
Here you can implement you bot logic. The return value must be an radiant angle. <a href="http://pgl.yoyo.org/luai/i/math.randomseed">randomseed</a>,
A negative angle means turn left and a positive angle <a href="http://pgl.yoyo.org/luai/i/math.sin">sin</a>,
means turn right. With 0, the snake keeps its direction. <a href="http://pgl.yoyo.org/luai/i/math.sinh">sinh</a>,
<a href="http://pgl.yoyo.org/luai/i/math.sqrt">sqrt</a>,
<a href="http://pgl.yoyo.org/luai/i/math.tan">tan</a>,
<a href="http://pgl.yoyo.org/luai/i/math.tanh">tanh</a></p>
<h4>Returns:</h4> <p>From the module <code>os</code> you can use:</p>
<ol> <p><a href="http://pgl.yoyo.org/luai/i/os.clock">clock</a>,
<a href="http://pgl.yoyo.org/luai/i/os.difftime">difftime</a>,
new angle relative to the head direction <a href="http://pgl.yoyo.org/luai/i/os.time">time</a></p>
</ol> <p>From the module <code>table</code> you can use:</p>
<a href="http://pgl.yoyo.org/luai/i/table.maxn">maxn</a>,
<a href="http://pgl.yoyo.org/luai/i/table.insert">insert</a>,
<a href="http://pgl.yoyo.org/luai/i/table.remove">remove</a>,
<h4>Usage:</h4> <a href="http://pgl.yoyo.org/luai/i/table.sort">sort</a></p>
<ul> <p>Every snake can describe itself with the following attributes of the global variable <code>self</code>:</p>
<pre class="usage"><code class="lua"> <span class="keyword">function</span> step() <table>
<span class="keyword">return</span> <span class="number">0.005</span> <thead>
<span class="keyword">end</span></code></pre> <tr><td>Variable within self</td><td>Type</td><td>Description</td></tr>
</ul> </thead>
<tbody>
</dd> <tr><td>id</td><td>number</td><td>internal identifier</td></tr>
<dt> <tr><td>segment_radius</td><td>number</td><td>the size of the snake</td></tr>
<a name = "init"></a> <tr><td>mass</td><td>number</td><td>the weight of the snake</td></tr>
<strong>init ()</strong> <tr><td>sight_radius</td><td>number</td><td>the field of view of the snake, which increases with the size of the snake</td></tr>
</dt> <tr><td>consume_radius</td><td>number</td><td>the field of feed of the snake, which increases with the size of the snake</td></tr>
<dd> <tr><td>max_step_angle</td><td>number</td><td>unknown definition</td></tr>
This method is called upon creation of a bot <tr><td>start_frame</td><td>number</td><td>the game frame, when the snake was born</td></tr>
Initialialize your environment here. <tr><td>current_frame</td><td>number</td><td>the current game frame</td></tr>
you can also access the "self" object here and, e.g. set your snake's colors <tr><td>speed</td><td>number</td><td>default speed is 1, but it can change if a snake is using boost</td></tr>
<tr><td>food_consumed_natural</td><td>number</td><td>unknown definition</td></tr>
<tr><td>food_consumed_hunted_self</td><td>number</td><td>unknown definition</td></tr>
<tr><td>food_consumed_hunted_by_others</td><td>number</td><td>unknown definition</td></tr>
<tr><td>colors</td><td>{number}</td><td>table of colors (default color is 0x0000FF00, maximum count is 100, set is available in <a href="#init">init</a>)</td></tr>
<tr><td>face</td><td>number</td><td>not implemented yet (returns 0, set is available in <a href="#init">init</a>)</td></tr>
<tr><td>logo</td><td>number</td><td>not implemented yet (returns 0, set is available in <a href="#init">init</a>)</td></tr></tr>
</tbody></table></p>
</dd>
<dt>
<a name = "findFood"></a> <h2><a href="#Functions">Functions</a></h2>
<strong>findFood (max_distance, minimum_food_value)</strong> <table class="function_list">
</dt> <thead>
<dd> <tr>
That method returns all food as list. <td>
Function name
</td>
<h4>Parameters:</h4> <td>
<ul> Description
<li><code>max_distance</code> </td>
all food within the distance is included </tr>
</li> </thead>
<li><code>minimum_food_value</code> <tbody>
all lower food values are filtered (min: 0, max: unknown) <tr>
</li> <td class="name" nowrap><a href="#init">init ()</a></td>
</ul> <td class="summary">This function is called upon creation of a bot
Initialialize your environment here.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#findFood">findFood (max_distance, minimum_food_value)</a></td>
<h4>Usage:</h4> <td class="summary">That function returns all food as list.</td>
<ul> </tr>
<pre class="usage"><code class="lua"> <span class="keyword">local</span> food = findFood(max_distance, <span class="number">0.8</span>) <tr>
<span class="keyword">for</span> i, item <span class="keyword">in</span> food:<span class="global">pairs</span>() <span class="keyword">do</span> <td class="name" nowrap><a href="#findSegments">findSegments (max_distance, include_own)</a></td>
item.d <span class="comment">-- angle in radian <td class="summary">That function returns all segments of all snakes within a certain radius as list.</td>
</span> item.dist <span class="comment">-- distance </tr>
</span> <span class="keyword">end</span></code></pre> <tr>
</ul> <td class="name" nowrap><a href="#log">log (message)</a></td>
<td class="summary">That function sends messages to the development console.</td>
</dd> </tr>
<dt> <tr>
<a name = "findSegments"></a> <td class="name" nowrap><a href="#step">step ()</a></td>
<strong>findSegments (max_distance, include_own)</strong> <td class="summary">That function is called each frame.</td>
</dt> </tr>
<dd> </tbody>
That method returns all segments of all snakes within a certain radius as list. </table>
All attributes of each item in the segments list are measured between the center of your head the the center of the item center.
<h2><a name="Functions"></a>Functions</h2>
<h4>Parameters:</h4>
<ul> <dl class="function">
<li><code>max_distance</code> <dt>
all segements within that distance are included <a name = "init"></a>
</li> <strong>init ()</strong>
<li><code>include_own</code> </dt>
If true, your snake segments are included. Otherwise you get only enemy segments <dd>
</li> This function is called upon creation of a bot
</ul> Initialialize your environment here.
You can also access the "self" module here and, e.g. set your snake's colors.
<h4>Usage:</h4>
<ul>
<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> <h4>Usage:</h4>
item.d <span class="comment">-- angle in radian <ul>
</span> item.r <span class="comment">-- radius of the item <pre class="usage"><code class="lua"> <span class="keyword">function</span> init()
</span> item.dist <span class="comment">-- distance self.colors = { <span class="number">0xFF0000</span>, <span class="number">0xFFBF00</span>, <span class="number">0x80FF00</span>, <span class="number">0x00FF40</span>, <span class="number">0x00FFFF</span>, <span class="number">0x0015FF</span>, <span class="number">0x8000FF</span> }
</span> item.bot <span class="comment">-- id of the other snake <span class="keyword">end</span></code></pre>
</span> <span class="keyword">end</span></code></pre> </ul>
</ul>
</dd>
</dd> <dt>
<dt> <a name = "findFood"></a>
<a name = "log"></a> <strong>findFood (max_distance, minimum_food_value)</strong>
<strong>log (message)</strong> </dt>
</dt> <dd>
<dd> That function returns all food as list.
That method sends messages to the development console.
<h4>Parameters:</h4>
<h4>Parameters:</h4> <ul>
<ul> <li><code>max_distance</code>
<li><code>message</code> all food within the distance is included
this string will be transfered to the console </li>
</li> <li><code>minimum_food_value</code>
</ul> all lower food values are filtered (min: 0, max: unknown)
</li>
</ul>
</dd>
</dl> <h4>Usage:</h4>
<ul>
<pre class="usage"><code class="lua"> <span class="keyword">local</span> food = findFood(max_distance, <span class="number">0.8</span>)
</div> <!-- id="content" --> <span class="keyword">for</span> i, item <span class="keyword">in</span> food:<span class="global">pairs</span>() <span class="keyword">do</span>
</div> <!-- id="main" --> item.d <span class="comment">-- angle in radian
</div> <!-- id="container" --> </span> item.dist <span class="comment">-- distance
</span> <span class="keyword">end</span></code></pre>
{% endblock %} </ul>
</dd>
<dt>
<a name = "findSegments"></a>
<strong>findSegments (max_distance, include_own)</strong>
</dt>
<dd>
That function 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>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>
<h4>Usage:</h4>
<ul>
<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>