29 lines
620 B
Python
29 lines
620 B
Python
from sim import Environment, CAMSReverseAndSidestepAgent, Direction
|
|
import time
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
STEPS = 1000
|
|
FRAME_DELAY = 1/60
|
|
|
|
|
|
# Fixing random state for reproducibility
|
|
np.random.seed(12345)
|
|
|
|
env = Environment((40, 30))
|
|
first_agent = CAMSReverseAndSidestepAgent(
|
|
environment=env,
|
|
position=(20,15),
|
|
initial_direction=Direction.NORTH
|
|
)
|
|
|
|
fig, ax = plt.subplots()
|
|
im = ax.imshow(env.render(), aspect="equal", origin="lower")
|
|
fig.show()
|
|
|
|
for i in range(1, STEPS+1):
|
|
print(i)
|
|
plt.pause(FRAME_DELAY)
|
|
env.step()
|
|
im.set_data(env.render())
|
|
fig.canvas.draw() |