Simbad and Python


Home | Download | Docs | Screenshots | SourceForge Summary


Python scripting examples

It is easy to program Simbad with Java and it is even easier to program it with Python. As you probably know, Python is a very powerful language particularly suited for Artificial Intelligence and Computer Science experiments in general. To execute Python scripts with simbad you need the famous Jython package. Jython is a Python interpreter written in Java, it adds Python scripting facilities to the java language and permit to script directly Simbad classes.

Launching scripts

Jython can be downloaded from www.jython.org. Follow Jython (easy) install procedure then edit scripts and launch them with: jython myscript.py

For this to work simbad.jar must be on your CLASSPATH

Note: Python scripting is only available since Simbad 1.3.1 version.

A Simple controler

from simbad.gui import *
from simbad.sim import *
from  javax.vecmath import *

# a very simple robot controller , derived from Agent java class.
class MyRobot(Agent):
	def initBehavior(self):
		# nothing to do
		pass
	
	def performBehavior(self):
		if self.collisionDetected():
			self.setTranslationalVelocity(0)
		else:
			self.setTranslationalVelocity(0.2)

# description of the environment 
class MyEnv(EnvironmentDescription):
	def __init__(self):
		# put a  robot 
		self.add(MyRobot(Vector3d(0,0,0),"robot with python"))
		# put a box 
		self.add(Box(Vector3d(3, 0, 0), Vector3f(1, 1, 1),self))

# launch simbad 
simbad = Simbad(MyEnv(),0)



Python scripts examples:

  • simplan.py :this example shows the use of a simple plan in Python.
Simbad Project is hosted at SourceForge.net Logo