data representation update
This commit is contained in:
parent
8188cbbadf
commit
543b1898a9
@ -25,17 +25,17 @@ class ForkliftModel(Model):
|
|||||||
agent = ForkliftAgent(0, self)
|
agent = ForkliftAgent(0, self)
|
||||||
self.schedule.add(agent)
|
self.schedule.add(agent)
|
||||||
# Add the agent to a random grid cell
|
# Add the agent to a random grid cell
|
||||||
x = 3
|
x = 5
|
||||||
y = 2
|
y = 5
|
||||||
self.grid.place_agent(agent, (x, y))
|
self.grid.place_agent(agent, (x, y))
|
||||||
|
|
||||||
agent = PatchAgent(1, self, PatchType.pickUp)
|
agent = PatchAgent(1, self, PatchType.pickUp)
|
||||||
self.schedule.add(agent)
|
self.schedule.add(agent)
|
||||||
self.grid.place_agent(agent, (0, self.grid.height-1))
|
self.grid.place_agent(agent, (self.grid.width-1, self.grid.height-1))
|
||||||
|
|
||||||
agent = PatchAgent(2, self, PatchType.dropOff)
|
agent = PatchAgent(2, self, PatchType.dropOff)
|
||||||
self.schedule.add(agent)
|
self.schedule.add(agent)
|
||||||
self.grid.place_agent(agent, (self.grid.width-1, self.grid.height-1))
|
self.grid.place_agent(agent, (0, self.grid.height-1))
|
||||||
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
a = PatchAgent(i+3, self, PatchType.item)
|
a = PatchAgent(i+3, self, PatchType.item)
|
||||||
|
7
data/CATEGORY.py
Normal file
7
data/CATEGORY.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class CATEGORY(Enum):
|
||||||
|
PIZZA = 1
|
||||||
|
PASTA = 2
|
||||||
|
EGG = 3
|
16
data/Game.py
Normal file
16
data/Game.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from data.Item import Item
|
||||||
|
from data.Order import Order
|
||||||
|
|
||||||
|
|
||||||
|
class Game:
|
||||||
|
def __init__(self, id: int, agentPos: (int, int), deliveryPos: (int, int), orderPos: (int,int), stockPilePos: [(int,int)],
|
||||||
|
deliveryItem: Item, agentHandId: int, orderStock:[id], orderList: [Order] ):
|
||||||
|
self.id = id
|
||||||
|
self.agentPos = agentPos
|
||||||
|
self.deliveryPos = deliveryPos
|
||||||
|
self.orderPos = orderPos
|
||||||
|
self.stockPilePos = stockPilePos
|
||||||
|
self.deliveryItem = deliveryItem
|
||||||
|
self.agentHandId = agentHandId
|
||||||
|
self.orderStock = orderStock
|
||||||
|
self.orderList = orderList
|
7
data/Item.py
Normal file
7
data/Item.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from data.CATEGORY import CATEGORY
|
||||||
|
|
||||||
|
|
||||||
|
class Item:
|
||||||
|
def __init__(self, id: int, category: CATEGORY):
|
||||||
|
self.id = id
|
||||||
|
self.category = category
|
7
data/JOB.py
Normal file
7
data/JOB.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class JOB(Enum):
|
||||||
|
FISHERMAN = 1
|
||||||
|
FIREFIGHTER = 2
|
||||||
|
POLICEMAN = 3
|
8
data/Order.py
Normal file
8
data/Order.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from data.JOB import JOB
|
||||||
|
|
||||||
|
|
||||||
|
class Order:
|
||||||
|
def __init__(self, id: int, money: int, job: JOB):
|
||||||
|
self.id = id
|
||||||
|
self.money = money
|
||||||
|
self.job = job
|
9
data/StockPile.py
Normal file
9
data/StockPile.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from data.CATEGORY import CATEGORY
|
||||||
|
from data.Item import Item
|
||||||
|
|
||||||
|
|
||||||
|
class StockPile:
|
||||||
|
def __init__(self, id: int, category: CATEGORY, itemList: [Item]):
|
||||||
|
self.id = id
|
||||||
|
self.category = category
|
||||||
|
self.itemList = itemList
|
8
main.py
8
main.py
@ -22,9 +22,9 @@ def agent_portrayal(agent):
|
|||||||
if isinstance(agent, PatchAgent):
|
if isinstance(agent, PatchAgent):
|
||||||
color = colors[0]
|
color = colors[0]
|
||||||
if agent.type == PatchType.dropOff:
|
if agent.type == PatchType.dropOff:
|
||||||
color = colors[1]
|
portrayal = {"Shape": "truck.png", "scale": 1.0, "Layer": 0}
|
||||||
elif agent.type == PatchType.pickUp:
|
elif agent.type == PatchType.pickUp:
|
||||||
color = colors[2]
|
portrayal = {"Shape": "okB00mer.png", "scale": 1.0, "Layer": 0}
|
||||||
else:
|
else:
|
||||||
color = colors[random.randrange(13)+3]
|
color = colors[random.randrange(13)+3]
|
||||||
portrayal = {"Shape": "rect",
|
portrayal = {"Shape": "rect",
|
||||||
@ -36,8 +36,8 @@ def agent_portrayal(agent):
|
|||||||
return portrayal
|
return portrayal
|
||||||
|
|
||||||
base = 512
|
base = 512
|
||||||
gridWidth = 6
|
gridWidth = 10
|
||||||
gridHeight = 4
|
gridHeight = 10
|
||||||
scale = base/gridWidth
|
scale = base/gridWidth
|
||||||
|
|
||||||
grid = CanvasGrid(agent_portrayal, gridWidth, gridHeight, scale*gridWidth, scale*gridHeight)
|
grid = CanvasGrid(agent_portrayal, gridWidth, gridHeight, scale*gridWidth, scale*gridHeight)
|
||||||
|
BIN
okB00mer.png
Normal file
BIN
okB00mer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 393 KiB |
BIN
tomatoe.png
Normal file
BIN
tomatoe.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 416 KiB |
Loading…
Reference in New Issue
Block a user