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
b387747e
Commit
b387747e
authored
Feb 23, 2016
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified includes.
parent
875bde45
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
34 deletions
+49
-34
hfo/hfo_c_wrapper.h
hfo/hfo_c_wrapper.h
+1
-1
setup.py
setup.py
+1
-1
src/HFO.cpp
src/HFO.cpp
+36
-23
src/HFO.hpp
src/HFO.hpp
+8
-9
src/common.hpp
src/common.hpp
+3
-0
No files found.
hfo/hfo_c_wrapper.h
View file @
b387747e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#define __HFO_C_WRAPPER_H__
#define __HFO_C_WRAPPER_H__
#include <vector>
#include <vector>
#include <string.h>
#include <HFO.hpp>
#include <HFO.hpp>
#include <common.hpp>
#include <common.hpp>
...
...
setup.py
View file @
b387747e
...
@@ -8,7 +8,7 @@ if not os.path.isfile(hfo_c_lib):
...
@@ -8,7 +8,7 @@ if not os.path.isfile(hfo_c_lib):
module1
=
Extension
(
'hfo.hfo_c_wrapper'
,
module1
=
Extension
(
'hfo.hfo_c_wrapper'
,
libraries
=
[
'hfo_c'
],
libraries
=
[
'hfo_c'
],
include_dirs
=
[
'src'
,
'src/chain_action'
,
'build/librcsc-prefix/src/librcsc'
],
include_dirs
=
[
'src'
],
library_dirs
=
[
'hfo'
],
library_dirs
=
[
'hfo'
],
extra_compile_args
=
[
'-D__STDC_CONSTANT_MACROS'
],
extra_compile_args
=
[
'-D__STDC_CONSTANT_MACROS'
],
sources
=
[
'hfo/hfo_c_wrapper.cpp'
])
sources
=
[
'hfo/hfo_c_wrapper.cpp'
])
...
...
src/HFO.cpp
View file @
b387747e
...
@@ -11,9 +11,22 @@
...
@@ -11,9 +11,22 @@
#include <iostream>
#include <iostream>
#include <stdarg.h>
#include <stdarg.h>
#include <agent.h>
#include <agent.h>
#include <rcsc/common/basic_client.h>
#include <rcsc/player/player_config.h>
#include <rcsc/player/world_model.h>
using
namespace
hfo
;
using
namespace
hfo
;
HFOEnvironment
::
HFOEnvironment
()
{
client
=
new
rcsc
::
BasicClient
();
agent
=
new
Agent
();
}
HFOEnvironment
::~
HFOEnvironment
()
{
delete
client
;
delete
agent
;
}
void
HFOEnvironment
::
connectToServer
(
feature_set_t
feature_set
,
void
HFOEnvironment
::
connectToServer
(
feature_set_t
feature_set
,
std
::
string
config_dir
,
std
::
string
config_dir
,
int
uniform_number
,
int
uniform_number
,
...
@@ -21,37 +34,37 @@ void HFOEnvironment::connectToServer(feature_set_t feature_set,
...
@@ -21,37 +34,37 @@ void HFOEnvironment::connectToServer(feature_set_t feature_set,
std
::
string
server_addr
,
std
::
string
server_addr
,
std
::
string
team_name
,
std
::
string
team_name
,
bool
play_goalie
)
{
bool
play_goalie
)
{
agent
.
setFeatureSet
(
feature_set
);
agent
->
setFeatureSet
(
feature_set
);
rcsc
::
PlayerConfig
&
config
=
agent
.
mutable_config
();
rcsc
::
PlayerConfig
&
config
=
agent
->
mutable_config
();
config
.
setConfigDir
(
config_dir
);
config
.
setConfigDir
(
config_dir
);
config
.
setPlayerNumber
(
uniform_number
);
config
.
setPlayerNumber
(
uniform_number
);
config
.
setPort
(
server_port
);
config
.
setPort
(
server_port
);
config
.
setHost
(
server_addr
);
config
.
setHost
(
server_addr
);
config
.
setTeamName
(
team_name
);
config
.
setTeamName
(
team_name
);
config
.
setGoalie
(
play_goalie
);
config
.
setGoalie
(
play_goalie
);
if
(
!
agent
.
init
(
&
client
,
0
,
NULL
))
{
if
(
!
agent
->
init
(
client
,
0
,
NULL
))
{
std
::
cerr
<<
"Init failed"
<<
std
::
endl
;
std
::
cerr
<<
"Init failed"
<<
std
::
endl
;
exit
(
1
);
exit
(
1
);
}
}
client
.
setClientMode
(
rcsc
::
BasicClient
::
ONLINE
);
client
->
setClientMode
(
rcsc
::
BasicClient
::
ONLINE
);
if
(
!
client
.
startAgent
(
&
agent
))
{
if
(
!
client
->
startAgent
(
agent
))
{
std
::
cerr
<<
"Unable to start agent"
<<
std
::
endl
;
std
::
cerr
<<
"Unable to start agent"
<<
std
::
endl
;
exit
(
1
);
exit
(
1
);
}
}
assert
(
client
.
isServerAlive
()
==
true
);
assert
(
client
->
isServerAlive
()
==
true
);
while
(
agent
.
getState
().
empty
())
{
while
(
agent
->
getState
().
empty
())
{
step
();
step
();
}
}
}
}
const
std
::
vector
<
float
>&
HFOEnvironment
::
getState
()
{
const
std
::
vector
<
float
>&
HFOEnvironment
::
getState
()
{
return
agent
.
getState
();
return
agent
->
getState
();
}
}
void
HFOEnvironment
::
act
(
action_t
action
,
...)
{
void
HFOEnvironment
::
act
(
action_t
action
,
...)
{
agent
.
setAction
(
action
);
agent
->
setAction
(
action
);
int
n_args
=
NumParams
(
action
);
int
n_args
=
NumParams
(
action
);
std
::
vector
<
float
>
*
params
=
agent
.
mutable_params
();
std
::
vector
<
float
>
*
params
=
agent
->
mutable_params
();
params
->
resize
(
n_args
);
params
->
resize
(
n_args
);
va_list
vl
;
va_list
vl
;
va_start
(
vl
,
action
);
va_start
(
vl
,
action
);
...
@@ -62,35 +75,35 @@ void HFOEnvironment::act(action_t action, ...) {
...
@@ -62,35 +75,35 @@ void HFOEnvironment::act(action_t action, ...) {
}
}
void
HFOEnvironment
::
act
(
action_t
action
,
const
std
::
vector
<
float
>&
params
)
{
void
HFOEnvironment
::
act
(
action_t
action
,
const
std
::
vector
<
float
>&
params
)
{
agent
.
setAction
(
action
);
agent
->
setAction
(
action
);
int
n_args
=
NumParams
(
action
);
int
n_args
=
NumParams
(
action
);
assert
(
n_args
==
params
.
size
());
assert
(
n_args
==
params
.
size
());
std
::
vector
<
float
>
*
agent_params
=
agent
.
mutable_params
();
std
::
vector
<
float
>
*
agent_params
=
agent
->
mutable_params
();
(
*
agent_params
)
=
params
;
(
*
agent_params
)
=
params
;
}
}
void
HFOEnvironment
::
say
(
const
std
::
string
&
message
)
{
void
HFOEnvironment
::
say
(
const
std
::
string
&
message
)
{
agent
.
setSayMsg
(
message
);
agent
->
setSayMsg
(
message
);
}
}
std
::
string
HFOEnvironment
::
hear
()
{
std
::
string
HFOEnvironment
::
hear
()
{
return
agent
.
getHearMsg
();
return
agent
->
getHearMsg
();
}
}
Player
HFOEnvironment
::
playerOnBall
()
{
Player
HFOEnvironment
::
playerOnBall
()
{
return
agent
.
getPlayerOnBall
();
return
agent
->
getPlayerOnBall
();
}
}
status_t
HFOEnvironment
::
step
()
{
status_t
HFOEnvironment
::
step
()
{
bool
end_of_trial
=
agent
.
getGameStatus
()
!=
IN_GAME
;
bool
end_of_trial
=
agent
->
getGameStatus
()
!=
IN_GAME
;
long
start_cycle
=
agent
.
cycle
();
long
start_cycle
=
agent
->
cycle
();
while
((
agent
.
cycle
()
<=
start_cycle
)
while
((
agent
->
cycle
()
<=
start_cycle
)
||
(
agent
.
getLastDecisionTime
()
<
agent
.
cycle
())
||
(
agent
->
getLastDecisionTime
()
<
agent
->
cycle
())
||
(
end_of_trial
&&
agent
.
getGameStatus
()
!=
IN_GAME
))
{
||
(
end_of_trial
&&
agent
->
getGameStatus
()
!=
IN_GAME
))
{
client
.
runStep
(
&
agent
);
client
->
runStep
(
agent
);
if
(
!
client
.
isServerAlive
())
{
if
(
!
client
->
isServerAlive
())
{
return
SERVER_DOWN
;
return
SERVER_DOWN
;
}
}
}
}
return
agent
.
getGameStatus
();
return
agent
->
getGameStatus
();
}
}
src/HFO.hpp
View file @
b387747e
...
@@ -3,18 +3,17 @@
...
@@ -3,18 +3,17 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <rcsc/common/basic_client.h>
#include <rcsc/player/player_config.h>
#include <rcsc/player/world_model.h>
#include "agent.h"
#include "common.hpp"
#include "common.hpp"
class
Agent
;
namespace
rcsc
{
class
BasicClient
;
}
namespace
hfo
{
namespace
hfo
{
class
HFOEnvironment
{
class
HFOEnvironment
{
public:
public:
HFOEnvironment
()
{}
;
HFOEnvironment
();
virtual
~
HFOEnvironment
()
{}
;
virtual
~
HFOEnvironment
();
/**
/**
* Connect to the server on the specified port. The
* Connect to the server on the specified port. The
...
@@ -54,9 +53,9 @@ class HFOEnvironment {
...
@@ -54,9 +53,9 @@ class HFOEnvironment {
// progress. Returns the game status after the step
// progress. Returns the game status after the step
virtual
status_t
step
();
virtual
status_t
step
();
pr
otected
:
pr
ivate
:
rcsc
::
BasicClient
client
;
rcsc
::
BasicClient
*
client
;
Agent
agent
;
Agent
*
agent
;
};
};
}
// namespace hfo
}
// namespace hfo
...
...
src/common.hpp
View file @
b387747e
#ifndef __COMMON_HPP__
#ifndef __COMMON_HPP__
#define __COMMON_HPP__
#define __COMMON_HPP__
#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <sstream>
namespace
hfo
{
namespace
hfo
{
...
...
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