Commit 85a0d4aa authored by drallensmith's avatar drallensmith

Revise feedback with enum, use of ACTION_STATUS_UNKNOWN when appropriate

parent 2be132c1
No preview for this file type
...@@ -622,13 +622,13 @@ Team. unum invalid & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & N & ...@@ -622,13 +622,13 @@ Team. unum invalid & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & N &
Opponent loc invalid & Y & Y & Y & Y & Y & Y & Y? & Y & N & Y? & Y & Y? & Y & Y & Y & Y & N \\ Opponent loc invalid & Y & Y & Y & Y & Y & Y & Y? & Y & N & Y? & Y & Y? & Y & Y & Y & Y & N \\
Opp. unum invalid & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & N \\ Opp. unum invalid & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & N \\
\hline \hline
Ball kickable & Y & Y & Y & Y & Y & Y & Y & ? & * & Y & Y & Y & Y & ? & ? & ? & Y \\ Ball kickable & Y & Y & Y & Y & Y & Y & Y & N & * & Y & Y & Y & Y & ? & ? & N & Y \\
Ball not kickable & Y & Y & Y & N & N & Y & Y & Y & Y & N & N & N & Y & Y & Y & Y & Y \\ Ball not kickable & Y & Y & Y & N & N & Y & Y & Y & Y & N & N & N & Y & Y & Y & Y & Y \\
\hline \hline
Frozen & N & N & N & N & N & N & N? & N & N? & N & N & Y & N? & N & N & N & N \\ Frozen & N & N & N & N & N & N & N? & N & N? & N & N & Y & N? & N & N & N & N \\
Colliding w/ball & Y & Y & ? & ? & ? & Y? & ? & ? & ? & ? & ? & ? & ? & ? & ? & ? & ? \\ Colliding w/ball & Y & Y & ? & N & Y & Y & Y & Y & ? & ? & ? & ? & ? & ? & ? & N & ? \\
Colliding w/player & Y & Y? & ? & N? & N? & Y? & ? & Y? & ? & ? & ? & Y? & ? & ? & ? & Y? & ? \\ Colliding w/player & Y & Y? & ? & N? & N? & Y? & ? & Y? & ? & ? & ? & Y? & ? & ? & ? & Y? & ? \\
Colliding w/post & Y & Y & N? & N? & N? & Y & ? & Y & ? & ? & ? & ? & ? & ? & ? & Y & ? \\ Colliding w/post & Y & Y & N? & N? & N? & Y & Y & Y & Y & ? & ? & Y & ? & Y & Y & Y & Y \\
\hline \hline
Offense & Y & Y & N & Y & Y & Y & Y & Y & Y & Y & Y & Y & N & N & N & Y & N \\ Offense & Y & Y & N & Y & Y & Y & Y & Y & Y & Y & Y & Y & N & N & N & Y & N \\
Defense, not goalie & Y & Y & Y & N? & N? & Y & N & Y & Y & N & N & N & N & Y & ? & Y & Y \\ Defense, not goalie & Y & Y & Y & N? & N? & Y & N & Y & Y & N & N & N & N & Y & ? & Y & Y \\
......
...@@ -68,9 +68,6 @@ STATUS_STRINGS = {IN_GAME: "InGame", ...@@ -68,9 +68,6 @@ STATUS_STRINGS = {IN_GAME: "InGame",
OUT_OF_TIME: "OutOfTime", OUT_OF_TIME: "OutOfTime",
SERVER_DOWN: "ServerDown"} SERVER_DOWN: "ServerDown"}
"""Possible sides."""
RIGHT, NEUTRAL, LEFT = list(range(-1,2))
"""Possible action result statuses.""" """Possible action result statuses."""
ACTION_STATUS_UNKNOWN, ACTION_STATUS_BAD, ACTION_STATUS_MAYBE = list(range(-1,2)) ACTION_STATUS_UNKNOWN, ACTION_STATUS_BAD, ACTION_STATUS_MAYBE = list(range(-1,2))
ACTION_STATUS_MAYBE_OK = ACTION_STATUS_MAYBE # typos ACTION_STATUS_MAYBE_OK = ACTION_STATUS_MAYBE # typos
...@@ -78,6 +75,9 @@ ACTION_STATUS_STRINGS = {ACTION_STATUS_UNKNOWN: "Unknown", ...@@ -78,6 +75,9 @@ ACTION_STATUS_STRINGS = {ACTION_STATUS_UNKNOWN: "Unknown",
ACTION_STATUS_BAD: "Bad", ACTION_STATUS_BAD: "Bad",
ACTION_STATUS_MAYBE: "MaybeOK"} ACTION_STATUS_MAYBE: "MaybeOK"}
"""Possible sides."""
RIGHT, NEUTRAL, LEFT = list(range(-1,2))
class Player(Structure): pass class Player(Structure): pass
Player._fields_ = [ Player._fields_ = [
('side', c_int), ('side', c_int),
......
...@@ -123,7 +123,7 @@ int HFOEnvironment::getNumOpponents() { ...@@ -123,7 +123,7 @@ int HFOEnvironment::getNumOpponents() {
return agent->getNumOpponents(); return agent->getNumOpponents();
} }
int HFOEnvironment::getLastActionStatus(action_t last_action) { action_status_t HFOEnvironment::getLastActionStatus(action_t last_action) {
return agent->getLastActionStatus(last_action); return agent->getLastActionStatus(last_action);
} }
......
...@@ -55,7 +55,7 @@ class HFOEnvironment { ...@@ -55,7 +55,7 @@ class HFOEnvironment {
// Returns the number of opponents // Returns the number of opponents
virtual int getNumOpponents(); virtual int getNumOpponents();
virtual int getLastActionStatus(action_t last_action); virtual action_status_t getLastActionStatus(action_t last_action);
// Get the current player holding the ball // Get the current player holding the ball
virtual Player playerOnBall(); virtual Player playerOnBall();
......
This diff is collapsed.
// -*-c++-*-
#ifndef AGENT_H #ifndef AGENT_H
#define AGENT_H #define AGENT_H
...@@ -64,7 +66,7 @@ protected: ...@@ -64,7 +66,7 @@ protected:
int num_teammates; // Number of teammates int num_teammates; // Number of teammates
int num_opponents; // Number of opponents int num_opponents; // Number of opponents
hfo::action_t last_action_with_status; // Last action with a recorded return status hfo::action_t last_action_with_status; // Last action with a recorded return status
int last_action_status; // Recorded return status of last action (1 = true, 0 = false, -1 = not available) hfo::action_status_t last_action_status; // Recorded return status of last action
public: public:
inline const std::vector<float>& getState() { return state; } inline const std::vector<float>& getState() { return state; }
...@@ -74,7 +76,7 @@ protected: ...@@ -74,7 +76,7 @@ protected:
int getUnum(); // Returns the uniform number of the player int getUnum(); // Returns the uniform number of the player
inline int getNumTeammates() { return num_teammates; } inline int getNumTeammates() { return num_teammates; }
inline int getNumOpponents() { return num_opponents; } inline int getNumOpponents() { return num_opponents; }
int getLastActionStatus(hfo::action_t last_action); // if last_action is correct, returns status if available hfo::action_status_t getLastActionStatus(hfo::action_t last_action); // if last_action is correct, returns status if available
inline void setFeatureSet(hfo::feature_set_t fset) { feature_set = fset; } inline void setFeatureSet(hfo::feature_set_t fset) { feature_set = fset; }
inline std::vector<float>* mutable_params() { return &params; } inline std::vector<float>* mutable_params() { return &params; }
...@@ -83,21 +85,22 @@ protected: ...@@ -83,21 +85,22 @@ protected:
private: private:
bool doPreprocess(); bool doPreprocess();
bool doSmartKick(); hfo::action_status_t doSmartKick();
bool doShoot(); hfo::action_status_t doShoot();
bool doPass(); bool doPass();
bool doPassTo(int receiver); hfo::action_status_t doPassTo(int receiver);
bool doDribble(); hfo::action_status_t doDribble();
bool doMove(); hfo::action_status_t doMove();
bool doForceKick(); bool doForceKick();
bool doHeardPassReceive(); bool doHeardPassReceive();
bool doMarkPlayer(int unum); hfo::action_status_t doMarkPlayer(int unum);
bool doMarkPlayerNearIndex(int near_index); bool doMarkPlayerNearIndex(int near_index);
bool doReduceAngleToGoal(); hfo::action_status_t doReduceAngleToGoal();
bool doDefendGoal(); hfo::action_status_t doDefendGoal();
bool doGoToBall(); hfo::action_status_t doGoToBall();
bool doNewAction1(); bool doNewAction1();
void addLastActionStatus(hfo::action_t last_action, bool action_status); void addLastActionStatus(hfo::action_t last_action, hfo::action_status_t action_status);
void addLastActionStatusCollision(hfo::action_t last_action, bool may_fix, bool likely_success);
Communication::Ptr M_communication; Communication::Ptr M_communication;
......
...@@ -48,25 +48,36 @@ ...@@ -48,25 +48,36 @@
#include <rcsc/common/server_param.h> #include <rcsc/common/server_param.h>
#include "neck_offensive_intercept_neck.h" #include "neck_offensive_intercept_neck.h"
#include "common.hpp"
using namespace rcsc; using namespace rcsc;
bool
Bhv_BasicMove::execute( PlayerAgent * agent )
{
if (Bhv_BasicMove::action_execute(agent) == hfo::ACTION_STATUS_MAYBE) {
return true;
} else {
return false;
}
}
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
/*! /*!
*/ */
bool hfo::action_status_t
Bhv_BasicMove::execute( PlayerAgent * agent ) Bhv_BasicMove::action_execute( PlayerAgent * agent )
{ {
dlog.addText( Logger::TEAM, dlog.addText( Logger::TEAM,
__FILE__": Bhv_BasicMove" ); __FILE__": Bhv_BasicMove" );
bool success = true; hfo::action_status_t success = hfo::ACTION_STATUS_UNKNOWN;
//----------------------------------------------- //-----------------------------------------------
// tackle // tackle
if ( Bhv_BasicTackle( 0.8, 80.0 ).execute( agent ) ) if ( Bhv_BasicTackle( 0.8, 80.0 ).execute( agent ) )
{ {
return true; return hfo::ACTION_STATUS_MAYBE;
} }
const WorldModel & wm = agent->world(); const WorldModel & wm = agent->world();
...@@ -85,9 +96,8 @@ Bhv_BasicMove::execute( PlayerAgent * agent ) ...@@ -85,9 +96,8 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
{ {
dlog.addText( Logger::TEAM, dlog.addText( Logger::TEAM,
__FILE__": intercept" ); __FILE__": intercept" );
success = Body_Intercept().execute( agent ); success = hfo::BooleanToActionStatus(Body_Intercept().execute( agent ));
agent->setNeckAction( new Neck_OffensiveInterceptNeck() ); agent->setNeckAction( new Neck_OffensiveInterceptNeck() );
return success; return success;
} }
...@@ -96,7 +106,9 @@ Bhv_BasicMove::execute( PlayerAgent * agent ) ...@@ -96,7 +106,9 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
const BallObject& ball = wm.ball(); const BallObject& ball = wm.ball();
if (! ball.rposValid()) { if (! ball.rposValid()) {
success = false; if (! wm.self().collidesWithPost()) {
success = hfo::ACTION_STATUS_BAD;
}
} }
double dist_thr = ball.distFromSelf() * 0.1; double dist_thr = ball.distFromSelf() * 0.1;
...@@ -115,8 +127,10 @@ Bhv_BasicMove::execute( PlayerAgent * agent ) ...@@ -115,8 +127,10 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
).execute( agent ) ) ).execute( agent ) )
{ {
if (! Body_TurnToBall().execute( agent )) { if (! Body_TurnToBall().execute( agent )) {
success = false; success = hfo::ACTION_STATUS_BAD;
} }
} else if (success != hfo::ACTION_STATUS_BAD) {
success = hfo::ACTION_STATUS_MAYBE;
} }
if ( wm.existKickableOpponent() && if ( wm.existKickableOpponent() &&
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <rcsc/geom/vector_2d.h> #include <rcsc/geom/vector_2d.h>
#include <rcsc/player/soccer_action.h> #include <rcsc/player/soccer_action.h>
#include "common.hpp"
class Bhv_BasicMove class Bhv_BasicMove
: public rcsc::SoccerBehavior { : public rcsc::SoccerBehavior {
...@@ -36,7 +37,8 @@ public: ...@@ -36,7 +37,8 @@ public:
Bhv_BasicMove() Bhv_BasicMove()
{ } { }
bool execute( rcsc::PlayerAgent * agent ); bool execute( rcsc::PlayerAgent * agent );
hfo::action_status_t action_execute( rcsc::PlayerAgent * agent );
private: private:
double getDashPower( const rcsc::PlayerAgent * agent ); double getDashPower( const rcsc::PlayerAgent * agent );
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <vector>
namespace hfo { namespace hfo {
...@@ -33,14 +34,14 @@ enum action_t ...@@ -33,14 +34,14 @@ enum action_t
DRIBBLE, // [High-Level] Dribble(): Offensive dribble DRIBBLE, // [High-Level] Dribble(): Offensive dribble
CATCH, // [High-Level] Catch(): Catch the ball (Goalie only!) CATCH, // [High-Level] Catch(): Catch the ball (Goalie only!)
NOOP, // Do nothing NOOP, // Do nothing
QUIT, // Special action to quit the game QUIT, // Special action to quit the game
REDUCE_ANGLE_TO_GOAL, // [High-Level] Reduce_Angle_To_Goal : Reduces the shooting angle REDUCE_ANGLE_TO_GOAL, // [High-Level] Reduce_Angle_To_Goal : Reduces the shooting angle
MARK_PLAYER, // [High-Level] Mark_Player(opponent_unum [0,11]) : Moves to the position in between the kicker and a given player MARK_PLAYER, // [High-Level] Mark_Player(opponent_unum [0,11]) : Moves to the position in between the kicker and a given player
DEFEND_GOAL, DEFEND_GOAL,
GO_TO_BALL GO_TO_BALL
}; };
// Status of a HFO game // Status of an HFO game
enum status_t enum status_t
{ {
IN_GAME, // Game is currently active IN_GAME, // Game is currently active
...@@ -51,6 +52,24 @@ enum status_t ...@@ -51,6 +52,24 @@ enum status_t
SERVER_DOWN // Server is not alive SERVER_DOWN // Server is not alive
}; };
// Action status
enum action_status_t {
ACTION_STATUS_UNKNOWN = -1, // cannot tell or invalid action # in status request
ACTION_STATUS_BAD = 0, // definitely not OK
ACTION_STATUS_MAYBE = 1, // may be OK, may not
};
/**
* Translates from boolean false (bad) or true (maybe OK) to action status
*/
inline action_status_t BooleanToActionStatus(const bool status) {
if (status) {
return ACTION_STATUS_MAYBE;
} else{
return ACTION_STATUS_BAD;
}
}
// 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 {
...@@ -171,7 +190,7 @@ inline std::string ActionToString(action_t action) { ...@@ -171,7 +190,7 @@ inline std::string ActionToString(action_t action) {
}; };
/** /**
* Returns a string representation of a game_status. * Returns a string representation of a game status.
*/ */
inline std::string StatusToString(status_t status) { inline std::string StatusToString(status_t status) {
switch (status) { switch (status) {
...@@ -192,6 +211,22 @@ inline std::string StatusToString(status_t status) { ...@@ -192,6 +211,22 @@ inline std::string StatusToString(status_t status) {
} }
}; };
/**
* Returns a string representation of an action status.
*/
inline std::string ActionStatusToString(action_status_t status) {
switch (status) {
case ACTION_STATUS_BAD:
return "Bad";
case ACTION_STATUS_MAYBE:
return "MaybeOK";
case ACTION_STATUS_UNKNOWN:
return "Unknown";
default:
return "Invalid";
}
}
/** /**
* Parse a Trainer message to populate config. Returns a bool * Parse a Trainer message to populate config. Returns a bool
* indicating if the struct was correctly parsed. * indicating if the struct was correctly parsed.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment