Simulation - jetstreamc/PySimbot Wiki
Simulation of the PySimbot is to experiment the robot navigation script. The robot will be moved according to your Python code. You can see how the robot moves in PySimbot window.
Start the simulation
To start the simulation, create the script file and named it as main.py
from pysimbotlib.core import PySimbotApp if __name__ == '__main__': app = PySimbotApp() app.run()
In command window, run the command
After running the command above, the simulation window will be shown. It is created by the PySimbot's default configuration. When the simulation starts, the timer on the right panel will start counting. However, robot stays still because its PySimbot default Robot which has no command.
PySimbot allows customization of an experiment. You can configure your own Robot to run in the simulation, the maximum number of time in simulation, robot start position, and so much more.
The followings are few examples of the parameter that could be passed to
max_tickis the maximum number of time steps for a simulation.
robot_default_start_posis the initial position to create the robot.
For the full list of simulation option, see API
Example: maximum simulation tick
By default, time to complete the simulation is 4000 steps. However, to define your own time of the simulation, you can pass arguments to a PySimbotApp constructor as same as passing the
enable_wasd_control in the first example (See Welcome-to-PySimbot-World).
The code below set the
max_tick to 1000 iterations. Thus, simulation will run only for 1000 iterations, then terminate.
from pysimbotlib.core import PySimbotApp if __name__ == '__main__': app = PySimbotApp(max_tick=1000) app.run()
Example: default robot starting position
By default, robot will be spawned on the left corner of the map. You may change the initial point of the robot by
from pysimbotlib.core import PySimbotApp if __name__ == '__main__': app = PySimbotApp(robot_default_start_pos=(450, 50)) app.run()