TurtleField Quick Reference

Turtle Graphics

connect to server
clear screen
home position
pen uppen down
step forward
step backjump
relative jump
turn left
turn rightprint stringline modebrush modefilling mode
display card
clear card
query curr. position
query heading direction
pen colorbackground color

11-JUN-2017, Y. Hayakawa (CITE, Tohoku Univ.)

C functions (all names in capital letters)
int CON(char *hostname) TF uses TCP port 2222
void CLR(void)origin is the center of squarevoid HOME(void)
void PU(void)
void PD(void)
void FD(float step)
void BK(float step)
unit of length: pixel
void JUMP(float x, float y)void RJUMP(float dx, float dy)
void LT(float angle)
void RT(float angle)
unit of angle: degree
void SAY(char *string)
void LINE(void)
void BRUSH(void)
max # of vertices in filling mode: 6
void FILL(void)
void CARD(int type, float x, float y) type: 1..53
void CLRCARD(void)
void Q_POS(float *x, float *y)void Q_DIR(float *angle)
void COL(float r, float g, float b)
void BGC(float r, float g, float b) 0.0 < r, g, b < 1.0

Battles & robot simulations

Regulations/limitations in battle (robot) mode
step size of FD & BK: up to 2 pixels
turning angle: up to 3 degrees
field is surrounded by rigid walls
only single bullet can exist at a moment in the field for each turtle

Set callback functions for event handling
SET_HIT_BY_BULLET_HANDLER(func)
SET_RUN_INTO_TURTLE_HANDLER(func)
SET_RUN_INTO_DONUT_HANDLER(func)
SET_RUN_INTO_STONE_HANDLER(func)
SET_RUN_INTO_WALL_HANDLER(func)
SET_FOUND_COIN_HANDLER(func)
SET_DETECTED_BY_FINDER_HANDLER(func)
SET_DETECTED_BY_RADAR_HANDLER(func)

SET_GOT_MESSAGE_HANDLER(func)

Callback functions(void) callback_func(unsigned int time)
time code is passed by caller

Scoring
initial score of each: 100
point to loose for each shoot: -1
hitting other turtle: +10
hit by bullet:-30
hitting donut within short distance: +10
when score < 0, disconnected

C functions
FINDER front sensor
switch to battle mode void BMODE(void)
default: 20
use RF() to changeswitch to graphics mode void GMODE(void)
shoot a bullet void FIRE(void)
set nickname void NM(char *name)set my team number void TM(int team_id) 0<=team_id<=4query number of objects void Q_NT(int *n) returns # of turtles and donuts
result code = 0: no objects within effective range
query to finder void Q_FINDER(int *result) returns code
1: turtle 2: donut 3: stone 4: wall found
set range of finder void RF(float range)
query to angular radar void Q_RADAR(float *angle) returns angle
RADAR angular sensor
query to sonar void Q_SONAR(int *left, int *front, int *right)
anticlockwise>0
query my current score void Q_SCORE(int *score)use
thiscallafterQ_FINDER
query team id of turtle met just before void Q_TM(void)angle to the nearest
or Q_RADAR
put a robot turtle in the field void ROBOT(void)
object (turtle or donut)
scatter a donut in the field void DONUT(void) max 10 donuts for eachscatter a coin in the field void COIN(void)borrow 10 coins from the TF owner void BORROWCOIN(void) max 300 coins in the fieldmeasurement error: 20 deg
drop a coin at current position void DROPCOIN(void)
pick one coin near current position void PICKCOIN(void)
SONAR obstacle detector
check number of coin at near distance void Q_COIN(int *ncoin)broadcast message to team members void BCAS(char *msg)
for each direction
0: no obstacle 1: obstacle foundquery team message void Q_BCAS(int *etime, char *msg)
within 20 pixels
Java, Ruby, and Python APIs are available at TurtleField web site:

http://seaotter.cite.tohoku.ac.jp/coda/tfield/index.html

Usage of Turtle Field serverright click on screen to pop up menu

size of turtle: 20 pixels in diameterpress capital M: enter maze mode
3: toggle b/w 2D and 3D modes

clear field clear drawing
http port for Turtle Field Live: 2280
erase zombie erase turtles that lost TCP connections
toggle graphics/battle mode in battle mode, background texture changes
toggle private/public mode in public mode connections from any addr. are accepted. window title bar changes
capture screen save screen shot in home (UNIX) or desktop (Windows)
kill all turtles
exit