This is an archive of a previous version of Sodarace.

Please visit http://sodarace.net for the latest version.

forum  |  »» sodaplay
 
»» forums  »» artificial intelligence forum

subject: Getting started

2 replies on 1 page. most recent reply: 19-Aug-06 21:23 by martincmartin

»» back to topic list  

This topic has 2 replies on 1 page
»» previous topic   »» next topic  


martincmartin

»» models
»» homepage

Getting started   posted: 19-Aug-06 17:23   »» 
I'm new to sodarace so I thought I'd collect all the info related to AI in one thread. The SodaRace home page just points AI people to the two applets and these forums, and digging through the forums for information can take a lot of time.

Should this thread be sticky?

You can find API documentation here: http://sodarace.net/api/index.jsp

And the DTD for the model XML here: http://www.sodaplay.com/constructor/beta/sodaconstructor.dtd

Is there any documentation on limits for any of the values? For example, gravity, speed, phase.

There are two existing projects:

Wodka: http://wodka.sourceforge.net/
AI Central's SodaRace: http://www.dcs.qmul.ac.uk/sodarace/SodaOptimization_index.html



martincmartin

»» models
»» homepage

Re: Getting started   posted: 19-Aug-06 21:17   »» 
The maximum values for:

gravity: 4.0
friction: 1.0
springyness: 0.5

martincmartin

»» models
»» homepage

Simple python client   posted: 19-Aug-06 21:23   »» 
Here's a simple python client that evaluates a single model. You may need to indent the loop, i.e. the three lines after "while True:"

import socket

model = """<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE sodaconstructor>
<model>
<container width="651" height="422"/>
<environment gravity="0.31443796" friction="0.05458992" springyness="0.32299763"/>
<collisions surface_friction="0.1" surface_reflection="-0.75"/>
<wave amplitude="0.60465115" phase="0.0015686274" speed="0.008235294"/>
<settings gravitydirection="down" wavedirection="forward" autoreverse="off"/>
<nodes>
<mass id="m7" x="0.20344639" y="0.0" vx="7.347312E-17" vy="0.19228646"/>
<mass id="m8" x="39.06419" y="34.916317" vx="-2.4770938E-14" vy="7.3158236E-14"/>
<mass id="m9" x="78.87359" y="69.91241" vx="-2.687017E-14" vy="7.4260334E-14"/>
<mass id="m10" x="38.851414" y="35.02552" vx="-3.4532368E-14" vy="3.8940754E-14"/>
<mass id="m11" x="0.008171797" y="0.0" vx="1.7318665E-16" vy="0.19119084"/>
<mass id="m12" x="76.12644" y="0.0" vx="-1.0758565E-15" vy="0.25021917"/>
<mass id="m13" x="75.98091" y="0.0" vx="-3.8835794E-16" vy="0.27948648"/>
</nodes>
<links>
<spring a="m8" b="m7" restlength="0.0"/>
<spring a="m9" b="m8" restlength="0.0"/>
<spring a="m10" b="m9" restlength="0.0"/>
<spring a="m11" b="m10" restlength="0.0"/>
<spring a="m12" b="m7" restlength="74.97434"/>
<spring a="m12" b="m8" restlength="52.222485"/>
<spring a="m13" b="m10" restlength="52.6637"/>
<spring a="m13" b="m11" restlength="74.79381"/>
<muscle a="m7" b="m9" restlength="159.0" amplitude="0.52380955" phase="0.0"/>
<muscle a="m9" b="m11" restlength="159.0" amplitude="0.52380955" phase="0.5019608"/>
</links>
</model>
"""

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', 7777))
sockfile = sock.makefile(mode='r+')

# Read and check the header
header = sockfile.readline()
assert header.startswith('Hello client: ')
print "Connected to sodarace"

# Read and check the request
request = sockfile.readline()
qmark_pos = request.find('?')
assert qmark_pos > 0
print "got request: ", request
id = request[0:qmark_pos]

# Send the model
sockfile.write(model)
sockfile.flush()
print "Sent model"

while True:
racer = sockfile.readline()
print "Received: ", racer
if racer.startswith(id + '>'): break

print "Time: ", racer[racer.find('>')+1:-1]



This topic has 2 replies on 1 page


»» previous topic   »» next topic  

»» back to topic list  »» top of the page  

PLEASE READ THE FORUM GUIDELINES AND ALWAYS PREVIEW TO CHECK MESSAGES BEFORE POSTING...
...Help keep our forums creative and constructive. Thank you.


»» forum home