Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
neural-mmo-starter-kit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Neural MMO
neural-mmo-starter-kit
Commits
f43da181
Commit
f43da181
authored
3 years ago
by
Siddhartha Laghuvarapu
Browse files
Options
Downloads
Patches
Plain Diff
Fix rollout.py
parent
685dec5f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
evaluator/rollout.py
+49
-2
49 additions, 2 deletions
evaluator/rollout.py
with
49 additions
and
2 deletions
evaluator/rollout.py
+
49
−
2
View file @
f43da181
...
...
@@ -13,6 +13,54 @@ from config import LocalEvaluationConfig
import
random
import
copy
class
ProxyEnv
(
Env
):
def
step
(
self
,
actions
,
preprocess
=
set
(),
omitDead
=
True
):
#Preprocess actions
for
entID
in
preprocess
:
ent
=
self
.
realm
.
players
[
entID
]
if
not
ent
.
alive
:
continue
for
atn
,
args
in
actions
[
entID
].
items
():
for
arg
,
val
in
args
.
items
():
if
len
(
arg
.
edges
)
>
0
:
actions
[
entID
][
atn
][
arg
]
=
arg
.
edges
[
val
]
elif
val
<
len
(
ent
.
targets
):
targ
=
ent
.
targets
[
val
]
actions
[
entID
][
atn
][
arg
]
=
self
.
realm
.
entity
(
targ
)
else
:
#Need to fix -inf in classifier before removing this
actions
[
entID
][
atn
][
arg
]
=
ent
#Step: Realm, Observations, Logs
self
.
dead
=
self
.
realm
.
step
(
actions
)
obs
,
rewards
,
dones
,
self
.
raw
=
{},
{},
{},
{}
for
entID
,
ent
in
self
.
realm
.
players
.
items
():
ob
=
self
.
realm
.
dataframe
.
get
(
ent
)
obs
[
entID
]
=
ob
self
.
dummy_ob
=
ob
rewards
[
entID
]
=
self
.
reward
(
ent
)
dones
[
entID
]
=
False
#self.steps += len(self.realm.players.items())
#print('World {} Tick {} Steps {}'.format(self.worldIdx, self.realm.tick, self.steps))
for
entID
,
ent
in
self
.
dead
.
items
():
self
.
log
(
ent
)
#Postprocess dead agents
if
omitDead
:
return
obs
,
rewards
,
dones
,
{}
for
entID
,
ent
in
self
.
dead
.
items
():
rewards
[
ent
.
entID
]
=
self
.
reward
(
ent
)
dones
[
ent
.
entID
]
=
True
obs
[
ent
.
entID
]
=
self
.
dummy_ob
return
obs
,
rewards
,
dones
,
{}
def
assign_agents
(
player_agent
,
opponent_agents
):
player_index
=
0
...
...
@@ -27,7 +75,7 @@ def assign_agents(player_agent, opponent_agents):
def
run_episode
(
player_index
,
agents
,
N_TIME_STEPS
):
config
=
projekt
.
config
.
CompetitionRound1
()
env
=
Env
(
config
)
env
=
Proxy
Env
(
config
)
n_steps
=
0
neural_agents
=
set
()
dead_agents
=
[]
...
...
@@ -53,7 +101,6 @@ def run_episode(player_index, agents, N_TIME_STEPS):
if
Action
.
Attack
in
actions
[
entid
]:
targID
=
actions
[
entid
][
Action
.
Attack
][
Action
.
Target
]
actions
[
entid
][
Action
.
Attack
][
Action
.
Target
]
=
realm
.
entity
(
targID
)
print
(
actions
)
obs
,
dones
,
rewards
,
_
=
env
.
step
(
actions
,
omitDead
=
True
,
preprocess
=
neural_agents
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment