Turtle Field Quick Reference

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

Java methods in Turtle class

Turtle Graphics

use TCP port 2222
connect to server Turtle.new(String hostname)clear screen void clr(void)origin is the center of square
home position void home(void)
pen up void pu(void)
pen down void pd(void)
step forward void fd(float step)
unit of length: pixel
step back void bk(float step)
jump void jump(double x, double y)relative jump void rjump(double dx, double dy)turn left void lt(double angle)
unit of angle: degree
turn right void rt(double angle)
print string void say(String string)line mode void line(void)brush mode void brush(void)
max # of vertices in filling mode: 6
filling mode void fill(void)
display card void card(int type, double x, double y) type: 1..53
clear card void clrcard(void)
query curr. position double[ ] q_pos(void)
0.0 < r, g, b < 1.0
query heading direction double q_dir(void)
pen color void col(double r, double g, double b)
background color void bgc(double r, double g, double b)

Regulations/limitations in battle (robot) mode

Battles & robot simulations

step size of FD & BK: up to 2 pixels
turning angle: up to 3 degrees
field is surrounded by rigid walls

Methods to be called on events
void hit_by_bullet(int time)
void run_into_turtle(int time)
void run_into_donut(int time)
void run_into_stone(int time)
void run_into_wall(int time)
void found_coin(int time)
void detected_by_finder(int time)
void detected_by_radar(int time)
void got_message(int time)
time code is passedScoring
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

only single bullet can exist at a moment in the field for each turtle

switch to battle modeswitch to graphics modeshoot a bullet
set nickname
set my team number
query number of objects
query to finder
set range of finder
query to angular radar
query to sonar
query my current score
query team id of turtle met just before
put a robot turtle in the fieldscatter a donut in the field
scatter a coin in the fieldborrow 10 coins from the TF owner
drop a coin at current position
pick one coin near current position
check number of coin at near distancebroadcast message to team members
query team message

methods
FINDER front sensor
void bmode(void)
default: 20
use rf() to change
void gmode(void)
void fire(void)
void nm(String name)void tm(int team_id) 0<=team_id<=4
int q_nt(void) returns # of turtles and donuts
result code = 0: no objects within effective rangereturns code
int q_finder(void)
1: turtle 2: donut 3: stone 4: wall foundvoid rf(double range)
double q_radar(void) returns angle
RADAR angular sensor
boolean[ ] q_sonar(void) returns [left, front, right]
anticlockwise>0
int q_score(void)use
thiscallafter
Q_FINDER
int q_tm(void)angle to the nearest
or Q_RADAR
void robot(void)
object (turtle or donut)
void donut(void) max 10 donuts for eachvoid coin(void)
void borrowcoin(void) max 300 coins in the fieldmeasurement error: 20 degvoid dropcoin(void)
void pickcoin(void)
SONAR obstacle detector
int q_coin(void)array index = 0
void bcas(String msg)
for each direction
1
false: no obstacle, true: obstacle found
TeamMessage q_bcas()within 20 pixels

2
C, 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