Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Seminar-HFO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
Seminar-HFO
Commits
2a7f23b1
Commit
2a7f23b1
authored
Mar 04, 2015
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added start script for agent. Refactored state variables.
parent
8ad9a9e7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
590 additions
and
126 deletions
+590
-126
bin/Trainer.py
bin/Trainer.py
+23
-17
bin/start_agent.sh
bin/start_agent.sh
+456
-0
src/agent.cpp
src/agent.cpp
+94
-104
src/agent.h
src/agent.h
+17
-5
No files found.
bin/Trainer.py
View file @
2a7f23b1
...
@@ -85,14 +85,19 @@ class Trainer(object):
...
@@ -85,14 +85,19 @@ class Trainer(object):
self
.
_agentTeam
=
self
.
_offenseTeam
self
.
_agentTeam
=
self
.
_offenseTeam
self
.
_agentNumInt
=
1
if
self
.
_numOffense
==
1
\
self
.
_agentNumInt
=
1
if
self
.
_numOffense
==
1
\
else
self
.
_rng
.
randint
(
1
,
self
.
_numOffense
)
else
self
.
_rng
.
randint
(
1
,
self
.
_numOffense
)
numTeammates
=
self
.
_numOffense
-
1
numOpponents
=
self
.
_numDefense
else
:
else
:
assert
self
.
_numDefense
>
0
assert
self
.
_numDefense
>
0
self
.
_agentTeam
=
self
.
_defenseTeam
self
.
_agentTeam
=
self
.
_defenseTeam
self
.
_agentNumInt
=
0
if
self
.
_numDefense
==
1
\
self
.
_agentNumInt
=
0
if
self
.
_numDefense
==
1
\
else
self
.
_rng
.
randint
(
0
,
self
.
_numDefense
)
else
self
.
_rng
.
randint
(
0
,
self
.
_numDefense
)
numTeammates
=
self
.
_numOffense
numOpponents
=
self
.
_numDefense
-
1
self
.
_agentNumExt
=
self
.
convertToExtPlayer
(
self
.
_agentTeam
,
self
.
_agentNumExt
=
self
.
convertToExtPlayer
(
self
.
_agentTeam
,
self
.
_agentNumInt
)
self
.
_agentNumInt
)
agentCmd
=
'start_agent.sh -t
%
s -u
%
i'
%
(
self
.
_agentTeam
,
self
.
_agentNumExt
)
agentCmd
=
'start_agent.sh -t
%
s -u
%
i --numTeammates
%
i --numOpponents
%
i'
\
%
(
self
.
_agentTeam
,
self
.
_agentNumExt
,
numTeammates
,
numOpponents
)
agentCmd
=
agentCmd
.
split
(
' '
)
agentCmd
=
agentCmd
.
split
(
' '
)
# Ignore stderr because librcsc continually prints to it
# Ignore stderr because librcsc continually prints to it
kwargs
=
{
'stderr'
:
open
(
'/dev/null'
,
'w'
)}
kwargs
=
{
'stderr'
:
open
(
'/dev/null'
,
'w'
)}
...
@@ -475,22 +480,23 @@ class Trainer(object):
...
@@ -475,22 +480,23 @@ class Trainer(object):
def
getOffensiveResetPosition
(
self
):
def
getOffensiveResetPosition
(
self
):
""" Returns a random position for an offensive player. """
""" Returns a random position for an offensive player. """
offsets
=
[
# offsets = [
[
-
1
,
-
1
],
# [-1,-1],
[
-
1
,
1
],
# [-1,1],
[
1
,
1
],
# [1,1],
[
1
,
-
1
],
# [1,-1],
[
0
,
2
],
# [0,2],
[
0
,
-
2
],
# [0,-2],
[
-
2
,
-
2
],
# [-2,-2],
[
-
2
,
2
],
# [-2,2],
[
2
,
2
],
# [2,2],
[
2
,
-
2
],
# [2,-2],
]
# ]
offset
=
offsets
[
self
.
_rng
.
randint
(
len
(
offsets
))]
# offset = offsets[self._rng.randint(len(offsets))]
offset_from_ball
=
0.1
*
self
.
PITCH_LENGTH
*
self
.
_rng
.
rand
(
2
)
+
\
# offset_from_ball = 0.1 * self.PITCH_LENGTH * self._rng.rand(2) + \
0.1
*
self
.
PITCH_LENGTH
*
numpy
.
array
(
offset
)
# 0.1 * self.PITCH_LENGTH * numpy.array(offset)
return
self
.
boundPoint
(
self
.
_ballPosition
+
offset_from_ball
)
# return self.boundPoint(self._ballPosition + offset_from_ball)
return
self
.
_ballPosition
def
getDefensiveResetPosition
(
self
):
def
getDefensiveResetPosition
(
self
):
""" Returns a random position for a defensive player. """
""" Returns a random position for a defensive player. """
...
...
bin/start_agent.sh
0 → 100755
View file @
2a7f23b1
This diff is collapsed.
Click to expand it.
src/agent.cpp
View file @
2a7f23b1
This diff is collapsed.
Click to expand it.
src/agent.h
View file @
2a7f23b1
...
@@ -37,8 +37,7 @@
...
@@ -37,8 +37,7 @@
class
Agent
:
public
rcsc
::
PlayerAgent
{
class
Agent
:
public
rcsc
::
PlayerAgent
{
public:
public:
Agent
();
Agent
();
virtual
~
Agent
();
virtual
~
Agent
()
{};
std
::
vector
<
float
>
getState
();
virtual
FieldEvaluator
::
ConstPtr
getFieldEvaluator
()
const
;
virtual
FieldEvaluator
::
ConstPtr
getFieldEvaluator
()
const
;
protected:
protected:
...
@@ -59,11 +58,24 @@ protected:
...
@@ -59,11 +58,24 @@ protected:
virtual
FieldEvaluator
::
ConstPtr
createFieldEvaluator
()
const
;
virtual
FieldEvaluator
::
ConstPtr
createFieldEvaluator
()
const
;
virtual
ActionGenerator
::
ConstPtr
createActionGenerator
()
const
;
virtual
ActionGenerator
::
ConstPtr
createActionGenerator
()
const
;
private:
// Updated the state features stored in feature_vec
void
updateStateFeatures
();
// Add the angle and distance to the landmark to the feature_vec
// Add the angle and distance to the landmark to the feature_vec
void
addLandmarkFeature
(
const
rcsc
::
Vector2D
&
landmark
,
void
addLandmarkFeature
(
const
rcsc
::
Vector2D
&
landmark
,
const
rcsc
::
Vector2D
&
self_pos
,
const
rcsc
::
Vector2D
&
self_pos
);
std
::
vector
<
float
>&
feature_vec
);
int
numTeammates
;
int
numOpponents
;
int
numFeatures
;
// Total number of features
// Number of features for non-player objects. Clearly this is the answer.
const
static
int
num_basic_features
=
42
;
// Number of features for each player or opponent in game.
const
static
int
features_per_player
=
5
;
std
::
vector
<
float
>
feature_vec
;
// Contains the current features
int
featIndx
;
// Feature being populated
private:
bool
doPreprocess
();
bool
doPreprocess
();
bool
doShoot
();
bool
doShoot
();
bool
doForceKick
();
bool
doForceKick
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment