2D gridworld simulation, grid world, grid-world, pygame, sim, girdworld, simulation, 2D.
- Python 2.7 or 3+
- Pygame
Simulation(configFile = None)configFile: String
An instance of Simulation()
sim = Simulation('path/to/config_file')Simulation.load_matrix_file('path/to/matrix_file')matrixFile: String
Nothing
Simulation.load_slip_file('path/to/slip_file')slipFile: String
Nothing
x_pos y_pos action x_result y_result probabilitySimulation.move_agent(actions = None)actions: List of actions. There are 7 actions to choose from. 'east', 'west', 'north', 'south', 'keyboard', 'matrix'.
The fist four actions are self-explanatory. 'keyboard' takes the input from they keyboard keys to move the agent. 'matrix' moves the agent according to the matrix file used during instantiating the simulation.
Boolean: flag whether to terminate simulation. True if terminate, False if not.
Dictionary: Contains the state of the simulation.
done, state = sim.move_agent(['east','keyboard'])Simulation.get_state()None
Dictionary
state = sim.get_state()Simulation.update()None
Boolean
done = sim.update()Simulation.get_log()
None
Dictionary
log = sim.get_log()
agents_log = sim.get_log()["agents"]
agent_0_log = sim.get_log()["agents"][0]Simulation.get_history(time_steps)time_steps
Dictionary of last [time_steps] time steps
histroy_1 = sim.get_log(1)
history_2 = sim.get_log(2)
agents_2_history = sim.get_log(2)["agents"]Simulation.generate_agent_matrix(file = None)String: String
None
sim.generate_agent_matrix("agent_matrix.txt")from environment import Simulation
from time import sleep
sim = Simulation("config.txt")
sim.load_matrix_file("matrix.txt")
state = sim.get_state()
done = False
while not done:
# move the agent 1 according to the matrix file and agent 2 south
done, state = sim.move(["matrix", "south"])
sleep(1)
# to generate a matrix file
sim.generate_agent_matrix("agent_matrix.txt")python config_gui.py [configFile]The GUI prompts for inputs on the command line while running
configFile (optional) - open a config file to edit