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
2311a7d8
Commit
2311a7d8
authored
Mar 13, 2015
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced normalization for all of the state features.
parent
fe5ddaf2
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
246 additions
and
105 deletions
+246
-105
bin/Trainer.py
bin/Trainer.py
+4
-3
bin/start.py
bin/start.py
+2
-0
bin/start_agent.sh
bin/start_agent.sh
+10
-0
src/agent.cpp
src/agent.cpp
+186
-85
src/agent.h
src/agent.h
+44
-17
No files found.
bin/Trainer.py
View file @
2311a7d8
...
@@ -63,6 +63,7 @@ class Trainer(object):
...
@@ -63,6 +63,7 @@ class Trainer(object):
self
.
_agentTeam
=
''
# Name of the team the agent is playing for
self
.
_agentTeam
=
''
# Name of the team the agent is playing for
self
.
_agentNumInt
=
-
1
# Agent's internal team number
self
.
_agentNumInt
=
-
1
# Agent's internal team number
self
.
_agentNumExt
=
-
1
# Agent's external team number
self
.
_agentNumExt
=
-
1
# Agent's external team number
self
.
_agentServerPort
=
args
.
serverPort
# Port for agent's server
# =============== MISC =============== #
# =============== MISC =============== #
self
.
_offenseTeam
=
''
# Name of the offensive team
self
.
_offenseTeam
=
''
# Name of the offensive team
self
.
_defenseTeam
=
''
# Name of the defensive team
self
.
_defenseTeam
=
''
# Name of the defensive team
...
@@ -97,12 +98,12 @@ class Trainer(object):
...
@@ -97,12 +98,12 @@ class Trainer(object):
self
.
_agentNumExt
=
self
.
convertToExtPlayer
(
self
.
_agentTeam
,
self
.
_agentNumExt
=
self
.
convertToExtPlayer
(
self
.
_agentTeam
,
self
.
_agentNumInt
)
self
.
_agentNumInt
)
agentCmd
=
'start_agent.sh -t
%
s -u
%
i --numTeammates
%
i --numOpponents
%
i'
\
agentCmd
=
'start_agent.sh -t
%
s -u
%
i --numTeammates
%
i --numOpponents
%
i'
\
' --playingOffense
%
i'
\
' --playingOffense
%
i
--serverPort
%
i
'
\
%
(
self
.
_agentTeam
,
self
.
_agentNumExt
,
numTeammates
,
numOpponents
,
%
(
self
.
_agentTeam
,
self
.
_agentNumExt
,
numTeammates
,
numOpponents
,
self
.
_agent_play_offense
)
self
.
_agent_play_offense
,
self
.
_agentServerPort
)
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')}
p
=
subprocess
.
Popen
(
agentCmd
,
**
kwargs
)
p
=
subprocess
.
Popen
(
agentCmd
,
**
kwargs
)
p
.
wait
()
p
.
wait
()
with
open
(
'/tmp/start
%
i'
%
p
.
pid
,
'r'
)
as
f
:
with
open
(
'/tmp/start
%
i'
%
p
.
pid
,
'r'
)
as
f
:
...
...
bin/start.py
View file @
2311a7d8
...
@@ -101,6 +101,8 @@ def parseArgs(args=None):
...
@@ -101,6 +101,8 @@ def parseArgs(args=None):
help
=
'Don
\'
t use a learning agent.'
)
help
=
'Don
\'
t use a learning agent.'
)
p
.
add_argument
(
'--no-sync'
,
dest
=
'sync'
,
action
=
'store_false'
,
default
=
True
,
p
.
add_argument
(
'--no-sync'
,
dest
=
'sync'
,
action
=
'store_false'
,
default
=
True
,
help
=
'Run server in non-sync mode'
)
help
=
'Run server in non-sync mode'
)
p
.
add_argument
(
'--server-port'
,
dest
=
'serverPort'
,
type
=
int
,
default
=
6008
,
help
=
'Port to run agent server on.'
)
return
p
.
parse_args
(
args
=
args
)
return
p
.
parse_args
(
args
=
args
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
bin/start_agent.sh
View file @
2311a7d8
...
@@ -77,6 +77,7 @@ usage()
...
@@ -77,6 +77,7 @@ usage()
echo
" --numTeammates NUM number of teammates"
echo
" --numTeammates NUM number of teammates"
echo
" --numOpponents NUM number of opponents"
echo
" --numOpponents NUM number of opponents"
echo
" --playingOffense [0|1] are we playing offense or defense"
echo
" --playingOffense [0|1] are we playing offense or defense"
echo
" --serverPort NUM port for server to list on"
echo
" --seed NUM seed for rng"
echo
" --seed NUM seed for rng"
echo
" --gdb runs with gdb on (default:off)"
echo
" --gdb runs with gdb on (default:off)"
)
1>&2
)
1>&2
...
@@ -265,6 +266,15 @@ do
...
@@ -265,6 +266,15 @@ do
shift
1
shift
1
;;
;;
--serverPort
)
if
[
$#
-lt
2
]
;
then
usage
exit
1
fi
opts
=
"
${
opts
}
--serverPort
${
2
}
"
shift
1
;;
--seed
)
--seed
)
if
[
$#
-lt
2
]
;
then
if
[
$#
-lt
2
]
;
then
usage
usage
...
...
src/agent.cpp
View file @
2311a7d8
This diff is collapsed.
Click to expand it.
src/agent.h
View file @
2311a7d8
...
@@ -90,28 +90,57 @@ protected:
...
@@ -90,28 +90,57 @@ protected:
// Get the current game status
// Get the current game status
hfo_status_t
getGameStatus
();
hfo_status_t
getGameStatus
();
// Encodes an angle feature as the sin and cosine of that angle,
// effectively transforming a single angle into two features.
void
addAngFeature
(
const
rcsc
::
AngleDeg
&
ang
);
// Encodes a proximity feature which is defined by a distance as
// well as a maximum possible distance, which acts as a
// normalizer. Encodes the distance as [0-far, 1-close]. Ignores
// distances greater than maxDist or less than 0.
void
addDistFeature
(
float
dist
,
float
maxDist
);
// 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
addLandmarkFeatures
(
const
rcsc
::
Vector2D
&
landmark
,
const
rcsc
::
Vector2D
&
self_pos
);
const
rcsc
::
Vector2D
&
self_pos
,
const
rcsc
::
AngleDeg
&
self_ang
);
// Add features corresponding to another player.
void
addPlayerFeatures
(
rcsc
::
PlayerObject
&
player
,
const
rcsc
::
Vector2D
&
self_pos
,
const
rcsc
::
AngleDeg
&
self_ang
);
// Start the server and listen for a connection.
void
startServer
(
int
server_port
=
6008
);
int
numTeammates
;
// Transmit information to the client and ensure it can recieve.
int
numOpponents
;
void
clientHandshake
();
protected:
int
numTeammates
;
// Number of teammates in HFO
int
numOpponents
;
// Number of opponents in HFO
bool
playingOffense
;
// Are we playing offense or defense?
bool
playingOffense
;
// Are we playing offense or defense?
int
numFeatures
;
// Total number of features
int
numFeatures
;
// Total number of features
// Number of features for non-player objects.
Clearly this is the answer.
// Number of features for non-player objects.
const
static
int
num_basic_features
=
42
;
const
static
int
num_basic_features
=
58
;
// Number of features for each player or opponent in game.
// Number of features for each player or opponent in game.
const
static
int
features_per_player
=
5
;
const
static
int
features_per_player
=
8
;
std
::
vector
<
float
>
feature_vec
;
// Contains the current features
int
featIndx
;
// Feature being populated
int
featIndx
;
// Feature being populated
const
static
int
server_port
=
6008
;
std
::
vector
<
float
>
feature_vec
;
// Contains the current features
long
lastTrainerMessageTime
;
// Last time the trainer sent a message
bool
episode_start
;
// True only in the timestep that the game is starting
// Start the server and listen for a connection.
// Observed values of some parameters.
virtual
void
startServer
();
const
static
float
observedSelfSpeedMax
=
0.46
;
// Transmit information to the client and ensure it can recieve.
const
static
float
observedPlayerSpeedMax
=
0.75
;
virtual
void
clientHandshake
();
const
static
float
observedStaminaMax
=
8000.
;
const
static
float
observedBallSpeedMax
=
3.0
;
float
maxHFORadius
;
// Maximum possible distance in HFO playable region
// Useful measures defined by the Server Parameters
float
pitchLength
,
pitchWidth
,
pitchHalfLength
,
pitchHalfWidth
,
goalHalfWidth
,
penaltyAreaLength
,
penaltyAreaWidth
;
long
lastTrainerMessageTime
;
// Last time the trainer sent a message
int
server_port
;
// Port to start the server on
bool
server_running
;
// Is the server running?
int
sockfd
,
newsockfd
;
// Server sockets
private:
private:
bool
doPreprocess
();
bool
doPreprocess
();
...
@@ -122,8 +151,6 @@ protected:
...
@@ -122,8 +151,6 @@ protected:
Communication
::
Ptr
M_communication
;
Communication
::
Ptr
M_communication
;
FieldEvaluator
::
ConstPtr
M_field_evaluator
;
FieldEvaluator
::
ConstPtr
M_field_evaluator
;
ActionGenerator
::
ConstPtr
M_action_generator
;
ActionGenerator
::
ConstPtr
M_action_generator
;
bool
server_running
;
// Is the server running?
int
sockfd
,
newsockfd
;
// Server sockets
};
};
#endif
#endif
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