docs.html 4.68 KB
Newer Older
nachtgold's avatar
nachtgold committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

{% extends 'base.html' %}

{% load static %}

{% block earlycss %}
    <link rel="stylesheet" type="text/css" href="{% static "docs/github-markdown.css" %}" />
{% endblock %}

{% block css %}
    <link rel="stylesheet" type="text/css" href="{% static "docs/docs.css" %}" />
{% endblock %}

{% block content %}

<div class="docs_container markdown-body">


<h1>Bot Documentation</h1>

<div id="docs_content">

<p>This is a brief overview of all usable functions within the bot logic.</p>
nachtgold's avatar
nachtgold committed
24
25
26
27
<p>
 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
 to frame.</p>
nachtgold's avatar
nachtgold committed
28
29
30
31
32


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
33
34
	<td class="name" nowrap><a href="#step">step ()</a></td>
	<td class="summary">That method is called each frame.</td>
nachtgold's avatar
nachtgold committed
35
36
37
38
39
	</tr>
	<tr>
	<td class="name" nowrap><a href="#init">init ()</a></td>
	<td class="summary">This method is called upon creation of a bot
 Initialialize your environment here.</td>
nachtgold's avatar
nachtgold committed
40
41
	</tr>
	<tr>
42
43
44
45
46
47
	<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>
nachtgold's avatar
nachtgold committed
48
49
50
51
52
53
54
55
	</tr>
</table>


    <h2><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    <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()
nachtgold's avatar
nachtgold committed
78
   <span class="keyword">return</span> <span class="number">0.005</span>
79
80
81
 <span class="keyword">end</span></code></pre>
    </ul>

nachtgold's avatar
nachtgold committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
</dd>
    <dt>
    <a name = "init"></a>
    <strong>init ()</strong>
    </dt>
    <dd>
    This method is called upon creation of a bot
 Initialialize your environment here.
 you can also access the "self" object here and, e.g. set your snake's colors







98
99
100
101
</dd>
    <dt>
    <a name = "findFood"></a>
    <strong>findFood (max_distance, minimum_food_value)</strong>
nachtgold's avatar
nachtgold committed
102
103
    </dt>
    <dd>
104
    That method returns all food as list.
nachtgold's avatar
nachtgold committed
105
106
107
108


    <h4>Parameters:</h4>
    <ul>
109
110
111
112
113
        <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)
nachtgold's avatar
nachtgold committed
114
115
116
117
118
119
120
121
        </li>
    </ul>




    <h4>Usage:</h4>
    <ul>
122
123
124
125
126
        <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>
nachtgold's avatar
nachtgold committed
127
128
129
130
    </ul>

</dd>
    <dt>
131
132
    <a name = "findSegments"></a>
    <strong>findSegments (max_distance, include_own)</strong>
nachtgold's avatar
nachtgold committed
133
134
    </dt>
    <dd>
135
136
    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.
nachtgold's avatar
nachtgold committed
137
138


139
140
141
142
143
144
145
146
147
    <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>
nachtgold's avatar
nachtgold committed
148
149
150
151
152
153




    <h4>Usage:</h4>
    <ul>
154
155
156
157
158
159
160
        <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>
nachtgold's avatar
nachtgold committed
161
162
163
164
165
166
167
168
169
170
171
    </ul>

</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
</div> <!-- id="container" -->

{% endblock %}