CAMS-Replicator-2D-Simulation/main.py

34 lines
697 B
Python

from sim import Environment, CAMSReverseAndSidestepAgent, Direction
import time
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation
STEPS = 1000
np.random.seed(12345)
fig, ax = plt.subplots()
env = Environment((100, 100))
first_agent = CAMSReverseAndSidestepAgent(
environment=env,
position=(50,50),
initial_direction=Direction.NORTH,
required_resources=500
)
im = ax.imshow(env.render(), aspect="equal", origin="lower")
def update(frame_number):
print(frame_number)
env.step()
im.set_data(env.render())
return im,
ani = FuncAnimation(
fig=fig,
func=update,
frames=STEPS,
blit=True)
plt.show()