{% extends 'core/base.html' %} {% load static %} {% block title %} Docs - Schlangenprogrammiernacht 2018 {% endblock %} {% block earlycss %} {% endblock %} {% block css %} {% endblock %} {% block js%} {% endblock %} {% block content %}

Bot Documentation

This is a brief overview of all usable functions within the bot logic.

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.

Functions

step () That method is called each frame.
init () This method is called upon creation of a bot Initialialize your environment here.
findFood (max_distance, minimum_food_value) That method returns all food as list.
findSegments (max_distance, include_own) That method returns all segments of all snakes within a certain radius as list.
log (message) That method sends messages to the development console.

Functions

step ()
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.

Returns:

    new angle relative to the head direction

Usage:

     function step()
       return 0.005
     end
init ()
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
findFood (max_distance, minimum_food_value)
That method returns all food as list.

Parameters:

  • max_distance all food within the distance is included
  • 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
findSegments (max_distance, include_own)
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.

Parameters:

  • max_distance all segements within that distance are included
  • 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
log (message)
That method sends messages to the development console.

Parameters:

  • message this string will be transfered to the console
{% endblock %}