2023-09-30 14:53:32 +00:00
|
|
|
from sim import Environment, CAMSReverseAndSidestepAgent, Direction
|
|
|
|
import time
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import numpy as np
|
2023-09-30 15:26:39 +00:00
|
|
|
from matplotlib.animation import FuncAnimation
|
2023-09-30 14:53:32 +00:00
|
|
|
|
|
|
|
STEPS = 1000
|
|
|
|
|
|
|
|
np.random.seed(12345)
|
2023-09-30 15:26:39 +00:00
|
|
|
fig, ax = plt.subplots()
|
2023-09-30 23:45:10 +00:00
|
|
|
env = Environment((100, 100))
|
2023-09-30 15:26:39 +00:00
|
|
|
|
2023-09-30 14:53:32 +00:00
|
|
|
first_agent = CAMSReverseAndSidestepAgent(
|
|
|
|
environment=env,
|
2023-09-30 23:45:10 +00:00
|
|
|
position=(50,50),
|
|
|
|
initial_direction=Direction.NORTH,
|
2023-10-01 00:53:01 +00:00
|
|
|
required_resources=500
|
2023-09-30 14:53:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
im = ax.imshow(env.render(), aspect="equal", origin="lower")
|
|
|
|
|
2023-09-30 15:26:39 +00:00
|
|
|
def update(frame_number):
|
2023-09-30 17:39:26 +00:00
|
|
|
print(frame_number)
|
2023-09-30 14:53:32 +00:00
|
|
|
env.step()
|
|
|
|
im.set_data(env.render())
|
2023-09-30 15:26:39 +00:00
|
|
|
return im,
|
|
|
|
|
|
|
|
ani = FuncAnimation(
|
|
|
|
fig=fig,
|
|
|
|
func=update,
|
|
|
|
frames=STEPS,
|
|
|
|
blit=True)
|
|
|
|
|
|
|
|
plt.show()
|