mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-09-15 23:37:14 +02:00
WIP: removing tiles
This commit is contained in:
@@ -71,7 +71,7 @@ class PodRules(Rule):
|
||||
def on_init(self, state, lvl_map):
|
||||
pod_collection = state[b.CHARGE_PODS]
|
||||
empty_tiles = state[c.FLOOR].empty_tiles[:self.n_pods]
|
||||
pods = pod_collection.from_tiles(empty_tiles, entity_kwargs=dict(
|
||||
pods = pod_collection.from_coordinates(empty_tiles, entity_kwargs=dict(
|
||||
multi_charge=self.multi_charge, charge_rate=self.charge_rate)
|
||||
)
|
||||
pod_collection.add_items(pods)
|
||||
|
@@ -48,4 +48,4 @@ class DirtPile(Entity):
|
||||
return state_dict
|
||||
|
||||
def render(self):
|
||||
return RenderEntity(d.DIRT, self.tile.pos, min(0.15 + self.amount, 1.5), 'scale')
|
||||
return RenderEntity(d.DIRT, self.pos, min(0.15 + self.amount, 1.5), 'scale')
|
||||
|
@@ -29,7 +29,7 @@ class ItemAction(Action):
|
||||
elif items := state[i.ITEM].by_pos(entity.pos):
|
||||
item = items[0]
|
||||
item.change_parent_collection(inventory)
|
||||
item.set_tile_to(state.NO_POS_TILE)
|
||||
item.set_pos_to(c.VALUE_NO_POS)
|
||||
state.print(f'{entity.name} just picked up an item at {entity.pos}')
|
||||
return ActionResult(entity=entity, identifier=self._identifier, validity=c.VALID, reward=r.PICK_UP_VALID)
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class Item(Entity):
|
||||
var_can_collide = False
|
||||
|
||||
def render(self):
|
||||
return RenderEntity(i.ITEM, self.tile.pos) if self.pos != c.VALUE_NO_POS else None
|
||||
return RenderEntity(i.ITEM, self.pos) if self.pos != c.VALUE_NO_POS else None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -29,8 +29,8 @@ class Item(Entity):
|
||||
def set_auto_despawn(self, auto_despawn):
|
||||
self._auto_despawn = auto_despawn
|
||||
|
||||
def set_tile_to(self, no_pos_tile):
|
||||
self._tile = no_pos_tile
|
||||
def set_pos_to(self, no_pos):
|
||||
self._pos = no_pos
|
||||
|
||||
def summarize_state(self) -> dict:
|
||||
super_summarization = super(Item, self).summarize_state()
|
||||
@@ -57,7 +57,7 @@ class DropOffLocation(Entity):
|
||||
return True
|
||||
|
||||
def render(self):
|
||||
return RenderEntity(i.DROP_OFF, self.tile.pos)
|
||||
return RenderEntity(i.DROP_OFF, self.pos)
|
||||
|
||||
@property
|
||||
def encoding(self):
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import random
|
||||
from typing import List
|
||||
from typing import List, Tuple
|
||||
|
||||
from marl_factory_grid.environment.entity.entity import Entity
|
||||
from marl_factory_grid.environment.entity.object import Object
|
||||
@@ -14,12 +14,12 @@ class Zone(Object):
|
||||
|
||||
@property
|
||||
def positions(self):
|
||||
return [x.pos for x in self.tiles]
|
||||
return self.coords
|
||||
|
||||
def __init__(self, tiles: List[Floor], *args, **kwargs):
|
||||
def __init__(self, coords: List[Tuple[(int, int)]], *args, **kwargs):
|
||||
super(Zone, self).__init__(*args, **kwargs)
|
||||
self.tiles = tiles
|
||||
self.coords = coords
|
||||
|
||||
@property
|
||||
def random_tile(self):
|
||||
return random.choice(self.tiles)
|
||||
return random.choice(self.coords)
|
||||
|
Reference in New Issue
Block a user