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
e074f351
Commit
e074f351
authored
Jun 01, 2015
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for elog missing issue.
parent
ec2fa47f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
13 deletions
+29
-13
CMakeLists.txt
CMakeLists.txt
+2
-0
src/agent.cpp
src/agent.cpp
+25
-12
src/agent.h
src/agent.h
+0
-1
src/feature_extractor.cpp
src/feature_extractor.cpp
+2
-0
No files found.
CMakeLists.txt
View file @
e074f351
...
@@ -4,6 +4,8 @@ project(hfo)
...
@@ -4,6 +4,8 @@ project(hfo)
# Change these to reflect the location of your librcsc-4.1.0 install
# Change these to reflect the location of your librcsc-4.1.0 install
set
(
LIBRCSC_INCLUDE ~/.local/include
)
set
(
LIBRCSC_INCLUDE ~/.local/include
)
set
(
LIBRCSC_LINK ~/.local/lib
)
set
(
LIBRCSC_LINK ~/.local/lib
)
# Add this definition if using Librcsc from https://github.com/mhauskn/librcsc
# add_definitions(-DELOG)
set
(
SOURCE_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
set
(
SOURCE_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY bin
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY bin
)
...
...
src/agent.cpp
View file @
e074f351
...
@@ -137,8 +137,7 @@ Agent::Agent()
...
@@ -137,8 +137,7 @@ Agent::Agent()
M_action_generator
(
createActionGenerator
()),
M_action_generator
(
createActionGenerator
()),
lastTrainerMessageTime
(
-
1
),
lastTrainerMessageTime
(
-
1
),
server_port
(
6008
),
server_port
(
6008
),
server_running
(
false
),
server_running
(
false
)
record
(
false
)
{
{
boost
::
shared_ptr
<
AudioMemory
>
audio_memory
(
new
AudioMemory
);
boost
::
shared_ptr
<
AudioMemory
>
audio_memory
(
new
AudioMemory
);
...
@@ -202,25 +201,35 @@ bool Agent::initImpl(CmdLineParser & cmd_parser) {
...
@@ -202,25 +201,35 @@ bool Agent::initImpl(CmdLineParser & cmd_parser) {
int
numTeammates
,
numOpponents
;
int
numTeammates
,
numOpponents
;
bool
playingOffense
;
bool
playingOffense
;
rcsc
::
ParamMap
my_params
(
"Additional options"
);
rcsc
::
ParamMap
my_params
(
"Additional options"
);
my_params
.
add
()(
"numTeammates"
,
""
,
&
numTeammates
,
"number of teammates"
);
my_params
.
add
()
my_params
.
add
()(
"numOpponents"
,
""
,
&
numOpponents
,
"number of opponents"
);
(
"numTeammates"
,
""
,
&
numTeammates
)
my_params
.
add
()(
"playingOffense"
,
""
,
&
playingOffense
,
(
"numOpponents"
,
""
,
&
numOpponents
)
"are we playing offense or defense"
);
(
"playingOffense"
,
""
,
&
playingOffense
)
my_params
.
add
()(
"serverPort"
,
""
,
&
server_port
,
"Port to start server on"
);
(
"serverPort"
,
""
,
&
server_port
);
record
=
cmd_parser
.
count
(
"record"
)
>
0
;
cmd_parser
.
parse
(
my_params
);
cmd_parser
.
parse
(
my_params
);
if
(
cmd_parser
.
count
(
"help"
)
>
0
)
{
if
(
cmd_parser
.
count
(
"help"
)
>
0
)
{
my_params
.
printHelp
(
std
::
cout
);
my_params
.
printHelp
(
std
::
cout
);
return
false
;
return
false
;
}
}
if
(
cmd_parser
.
failed
())
{
if
(
cmd_parser
.
failed
())
{
std
::
cerr
<<
"player: ***WARNING*** detected unsuppprted options: "
;
std
::
cerr
<<
"player: ***WARNING*** detected unsuppprted options: "
;
cmd_parser
.
print
(
std
::
cerr
);
cmd_parser
.
print
(
std
::
cerr
);
std
::
cerr
<<
std
::
endl
;
std
::
cerr
<<
std
::
endl
;
}
}
#ifdef ELOG
#else
const
std
::
list
<
std
::
string
>&
args
=
cmd_parser
.
args
();
if
(
std
::
find
(
args
.
begin
(),
args
.
end
(),
"--record"
)
!=
args
.
end
())
{
std
::
cerr
<<
"[Agent Client] ERROR: Action recording requested but no supported."
<<
" To enable action recording, install https://github.com/mhauskn/librcsc"
<<
" and recompile with -DELOG. See CMakeLists.txt"
<<
std
::
endl
;
return
false
;
}
#endif
if
(
!
result
)
{
if
(
!
result
)
{
return
false
;
return
false
;
}
}
...
@@ -340,11 +349,15 @@ void Agent::actionImpl() {
...
@@ -340,11 +349,15 @@ void Agent::actionImpl() {
// Update and send the state features
// Update and send the state features
const
std
::
vector
<
float
>&
features
=
const
std
::
vector
<
float
>&
features
=
feature_extractor
->
ExtractFeatures
(
this
->
world
());
feature_extractor
->
ExtractFeatures
(
this
->
world
());
if
(
record
)
{
#ifdef ELOG
if
(
config
().
record
())
{
elog
.
addText
(
Logger
::
WORLD
,
"GameStatus %d"
,
game_status
);
elog
.
addText
(
Logger
::
WORLD
,
"GameStatus %d"
,
game_status
);
elog
.
flush
();
elog
.
flush
();
feature_extractor
->
LogFeatures
();
feature_extractor
->
LogFeatures
();
}
}
#endif
if
(
send
(
newsockfd
,
&
(
features
.
front
()),
if
(
send
(
newsockfd
,
&
(
features
.
front
()),
features
.
size
()
*
sizeof
(
float
),
0
)
<
0
)
{
features
.
size
()
*
sizeof
(
float
),
0
)
<
0
)
{
error
(
"[Agent Server] ERROR sending state features from socket"
);
error
(
"[Agent Server] ERROR sending state features from socket"
);
...
...
src/agent.h
View file @
e074f351
...
@@ -75,7 +75,6 @@ protected:
...
@@ -75,7 +75,6 @@ protected:
int
server_port
;
// Port to start the server on
int
server_port
;
// Port to start the server on
bool
server_running
;
// Is the server running?
bool
server_running
;
// Is the server running?
int
sockfd
,
newsockfd
;
// Server sockets
int
sockfd
,
newsockfd
;
// Server sockets
bool
record
;
// Record states + actions
private:
private:
bool
doPreprocess
();
bool
doPreprocess
();
...
...
src/feature_extractor.cpp
View file @
e074f351
...
@@ -31,6 +31,7 @@ FeatureExtractor::FeatureExtractor() :
...
@@ -31,6 +31,7 @@ FeatureExtractor::FeatureExtractor() :
FeatureExtractor
::~
FeatureExtractor
()
{}
FeatureExtractor
::~
FeatureExtractor
()
{}
void
FeatureExtractor
::
LogFeatures
()
{
void
FeatureExtractor
::
LogFeatures
()
{
#ifdef ELOG
assert
(
feature_vec
.
size
()
==
numFeatures
);
assert
(
feature_vec
.
size
()
==
numFeatures
);
std
::
stringstream
ss
;
std
::
stringstream
ss
;
for
(
int
i
=
0
;
i
<
numFeatures
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numFeatures
;
++
i
)
{
...
@@ -38,6 +39,7 @@ void FeatureExtractor::LogFeatures() {
...
@@ -38,6 +39,7 @@ void FeatureExtractor::LogFeatures() {
}
}
elog
.
addText
(
Logger
::
WORLD
,
"StateFeatures %s"
,
ss
.
str
().
c_str
());
elog
.
addText
(
Logger
::
WORLD
,
"StateFeatures %s"
,
ss
.
str
().
c_str
());
elog
.
flush
();
elog
.
flush
();
#endif
}
}
void
FeatureExtractor
::
addAngFeature
(
const
rcsc
::
AngleDeg
&
ang
)
{
void
FeatureExtractor
::
addAngFeature
(
const
rcsc
::
AngleDeg
&
ang
)
{
...
...
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