Turtle Field Quick Reference

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

Python methods in Turtle classconnect to server Turtle(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 brush()
max # of vertices in filling mode: 6
filling mode fill()
display card card(type,x,y)
type: 1..53
clear card clrcard()
query curr. position q_pos()returns [x, y]
query heading direction q_dir()
returns angle
pen color col(red, green, blue)
0.0 < red green, blue < 1.0
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 need to be overridden
to detect events
hit_by_bullet(self,time)
run_into_turtle(self,time)
run_into_donut(self,time)
run_into_stone(self,time)
run_into_wall(self,time)found_coin(self,time)
detected_by_finder(self,time)
detected_by_radar(self,time)
got_message(self,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 bmode()default: 20
use rf() to changeswitch to graphics mode gmode()shoot 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 angleRADAR 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)
scatter a donut in the field donut() max 10 donuts for eachmax 300 coins in the field
scatter a coin in the field coin()borrow 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 number
array index = 0
check number of coin at near distance q_coin()for each direction
1
broadcast message to team members bcas(message)
False: no obstacle, True: obstacle foundwithin 20 pixels
returns the message
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 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