-
Notifications
You must be signed in to change notification settings - Fork 12
Customize your Robot
You can code your own robot in Python, make it move, and configure to use it in a simulation.
PySimbot is designed based on the Object-Oriented Programming (OOP) concept.
You can create your own Robot class by extends the PySimbot's default robot class pysimbotlib.core.Robot. Then customize the update() method by override it by your logic. For the rest, your class will inherit the ability from the default robot class that will handle the methods such as drawing in simulation map, checking for robot collision, eating food etc.
from pysimbotlib.core import PySimbotApp, Robot
class CircularRobot(Robot):
def update(self):
self.move(5)
self.turn(15)By passing your robot class as a parameter of PySimbotApp constructor, the simulation will replace the default robot with your own robot.
if __name__ == '__main__':
app = PySimbotApp(robot_cls=CircularRobot)
app.run()To combine all code segments into one, you can simply create a new script file e.g. main.py and put it together.
from pysimbotlib.core import PySimbotApp, Robot
class CircularRobot(Robot):
def update(self):
self.move(5)
self.turn(15)
if __name__ == '__main__':
app = PySimbotApp(robot_cls=CircularRobot)
app.run()Then, in the command window, run the command
python main.pyNow, you should see the robot moving in the map by your own robot.
- Home
- Installation
- Getting Started
- Concept
- API
- Examples
- Use cases
- Reactive Robot