Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge latest fixes into 2.0 for pip release #77

Merged
merged 164 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
d4b7d20
added a test for realm-level rng
kywch May 31, 2023
714cd0d
Merge branch 'realm-rng' into 2.0
kywch Jun 8, 2023
f44b810
cleaned up determinism tests
kywch Jun 8, 2023
d69fc92
get eval_fn src from task, predicate
kywch Jun 9, 2023
e46152d
Merge pull request #72 from CarperAI/get-src
jsuarez5341 Jun 9, 2023
02d8865
Merge pull request #73 from CarperAI/realm-rng
jsuarez5341 Jun 9, 2023
17c95b7
clean up eval functions to feed into llm
kywch Jun 9, 2023
39aa4f4
corrected type hints
kywch Jun 9, 2023
f401208
fixed error
kywch Jun 9, 2023
2e0ce2a
fix errors
kywch Jun 9, 2023
1e30a25
added support for task_spec_with_embedding
kywch Jun 9, 2023
6aca4d7
separated pred_kwargs and task_kwargs in task_spec
kywch Jun 11, 2023
e6660c2
tweaked tests for task_spec
kywch Jun 11, 2023
879b675
Merge pull request #74 from CarperAI/for-llm
jsuarez5341 Jun 12, 2023
96713b5
Add a memory usage test
jsuarez5341 Jun 12, 2023
8ae6116
make market_n_obs a constant
daveey Jun 13, 2023
aa01ef8
install psutil
daveey Jun 13, 2023
85b908a
Merge pull request #75 from CarperAI/daveey-git-pr-7002-15907
daveey Jun 13, 2023
061586d
return dummy obs and reward for the dead agents
kywch Jun 14, 2023
04e3bc6
env returns obs, rewards, dones, infos for all env.agents
kywch Jun 14, 2023
1cb6038
quick fixes
kywch Jun 14, 2023
222c795
made dummy obs zero length
kywch Jun 14, 2023
7a35c25
make dummy obs at reset and use it
kywch Jun 14, 2023
6c4e226
Merge pull request #76 from CarperAI/dead-reward
daveey Jun 14, 2023
5b02961
Revert "return dummy obs and reward for the dead agents"
daveey Jun 14, 2023
547cd58
Merge pull request #77 from CarperAI/revert-76-dead-reward
daveey Jun 14, 2023
23d14d5
added ActionTargets to dummy obs
kywch Jun 14, 2023
6b1ca08
Merge pull request #79 from CarperAI/dummy-obs
daveey Jun 15, 2023
dbf2bc4
add config.reset_on_death
daveey Jun 15, 2023
04ca0a3
Merge pull request #80 from CarperAI/daveey-git-pr-20651-2088
daveey Jun 15, 2023
615947a
made env._compute_observations() faster
kywch Jun 15, 2023
5515598
Merge pull request #81 from CarperAI/tile-map
daveey Jun 15, 2023
a4f61fe
made obs, make_attack_mask faster
kywch Jun 16, 2023
b9bb4b9
removed unnecessary len
kywch Jun 16, 2023
29de5b2
lazy load gs data, use pre-computed index
kywch Jun 16, 2023
7b85371
better lazy eval
kywch Jun 16, 2023
bb5e43e
Merge pull request #82 from CarperAI/opt-obs
daveey Jun 16, 2023
cda0c5b
Merge pull request #83 from CarperAI/lazy-gs
daveey Jun 16, 2023
61a06d7
implement env-level rng using gym seeding
kywch Jun 17, 2023
ebe8539
checked whether ordered_set is necessary
kywch Jun 17, 2023
efcb95f
made the map generation deterministic
kywch Jun 20, 2023
10d67a4
checked flip seed in map generation
kywch Jun 20, 2023
a275432
fixed pylint error
kywch Jun 20, 2023
c73080d
fixed deterministic map test
kywch Jun 20, 2023
5713a55
make sure obs matches obs_space
kywch Jun 20, 2023
2ad1217
changed to _np_random, call self.seed(seed)
kywch Jun 21, 2023
512530b
Merge branch 'realm-rng' into obs-check
kywch Jun 21, 2023
8696b2d
ensure obs match the obs space, set ds dtype to int16
kywch Jun 21, 2023
12fbdab
fix the seed for testing
kywch Jun 21, 2023
152f478
Merge pull request #85 from CarperAI/obs-check
daveey Jun 22, 2023
8224be5
Merge pull request #84 from CarperAI/realm-rng
daveey Jun 22, 2023
cef5adf
Added A* caching so results are not recalculated each step.
MarkHaoxiang Jun 26, 2023
5c183fc
Added tests to check invariants assumed for optimiations.
MarkHaoxiang Jun 26, 2023
99444b0
linf - avoid uneccessary calls to np
MarkHaoxiang Jun 26, 2023
2d306d8
Some more low hanging fruit
MarkHaoxiang Jun 26, 2023
88767ef
where_in_1d optimization, vectorized.
MarkHaoxiang Jun 27, 2023
62d38fb
Pylinted
MarkHaoxiang Jun 28, 2023
980dee4
Bug fix:
MarkHaoxiang Jun 28, 2023
5db6d0c
Further bug fixes. TODO: Pylint the ai.util file
MarkHaoxiang Jun 28, 2023
edf765f
added test_map_preview
kywch Jun 30, 2023
e20e11f
randomize spawn locations and move team_loader out of environment
daveey Jul 1, 2023
21b665b
Merge pull request #88 from CarperAI/daveey-git-pr-23919-1853
daveey Jul 1, 2023
f6fa24d
Merge pull request #87 from CarperAI/check-map
kywch Jul 1, 2023
2f43f15
Pylint and revert vectorization.
MarkHaoxiang Jul 2, 2023
848492f
Entity data bug fix
MarkHaoxiang Jul 2, 2023
5623af5
Minor task system hash updates
MarkHaoxiang Jul 2, 2023
a465d9c
Merge branch '2.0' into optimization
MarkHaoxiang Jul 2, 2023
76f3e2f
Pylinted
MarkHaoxiang Jul 2, 2023
398235e
Removed random_direction and random_safe
MarkHaoxiang Jul 3, 2023
7c5da36
added get_direction() to np_random for speed
kywch Jul 4, 2023
6bc4511
specified bit_generator
kywch Jul 4, 2023
45885f0
few fixes
kywch Jul 4, 2023
8541755
add task embedding to gym obs
kywch Jul 4, 2023
e3a767e
Updated habitable.
MarkHaoxiang Jul 4, 2023
b790a3b
Merge pull request #86 from CarperAI/optimization
kywch Jul 4, 2023
e353929
Merge branch '2.0' into rng-dir
kywch Jul 4, 2023
025a7f9
use np_random.get_direction(), added perf test
kywch Jul 4, 2023
9e4c1ba
Merge pull request #89 from CarperAI/rng-dir
daveey Jul 4, 2023
cd2b3e1
assert single task per agent
kywch Jul 12, 2023
9ce1acf
tweaked manual curriculum, added curriculum pkl file
kywch Jul 13, 2023
102598b
implemented sample training tasks from curriculum file
kywch Jul 13, 2023
81a92b2
Merge branch '2.0' into task-embed
kywch Jul 13, 2023
94a3272
refactored task spec, added make_task_from_spec
kywch Jul 14, 2023
528ed34
remove some no-longer needed stats
daveey Jul 14, 2023
e6b5283
Merge pull request #92 from CarperAI/daveey-git-pr-25594-2209
daveey Jul 14, 2023
8fc9217
Merge pull request #91 from CarperAI/class-spec
daveey Jul 15, 2023
156be0b
Merge pull request #90 from CarperAI/task-embed
daveey Jul 15, 2023
5d71913
fix task embedding observation space
daveey Jul 15, 2023
f814c20
cp
daveey Jul 19, 2023
75fc43c
cp
daveey Jul 19, 2023
90423d6
added no-op, checked tests
kywch Jul 21, 2023
1742825
some clean ups
kywch Jul 21, 2023
b6406f1
removed all args()
kywch Jul 21, 2023
530d044
Merge pull request #94 from CarperAI/no-args
daveey Jul 21, 2023
f79e7c7
Merge pull request #93 from CarperAI/add-noop
daveey Jul 21, 2023
d98263f
cp
daveey Jul 21, 2023
f160010
cp'
daveey Jul 21, 2023
ea3ae00
cp
daveey Jul 21, 2023
bdf7861
cp
daveey Jul 21, 2023
3a163eb
added a test for noop action on/off, fixed tests
kywch Jul 21, 2023
2bf5bce
Merge branch 'NeuralMMO:2.0' into daveey-test-tasks
daveey Jul 21, 2023
59cbf6d
Merge pull request #96 from CarperAI/daveey-test-tasks
daveey Jul 21, 2023
273e81f
support non-continous team ids
kywch Jul 22, 2023
9fcc562
Remove websocket and websocket deps; breaks some python installs
jsuarez5341 Jul 22, 2023
0fbb94c
Merge branch '2.0' of https://github.com/carperai/nmmo-environment in…
jsuarez5341 Jul 22, 2023
63e42c8
Merge pull request #97 from CarperAI/team-fix
daveey Jul 23, 2023
703a12a
add back websocket
kywch Jul 24, 2023
3387919
made json the default for saving replay
kywch Jul 24, 2023
ae666aa
removed decompress flag
kywch Jul 24, 2023
82a3b1e
added task_spec to info, to know which tasks got completed, added Hol…
kywch Jul 27, 2023
c11fba7
can define task spec with instantiated predicates
kywch Jul 27, 2023
e5a36cd
Merge pull request #98 from CarperAI/websocket
jsuarez5341 Jul 27, 2023
7641949
Merge pull request #99 from CarperAI/eval
jsuarez5341 Jul 27, 2023
67be912
Re-add websocket deps and separate scripted base class
jsuarez5341 Jul 27, 2023
93875ea
Merge pull request #100 from CarperAI/websocket
kywch Jul 27, 2023
5a951a0
clean up scripted code
kywch Jul 28, 2023
2063c3f
tweaked task spec name
kywch Jul 29, 2023
1f23c61
added task progress reward tracking
kywch Jul 29, 2023
424c305
deepcopy kwargs that are being changed
kywch Jul 29, 2023
8925daa
Merge pull request #101 from CarperAI/scripted
jsuarez5341 Jul 30, 2023
8f0ab12
fixed task embedding type, added curriculum-related vars
kywch Aug 9, 2023
c97f7e0
Merge pull request #102 from CarperAI/task-fix
jsuarez5341 Aug 9, 2023
ee80177
fixed potential 1-off obs bug
kywch Aug 9, 2023
f72466a
Merge pull request #103 from CarperAI/obs-fix
jsuarez5341 Aug 9, 2023
f3225fd
comment out the ItemState empty assert for now
kywch Aug 10, 2023
e1d318b
added task progress info
kywch Aug 10, 2023
4fe3b78
removed config.SPECIALIZE for scripted agents
kywch Aug 10, 2023
ff70def
Merge pull request #105 from CarperAI/task-stat
jsuarez5341 Aug 10, 2023
9d3bf50
Merge pull request #104 from CarperAI/item-bug2
jsuarez5341 Aug 10, 2023
4585870
moved check_task_spec to nmmo.task.task_spec
kywch Aug 10, 2023
0144877
give out the max reward when the task is accomplished
kywch Aug 11, 2023
b0b3ac9
Merge pull request #106 from CarperAI/check-spec
jsuarez5341 Aug 11, 2023
c28b9c4
changed ActionTarget key type to str
kywch Aug 16, 2023
68113cf
Merge pull request #107 from CarperAI/str-mask
jsuarez5341 Aug 16, 2023
cc2632c
actions support both str and obj keys
kywch Aug 18, 2023
b74cb2f
Merge pull request #108 from CarperAI/str-atn
jsuarez5341 Aug 19, 2023
f379800
clear obs cache to allow garbage collection
kywch Aug 20, 2023
e9ec8f4
clean up obs during reset too
kywch Aug 20, 2023
fb59d16
caught task-related obj leaks
kywch Aug 20, 2023
0e1166d
added eventlog for loot item/gold
kywch Aug 21, 2023
686ad01
Merge pull request #109 from CarperAI/obs-leak
jsuarez5341 Aug 21, 2023
4f5b24d
tweaked combat cfg, tool use
kywch Aug 22, 2023
f52231e
added support for get event log data by tick
kywch Aug 23, 2023
e83923f
fixed pylint error
kywch Aug 23, 2023
997e15b
Merge pull request #110 from CarperAI/cfg-tweak
jsuarez5341 Aug 23, 2023
693802c
fixed spawn immunity bug/mask
kywch Aug 23, 2023
72c40b0
tweaked agent damages, added health_restore val for reward
kywch Aug 23, 2023
906afb2
tweaked player damage
kywch Aug 23, 2023
f2f9672
set health restore only when health increases
kywch Aug 23, 2023
b9aca7c
record both health inc and dec
kywch Aug 23, 2023
5edd767
tweaked exploration distance as progress toward center
kywch Aug 23, 2023
42aeb53
Merge pull request #112 from CarperAI/fix-immune
daveey Aug 24, 2023
9a82d50
Merge branch '2.0' into tick-event
daveey Aug 24, 2023
4093c14
Merge pull request #111 from CarperAI/tick-event
daveey Aug 24, 2023
8b3e093
cp
daveey Aug 24, 2023
037fbcc
fixed harvest tool bug, event log empty array
kywch Aug 25, 2023
e49cf78
Merge pull request #114 from CarperAI/daveey-eventlog
daveey Aug 25, 2023
1022875
sort obs dict by key to match gym.spaces.Dict
kywch Aug 27, 2023
d6dd351
fixed give gold mask key order
kywch Aug 27, 2023
1219029
undo sort dict, which is covered by pufferlib
kywch Aug 27, 2023
b3446e7
Merge pull request #115 from CarperAI/gym-obs
jsuarez5341 Aug 27, 2023
35ef317
removed all all-zero masks
kywch Aug 28, 2023
7977437
fixed the tests
kywch Aug 28, 2023
eca6938
Merge pull request #116 from CarperAI/no-zero-mask
jsuarez5341 Aug 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ maps/
runs/*
wandb/*

# local replay file from tests/test_deterministic_replay.py, test_render_save.py
# local replay file from test_render_save.py
tests/replay_local*.pickle
replay*
eval*

.vscode

Expand Down Expand Up @@ -162,3 +163,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

profile.run
4 changes: 2 additions & 2 deletions nmmo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .render.overlay import Overlay, OverlayRegistry
from .core import config, agent, action
from .core.action import Action
from .core.agent import Agent
from .core.agent import Agent, Scripted
from .core.env import Env
from .core.terrain import MapGenerator, Terrain

Expand All @@ -22,7 +22,7 @@
\ \:\ \ \:\ \ \:\ \ \::/ maintained at MIT in
\__\/ \__\/ \__\/ \__\/ Phillip Isola's lab '''

__all__ = ['Env', 'config', 'agent', 'Agent', 'MapGenerator', 'Terrain',
__all__ = ['Env', 'config', 'agent', 'Agent', 'Scripted', 'MapGenerator', 'Terrain',
'action', 'Action', 'material', 'spawn',
'Overlay', 'OverlayRegistry']

Expand Down
133 changes: 44 additions & 89 deletions nmmo/core/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# pylint: disable=no-method-argument,unused-argument,no-self-argument,no-member

from enum import Enum, auto
from ordered_set import OrderedSet
import numpy as np
from nmmo.core.observation import Observation

from nmmo.lib import utils
from nmmo.lib.utils import staticproperty
from nmmo.systems.item import Item, Stack
from nmmo.systems.item import Stack
from nmmo.lib.log import EventCode


class NodeType(Enum):
#Tree edges
STATIC = auto() #Traverses all edges without decisions
Expand All @@ -23,7 +24,8 @@ class NodeType(Enum):
class Node(metaclass=utils.IterableNameComparable):
@classmethod
def init(cls, config):
pass
# noop_action is used in some of the N() methods
cls.noop_action = 1 if config.PROVIDE_NOOP_ACTION_TARGET else 0

@staticproperty
def edges():
Expand All @@ -46,12 +48,9 @@ def leaf():
def N(cls, config):
return len(cls.edges)

def deserialize(realm, entity, index):
def deserialize(realm, entity, index, obs: Observation):
return index

def args(stim, entity, config):
return []

class Fixed:
pass

Expand All @@ -75,7 +74,7 @@ def hook(config):
arguments = []
for action in Action.edges(config):
action.init(config)
for args in action.edges:
for args in action.edges: # pylint: disable=not-an-iterable
args.init(config)
if not 'edges' in args.__dict__:
continue
Expand Down Expand Up @@ -105,10 +104,6 @@ def edges(cls, config):
edges.append(Comm)
return edges

def args(stim, entity, config):
raise NotImplementedError


class Move(Node):
priority = 60
nodeType = NodeType.SELECTION
Expand Down Expand Up @@ -139,12 +134,13 @@ def call(realm, entity, direction):
realm.map.tiles[r_new, c_new].add_entity(entity)

# exploration record keeping. moved from entity.py, History.update()
dist_from_spawn = utils.linf(entity.spawn_pos, (r_new, c_new))
if dist_from_spawn > entity.history.exploration:
entity.history.exploration = dist_from_spawn
progress_to_center = realm.map.dist_border_center -\
utils.linf_single(realm.map.center_coord, (r_new, c_new))
if progress_to_center > entity.history.exploration:
entity.history.exploration = progress_to_center
if entity.is_player:
realm.event_log.record(EventCode.GO_FARTHEST, entity,
distance=dist_from_spawn)
distance=progress_to_center)

# CHECK ME: material.Impassible includes void, so this line is not reachable
# Does this belong to Entity/Player.update()?
Expand All @@ -169,18 +165,15 @@ class Direction(Node):
def edges():
return [North, South, East, West, Stay]

def args(stim, entity, config):
return Direction.edges

def deserialize(realm, entity, index):
def deserialize(realm, entity, index, obs: Observation):
return deserialize_fixed_arg(Direction, index)

# a quick helper function
def deserialize_fixed_arg(arg, index):
if isinstance(index, (int, np.int64)):
if index < 0:
return None # so that the action will be discarded
val = min(index-1, len(arg.edges)-1)
val = min(index, len(arg.edges)-1)
return arg.edges[val]

# if index is not int, it's probably already deserialized
Expand All @@ -203,7 +196,6 @@ class West(Node):
class Stay(Node):
delta = (0, 0)


class Attack(Node):
priority = 50
nodeType = NodeType.SELECTION
Expand All @@ -226,7 +218,7 @@ def in_range(entity, stim, config, N):
R, C = stim.shape
R, C = R//2, C//2

rets = OrderedSet([entity])
rets = set([entity])
for r in range(R-N, R+N+1):
for c in range(C-N, C+N+1):
for e in stim[r, c].entities.values():
Expand All @@ -235,14 +227,6 @@ def in_range(entity, stim, config, N):
rets = list(rets)
return rets

# CHECK ME: do we need l1 distance function?
# systems/ai/utils.py also has various distance functions
# which we may want to clean up
# def l1(pos, cent):
# r, c = pos
# r_cent, c_cent = cent
# return abs(r - r_cent) + abs(c - c_cent)

def call(realm, entity, style, target):
if style is None or target is None:
return None
Expand All @@ -256,15 +240,15 @@ def call(realm, entity, style, target):
# Testing a spawn immunity against old agents to avoid spawn camping
immunity = config.COMBAT_SPAWN_IMMUNITY
if entity.is_player and target.is_player and \
target.history.time_alive < immunity < entity.history.time_alive.val:
target.history.time_alive < immunity:
return None

#Check if self targeted
if entity.ent_id == target.ent_id:
return None

#Can't attack out of range
if utils.linf(entity.pos, target.pos) > style.attack_range(config):
if utils.linf_single(entity.pos, target.pos) > style.attack_range(config):
return None

#Execute attack
Expand Down Expand Up @@ -293,28 +277,20 @@ class Style(Node):
def edges():
return [Melee, Range, Mage]

def args(stim, entity, config):
return Style.edges

def deserialize(realm, entity, index):
def deserialize(realm, entity, index, obs: Observation):
return deserialize_fixed_arg(Style, index)


class Target(Node):
argType = None

@classmethod
def N(cls, config):
return config.PLAYER_N_OBS

def deserialize(realm, entity, index: int):
# NOTE: index is the entity id
# CHECK ME: should index be renamed to ent_id?
return realm.entity_or_none(index)
return config.PLAYER_N_OBS + cls.noop_action

def args(stim, entity, config):
#Should pass max range?
return Attack.in_range(entity, stim, config, None)
def deserialize(realm, entity, index: int, obs: Observation):
if index >= len(obs.entities.ids):
return None
return realm.entity_or_none(obs.entities.ids[index])

class Melee(Node):
nodeType = NodeType.ACTION
Expand Down Expand Up @@ -346,27 +322,17 @@ def attack_range(config):
def skill(entity):
return entity.skills.mage


class InventoryItem(Node):
argType = None

@classmethod
def N(cls, config):
return config.INVENTORY_N_OBS

# TODO(kywch): What does args do?
def args(stim, entity, config):
return stim.exchange.items()
return config.INVENTORY_N_OBS + cls.noop_action

def deserialize(realm, entity, index: int):
# NOTE: index is from the inventory, NOT item id
inventory = Item.Query.owned_by(realm.datastore, entity.id.val)

if index >= inventory.shape[0]:
def deserialize(realm, entity, index: int, obs: Observation):
if index >= len(obs.inventory.ids):
return None

item_id = inventory[index, Item.State.attr_name_to_col["id"]]
return realm.items[item_id]
return realm.items.get(obs.inventory.ids[index])

class Use(Node):
priority = 10
Expand Down Expand Up @@ -490,7 +456,6 @@ def call(realm, entity, item, target):

realm.event_log.record(EventCode.GIVE_ITEM, entity)


class GiveGold(Node):
priority = 30

Expand Down Expand Up @@ -528,37 +493,26 @@ def call(realm, entity, amount, target):
if not isinstance(amount, int):
amount = amount.val

if not (amount > 0 and entity.gold.val > 0): # no gold to give
if amount > entity.gold.val: # no gold to give
return

amount = min(amount, entity.gold.val)

entity.gold.decrement(amount)
target.gold.increment(amount)

realm.event_log.record(EventCode.GIVE_GOLD, entity)


class MarketItem(Node):
argType = None

@classmethod
def N(cls, config):
return config.MARKET_N_OBS

# TODO(kywch): What does args do?
def args(stim, entity, config):
return stim.exchange.items()

def deserialize(realm, entity, index: int):
# NOTE: index is from the market, NOT item id
market = Item.Query.for_sale(realm.datastore)
return config.MARKET_N_OBS + cls.noop_action

if index >= market.shape[0]:
def deserialize(realm, entity, index: int, obs: Observation):
if index >= len(obs.market.ids):
return None

item_id = market[index, Item.State.attr_name_to_col["id"]]
return realm.items[item_id]
return realm.items.get(obs.market.ids[index])

class Buy(Node):
priority = 20
Expand Down Expand Up @@ -659,19 +613,24 @@ class Price(Node):
@classmethod
def init(cls, config):
# gold should be > 0
Price.classes = init_discrete(range(1, config.PRICE_N_OBS+1))
cls.price_range = range(1, config.PRICE_N_OBS+1)
Price.classes = init_discrete(cls.price_range)

@classmethod
def index(cls, price):
try:
return cls.price_range.index(price)
except ValueError:
# use the max price, which is config.PRICE_N_OBS
return len(cls.price_range) - 1

@staticproperty
def edges():
return Price.classes

def args(stim, entity, config):
return Price.edges

def deserialize(realm, entity, index):
def deserialize(realm, entity, index, obs: Observation):
return deserialize_fixed_arg(Price, index)


class Token(Node):
argType = Fixed

Expand All @@ -683,13 +642,9 @@ def init(cls, config):
def edges():
return Token.classes

def args(stim, entity, config):
return Token.edges

def deserialize(realm, entity, index):
def deserialize(realm, entity, index, obs: Observation):
return deserialize_fixed_arg(Token, index)


class Comm(Node):
argType = Fixed
priority = 99
Expand Down
14 changes: 13 additions & 1 deletion nmmo/core/agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class Agent:
policy = 'Neural'

Expand All @@ -11,10 +10,23 @@ def __init__(self, config, idx):
'''
self.config = config
self.iden = idx
self._np_random = None

def __call__(self, obs):
'''Used by scripted agents to compute actions. Override in subclasses.

Args:
obs: Agent observation provided by the environment
'''

def set_rng(self, np_random):
'''Set the random number generator for the agent for reproducibility

Args:
np_random: A numpy random.Generator object
'''
self._np_random = np_random

class Scripted(Agent):
'''Base class for scripted agents'''
policy = 'Scripted'