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
de23d119
You need to sign in or sign up before continuing.
Commit
de23d119
authored
Jan 26, 2016
by
sanmit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor updates
parent
baa4413c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
24 deletions
+27
-24
bin/Trainer.py
bin/Trainer.py
+6
-3
example/communication_agent.py
example/communication_agent.py
+2
-2
example/high_level_random_agent.cpp
example/high_level_random_agent.cpp
+2
-2
example/mid_level_kick_agent.cpp
example/mid_level_kick_agent.cpp
+0
-6
hfo/hfo.py
hfo/hfo.py
+2
-2
src/HFO.cpp
src/HFO.cpp
+7
-5
src/HFO.hpp
src/HFO.hpp
+7
-2
src/agent.h
src/agent.h
+1
-2
No files found.
bin/Trainer.py
View file @
de23d119
...
@@ -215,20 +215,23 @@ class Trainer(object):
...
@@ -215,20 +215,23 @@ class Trainer(object):
assert
body
[
0
]
==
'referee'
,
'Expected referee message.'
assert
body
[
0
]
==
'referee'
,
'Expected referee message.'
_
,
ts
,
event
=
body
_
,
ts
,
event
=
body
self
.
_frame
=
int
(
ts
)
self
.
_frame
=
int
(
ts
)
endOfTrial
=
False
if
'GOAL'
in
event
:
if
'GOAL'
in
event
:
self
.
_numGoals
+=
1
self
.
_numGoals
+=
1
self
.
_numGoalFrames
+=
self
.
_frame
-
self
.
_lastTrialStart
self
.
_numGoalFrames
+=
self
.
_frame
-
self
.
_lastTrialStart
e
vent
=
'GOAL'
e
ndOfTrial
=
True
elif
event
==
'OUT_OF_BOUNDS'
:
elif
event
==
'OUT_OF_BOUNDS'
:
self
.
_numBallsOOB
+=
1
self
.
_numBallsOOB
+=
1
endOfTrial
=
True
elif
'CAPTURED_BY_DEFENSE'
in
event
:
elif
'CAPTURED_BY_DEFENSE'
in
event
:
self
.
_numBallsCaptured
+=
1
self
.
_numBallsCaptured
+=
1
e
vent
=
"CAPTURED_BY_DEFENSE"
# This clears the defender number from the printout below, but it doesn't really matter here.
e
ndOfTrial
=
True
elif
event
==
'OUT_OF_TIME'
:
elif
event
==
'OUT_OF_TIME'
:
self
.
_numOutOfTime
+=
1
self
.
_numOutOfTime
+=
1
endOfTrial
=
True
elif
event
==
'HFO_FINISHED'
:
elif
event
==
'HFO_FINISHED'
:
self
.
_done
=
True
self
.
_done
=
True
if
e
vent
in
{
'GOAL'
,
'OUT_OF_BOUNDS'
,
'CAPTURED_BY_DEFENSE'
,
'OUT_OF_TIME'
}:
if
e
ndOfTrial
:
self
.
_numTrials
+=
1
self
.
_numTrials
+=
1
print
'EndOfTrial:
%
d /
%
d
%
d
%
s'
%
\
print
'EndOfTrial:
%
d /
%
d
%
d
%
s'
%
\
(
self
.
_numGoals
,
self
.
_numTrials
,
self
.
_frame
,
event
)
(
self
.
_numGoals
,
self
.
_numTrials
,
self
.
_frame
,
event
)
...
...
example/communication_agent.py
View file @
de23d119
...
@@ -42,9 +42,9 @@ if __name__ == '__main__':
...
@@ -42,9 +42,9 @@ if __name__ == '__main__':
print
'Episode'
,
episode
,
'ended with'
,
print
'Episode'
,
episode
,
'ended with'
,
# Check what the outcome of the episode was
# Check what the outcome of the episode was
if
status
==
HFO_Status
.
GOAL
:
if
status
==
HFO_Status
.
GOAL
:
print
'goal'
print
'goal'
,
hfo
.
playerOnBall
()
.
unum
elif
status
==
HFO_Status
.
CAPTURED_BY_DEFENSE
:
elif
status
==
HFO_Status
.
CAPTURED_BY_DEFENSE
:
print
'captured by defense'
print
'captured by defense'
,
hfo
.
playerOnBall
()
.
unum
elif
status
==
HFO_Status
.
OUT_OF_BOUNDS
:
elif
status
==
HFO_Status
.
OUT_OF_BOUNDS
:
print
'out of bounds'
print
'out of bounds'
elif
status
==
HFO_Status
.
OUT_OF_TIME
:
elif
status
==
HFO_Status
.
OUT_OF_TIME
:
...
...
example/high_level_random_agent.cpp
View file @
de23d119
...
@@ -41,10 +41,10 @@ int main(int argc, char** argv) {
...
@@ -41,10 +41,10 @@ int main(int argc, char** argv) {
cout
<<
"Episode "
<<
episode
<<
" ended with status: "
;
cout
<<
"Episode "
<<
episode
<<
" ended with status: "
;
switch
(
status
)
{
switch
(
status
)
{
case
GOAL
:
case
GOAL
:
cout
<<
"goal
"
<<
endl
;
cout
<<
"goal
"
<<
hfo
.
playerOnBall
().
unum
<<
endl
;
break
;
break
;
case
CAPTURED_BY_DEFENSE
:
case
CAPTURED_BY_DEFENSE
:
cout
<<
"captured by defense "
<<
endl
;
cout
<<
"captured by defense "
<<
hfo
.
playerOnBall
().
unum
<<
endl
;
break
;
break
;
case
OUT_OF_BOUNDS
:
case
OUT_OF_BOUNDS
:
cout
<<
"out of bounds"
<<
endl
;
cout
<<
"out of bounds"
<<
endl
;
...
...
example/mid_level_kick_agent.cpp
View file @
de23d119
...
@@ -46,7 +46,6 @@ int main(int argc, char** argv) {
...
@@ -46,7 +46,6 @@ int main(int argc, char** argv) {
// Advance the environment and get the game status
// Advance the environment and get the game status
status
=
hfo
.
step
();
status
=
hfo
.
step
();
}
}
// Check what the outcome of the episode was
// Check what the outcome of the episode was
cout
<<
"Episode "
<<
episode
<<
" ended with status: "
;
cout
<<
"Episode "
<<
episode
<<
" ended with status: "
;
switch
(
status
)
{
switch
(
status
)
{
...
@@ -66,11 +65,6 @@ int main(int argc, char** argv) {
...
@@ -66,11 +65,6 @@ int main(int argc, char** argv) {
cout
<<
"Unknown status "
<<
status
<<
endl
;
cout
<<
"Unknown status "
<<
status
<<
endl
;
exit
(
1
);
exit
(
1
);
}
}
}
}
hfo
.
act
(
QUIT
);
hfo
.
act
(
QUIT
);
};
};
hfo/hfo.py
View file @
de23d119
...
@@ -170,8 +170,8 @@ class HFOEnvironment(object):
...
@@ -170,8 +170,8 @@ class HFOEnvironment(object):
# Get the current game status
# Get the current game status
data
=
self
.
socket
.
recv
(
struct
.
calcsize
(
"iii"
))
data
=
self
.
socket
.
recv
(
struct
.
calcsize
(
"iii"
))
status
=
struct
.
unpack
(
"iii"
,
data
)[
0
]
status
,
side
,
unum
=
struct
.
unpack
(
"iii"
,
data
)
self
.
player_on_ball
=
HFO_Player
(
s
truct
.
unpack
(
"iii"
,
data
)[
1
],
struct
.
unpack
(
"iii"
,
data
)[
2
]
)
self
.
player_on_ball
=
HFO_Player
(
s
ide
,
unum
)
# Get the next state features
# Get the next state features
state_data
=
self
.
socket
.
recv
(
struct
.
calcsize
(
'f'
)
*
self
.
numFeatures
)
state_data
=
self
.
socket
.
recv
(
struct
.
calcsize
(
'f'
)
*
self
.
numFeatures
)
...
...
src/HFO.cpp
View file @
de23d119
...
@@ -248,8 +248,8 @@ void HFOEnvironment::handshakeAgentServer(feature_set_t feature_set) {
...
@@ -248,8 +248,8 @@ void HFOEnvironment::handshakeAgentServer(feature_set_t feature_set) {
exit
(
1
);
exit
(
1
);
}
}
// Recieve the game status
// Recieve the game status
std
::
vector
<
int
>
game_status
(
3
,
-
1
)
;
int
game_status
[
3
]
;
if
(
recv
(
sockfd
,
&
(
game_status
.
front
()
),
3
*
sizeof
(
int
),
0
)
<
0
)
{
if
(
recv
(
sockfd
,
&
(
game_status
[
0
]
),
3
*
sizeof
(
int
),
0
)
<
0
)
{
perror
(
"[Agent Client] ERROR receiving game status from socket"
);
perror
(
"[Agent Client] ERROR receiving game status from socket"
);
close
(
sockfd
);
close
(
sockfd
);
exit
(
1
);
exit
(
1
);
...
@@ -259,6 +259,8 @@ void HFOEnvironment::handshakeAgentServer(feature_set_t feature_set) {
...
@@ -259,6 +259,8 @@ void HFOEnvironment::handshakeAgentServer(feature_set_t feature_set) {
close
(
sockfd
);
close
(
sockfd
);
exit
(
1
);
exit
(
1
);
}
}
player_on_ball
.
side
=
(
SideID
)
game_status
[
1
];
player_on_ball
.
unum
=
game_status
[
2
];
std
::
cout
<<
"[Agent Client] Handshake complete"
<<
std
::
endl
;
std
::
cout
<<
"[Agent Client] Handshake complete"
<<
std
::
endl
;
}
}
...
@@ -332,14 +334,14 @@ status_t HFOEnvironment::step() {
...
@@ -332,14 +334,14 @@ status_t HFOEnvironment::step() {
say_msg
.
clear
();
say_msg
.
clear
();
// Get the game status
// Get the game status
std
::
vector
<
int
>
full_status
(
3
,
-
1
)
;
int
full_status
[
3
]
;
if
(
recv
(
sockfd
,
&
(
full_status
.
front
()
),
3
*
sizeof
(
int
),
0
)
<
0
)
{
if
(
recv
(
sockfd
,
&
(
full_status
[
0
]
),
3
*
sizeof
(
int
),
0
)
<
0
)
{
perror
(
"[Agent Client] ERROR receiving game status from socket"
);
perror
(
"[Agent Client] ERROR receiving game status from socket"
);
close
(
sockfd
);
close
(
sockfd
);
exit
(
1
);
exit
(
1
);
}
}
game_status
=
(
status_t
)
full_status
[
0
];
game_status
=
(
status_t
)
full_status
[
0
];
player_on_ball
.
side
=
(
rcsc
::
SideID
)
full_status
[
1
];
player_on_ball
.
side
=
(
SideID
)
full_status
[
1
];
player_on_ball
.
unum
=
full_status
[
2
];
player_on_ball
.
unum
=
full_status
[
2
];
// Get the next game state
// Get the next game state
...
...
src/HFO.hpp
View file @
de23d119
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <rcsc/types.h>
namespace
hfo
{
namespace
hfo
{
...
@@ -53,6 +52,12 @@ enum status_t
...
@@ -53,6 +52,12 @@ enum status_t
OUT_OF_TIME
// Trial has ended due to time limit
OUT_OF_TIME
// Trial has ended due to time limit
};
};
enum
SideID
{
RIGHT
=
-
1
,
NEUTRAL
=
0
,
LEFT
=
1
};
// Configuration of the HFO domain including the team names and player
// Configuration of the HFO domain including the team names and player
// numbers for each team. This struct is populated by ParseConfig().
// numbers for each team. This struct is populated by ParseConfig().
struct
Config
{
struct
Config
{
...
@@ -65,7 +70,7 @@ struct Config {
...
@@ -65,7 +70,7 @@ struct Config {
};
};
struct
Player
{
struct
Player
{
rcsc
::
SideID
side
;
// SideID is an enum: 1 = LEFT, 0 = NEUTRAL, -1 = RIGHT
SideID
side
;
int
unum
;
int
unum
;
};
};
...
...
src/agent.h
View file @
de23d119
...
@@ -34,7 +34,6 @@
...
@@ -34,7 +34,6 @@
#include "feature_extractor.h"
#include "feature_extractor.h"
#include <rcsc/player/player_agent.h>
#include <rcsc/player/player_agent.h>
#include <rcsc/types.h>
#include <vector>
#include <vector>
class
Agent
:
public
rcsc
::
PlayerAgent
{
class
Agent
:
public
rcsc
::
PlayerAgent
{
...
@@ -43,7 +42,7 @@ public:
...
@@ -43,7 +42,7 @@ public:
virtual
~
Agent
();
virtual
~
Agent
();
virtual
FieldEvaluator
::
ConstPtr
getFieldEvaluator
()
const
;
virtual
FieldEvaluator
::
ConstPtr
getFieldEvaluator
()
const
;
// Get the current game status
// Get the current game status
, and the side and uniform number of the player holding the ball
static
std
::
vector
<
int
>
getGameStatus
(
const
rcsc
::
AudioSensor
&
audio_sensor
,
static
std
::
vector
<
int
>
getGameStatus
(
const
rcsc
::
AudioSensor
&
audio_sensor
,
long
&
lastTrainerMessageTime
);
long
&
lastTrainerMessageTime
);
...
...
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