remove obsolete functions and imports, add license

main
Nekkowe! 2023-10-01 13:01:55 +02:00
parent 470223d7de
commit ea10aac18e
1 changed files with 12 additions and 10 deletions

22
sim.py
View File

@ -1,6 +1,8 @@
# By Nekkowe 2023-10-01
# nekkowe.com / nekkowe@gmail.com
# Released under CC-BY-NC https://creativecommons.org/licenses/by-nc/4.0/deed.en
import numpy as np
from enum import Enum, auto
import matplotlib.pyplot as plt
from enum import Enum
from dataclasses import dataclass
class Direction(Enum):
@ -103,20 +105,22 @@ class Environment:
return np.array(pixel_data).astype(np.uint8).swapaxes(0, 1)
def eat(self, position):
resources = self.resource_map[tuple(position)]
self.resource_map[tuple(position)] = 0
resources = self.get_resources(position)
self.set_resources(position, 0)
return resources
def cell(self, position):
x, y = tuple(position)
return self.cells[y][x]
def has_obstacle(self, position):
return self.obstacle_map[tuple(position)] == 1
def has_agent(self, position):
return tuple(position) in {tuple(agent.position) for agent in self.agents}
def get_resources(self, position):
return self.resource_map[tuple(position)]
def set_resources(self, position, resources):
self.resource_map[tuple(position)] = 0
def register_agent(self, agent):
self.agents.append(agent)
@ -262,5 +266,3 @@ class CAMSReverseAndSidestepAgent(DirectionalAgent):
return [255, 0, 0]
else:
return Colours.UNDEFINED