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 &
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 \\
\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 \\
\hline
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/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
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 \\
......
......@@ -68,9 +68,6 @@ STATUS_STRINGS = {IN_GAME: "InGame",
OUT_OF_TIME: "OutOfTime",
SERVER_DOWN: "ServerDown"}
"""Possible sides."""
RIGHT, NEUTRAL, LEFT = list(range(-1,2))
"""Possible action result statuses."""
ACTION_STATUS_UNKNOWN, ACTION_STATUS_BAD, ACTION_STATUS_MAYBE = list(range(-1,2))
ACTION_STATUS_MAYBE_OK = ACTION_STATUS_MAYBE # typos
......@@ -78,6 +75,9 @@ ACTION_STATUS_STRINGS = {ACTION_STATUS_UNKNOWN: "Unknown",
ACTION_STATUS_BAD: "Bad",
ACTION_STATUS_MAYBE: "MaybeOK"}
"""Possible sides."""
RIGHT, NEUTRAL, LEFT = list(range(-1,2))
class Player(Structure): pass
Player._fields_ = [
('side', c_int),
......
......@@ -123,7 +123,7 @@ int HFOEnvironment::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);
}
......
......@@ -55,7 +55,7 @@ class HFOEnvironment {
// Returns the number of opponents
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
virtual Player playerOnBall();
......
This diff is collapsed.
// -*-c++-*-
#ifndef AGENT_H
#define AGENT_H
......@@ -64,7 +66,7 @@ protected:
int num_teammates; // Number of teammates
int num_opponents; // Number of opponents
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:
inline const std::vector<float>& getState() { return state; }
......@@ -74,7 +76,7 @@ protected:
int getUnum(); // Returns the uniform number of the player
inline int getNumTeammates() { return num_teammates; }
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 std::vector<float>* mutable_params() { return &params; }
......@@ -83,21 +85,22 @@ protected:
private:
bool doPreprocess();
bool doSmartKick();
bool doShoot();
hfo::action_status_t doSmartKick();
hfo::action_status_t doShoot();
bool doPass();
bool doPassTo(int receiver);
bool doDribble();
bool doMove();
hfo::action_status_t doPassTo(int receiver);
hfo::action_status_t doDribble();
hfo::action_status_t doMove();
bool doForceKick();
bool doHeardPassReceive();
bool doMarkPlayer(int unum);
hfo::action_status_t doMarkPlayer(int unum);
bool doMarkPlayerNearIndex(int near_index);
bool doReduceAngleToGoal();
bool doDefendGoal();
bool doGoToBall();
hfo::action_status_t doReduceAngleToGoal();
hfo::action_status_t doDefendGoal();
hfo::action_status_t doGoToBall();
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;
......
......@@ -48,25 +48,36 @@
#include <rcsc/common/server_param.h>
#include "neck_offensive_intercept_neck.h"
#include "common.hpp"
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
Bhv_BasicMove::execute( PlayerAgent * agent )
hfo::action_status_t
Bhv_BasicMove::action_execute( PlayerAgent * agent )
{
dlog.addText( Logger::TEAM,
__FILE__": Bhv_BasicMove" );
bool success = true;
hfo::action_status_t success = hfo::ACTION_STATUS_UNKNOWN;
//-----------------------------------------------
// tackle
if ( Bhv_BasicTackle( 0.8, 80.0 ).execute( agent ) )
{
return true;
return hfo::ACTION_STATUS_MAYBE;
}
const WorldModel & wm = agent->world();
......@@ -85,9 +96,8 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
{
dlog.addText( Logger::TEAM,
__FILE__": intercept" );
success = Body_Intercept().execute( agent );
success = hfo::BooleanToActionStatus(Body_Intercept().execute( agent ));
agent->setNeckAction( new Neck_OffensiveInterceptNeck() );
return success;
}
......@@ -96,7 +106,9 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
const BallObject& ball = wm.ball();
if (! ball.rposValid()) {
success = false;
if (! wm.self().collidesWithPost()) {
success = hfo::ACTION_STATUS_BAD;
}
}
double dist_thr = ball.distFromSelf() * 0.1;
......@@ -115,8 +127,10 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
).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() &&
......
......@@ -29,6 +29,7 @@
#include <rcsc/geom/vector_2d.h>
#include <rcsc/player/soccer_action.h>
#include "common.hpp"
class Bhv_BasicMove
: public rcsc::SoccerBehavior {
......@@ -37,6 +38,7 @@ public:
{ }
bool execute( rcsc::PlayerAgent * agent );
hfo::action_status_t action_execute( rcsc::PlayerAgent * agent );
private:
double getDashPower( const rcsc::PlayerAgent * agent );
......
......@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <vector>
namespace hfo {
......@@ -40,7 +41,7 @@ enum action_t
GO_TO_BALL
};
// Status of a HFO game
// Status of an HFO game
enum status_t
{
IN_GAME, // Game is currently active
......@@ -51,6 +52,24 @@ enum status_t
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
// numbers for each team. This struct is populated by ParseConfig().
struct Config {
......@@ -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) {
switch (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
* 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