Turtle Field Quick Reference

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

Ruby methods in Turtle classconnect to server Turtle.new(hostname)use TCP port 2222

Turtle Graphics

clear screen clr
origin is the center of square
home position home
pen up pu
pen down pd
step forward fd(step)
step back bk(step)
unit of length: pixel
jump jump(x, y)
relative jump rjump(dx, dy)turn left lt(angle)
unit of angle: degree
turn right rt(angle)
print string say(string)line mode line
brush mode brushmax # of vertices in filling mode: 6
filling mode fill
type: 1..53
display card card(type,x,y)
clear card clrcard
returns [x, y]
query curr. position q_pos
returns angle
query heading direction q_dir
0.0 < red green, blue < 1.0
pen color col(red, green, blue)
background color bgc(red, green, blue)

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

Methods to be called on events
hit_by_bullet(time)
run_into_turtle(time)
run_into_donut(time)
run_into_stone(time)
run_into_wall(time)found_coin(time)
detected_by_finder(time)
detected_by_radar(time)
got_message(time)
time code is passed

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

methods
FINDER front sensor
switch to battle mode bmodedefault: 20
use rf() to changeswitch to graphics mode gmodeshoot a bullet fire
set nickname nm(name)set my team number tm(team_id) 0<=team_id<=4# of turtles and donuts
query number of objects q_nt
result code = 0: no objects within effective range
query to finder q_finder returns code
1: turtle 2: donut 3: stone 4: wall found
set range of finder rf(range)
query to angular radar q_radar returns angle
RADAR angular sensor
query to sonar q_sonar returns [left, front, right]
anticlockwise>0
query my current score q_score returns current score
query team id of turtle met just before q_tm returns the id (use this after Q_FINDER
angle to the nearest
or Q_RADAR calls)
put a robot turtle in the field robot
object (turtle or donut)
max 10 donuts for eachscatter a donut in the field donut
scatter a coin in the field coinmax 300 coins in the fieldborrow 10 coins from the TF owner borrowcoin
measurement error: 20 deg
drop a coin at current position dropcoin
SONAR obstacle detector
pick one coin near current position pickcoin returns the numberarray index = 0
check number of coin at near distance q_coin
for each direction
1
broadcast message to team members bcas(message)
false:
noobstacle,true:
obstacle
found
returns the message
within 20 pixels
query team message q_bcas
2

C, Java, 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 modesclear 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