Commit 439cc197 authored by drallensmith's avatar drallensmith

Exploration of offense actions

parent 687ff761
This diff is collapsed.
......@@ -19,7 +19,7 @@ except ImportError:
' run: \"pip install .\"')
exit()
GOAL_POS_X = 1.0
GOAL_POS_X = 0.9
GOAL_POS_Y = 0.0
# below - from hand_coded_defense_agent.cpp except LOW_KICK_DIST
......
......@@ -6,11 +6,12 @@ import os
hfo_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__),
'libhfo_c.so'))
''' Possible feature sets '''
"""Possible feature sets"""
NUM_FEATURE_SETS = 2
LOW_LEVEL_FEATURE_SET, HIGH_LEVEL_FEATURE_SET = list(range(NUM_FEATURE_SETS))
''' An enum of the possible HFO actions
"""
An enum of the possible HFO actions, including:
[Low-Level] Dash(power, relative_direction)
[Low-Level] Turn(direction)
[Low-Level] Tackle(direction)
......@@ -25,27 +26,58 @@ LOW_LEVEL_FEATURE_SET, HIGH_LEVEL_FEATURE_SET = list(range(NUM_FEATURE_SETS))
[High-Level] Dribble(): Offensive dribble
[High-Level] Catch(): Catch the ball (Goalie Only)
NOOP(): Do Nothing
QUIT(): Quit the game '''
QUIT(): Quit the game
"""
NUM_HFO_ACTIONS = 19
DASH, TURN, TACKLE, KICK, KICK_TO, MOVE_TO, DRIBBLE_TO, INTERCEPT, \
MOVE, SHOOT, PASS, DRIBBLE, CATCH, NOOP, QUIT, REDUCE_ANGLE_TO_GOAL,MARK_PLAYER,DEFEND_GOAL,GO_TO_BALL = list(range(NUM_HFO_ACTIONS))
ACTION_STRINGS = ["Dash", "Turn", "Tackle", "Kick", "KickTo", "MoveTo", "DribbleTo", "Intercept", "Move", "Shoot", "Pass", "Dribble", "Catch", "No-op", "Quit", "Reduce_Angle_To_Goal", "Mark_Player", "Defend_Goal", "Go_To_Ball"]
''' Possible game status
DASH,TURN,TACKLE,KICK,KICK_TO,MOVE_TO,DRIBBLE_TO,INTERCEPT,MOVE,SHOOT,PASS,DRIBBLE,CATCH,NOOP,QUIT,REDUCE_ANGLE_TO_GOAL,MARK_PLAYER,DEFEND_GOAL,GO_TO_BALL = list(range(NUM_HFO_ACTIONS))
ACTION_STRINGS = {DASH: "Dash",
TURN: "Turn",
TACKLE: "Tackle",
KICK: "Kick",
KICK_TO: "KickTo",
MOVE_TO: "MoveTo",
DRIBBLE_TO: "DribbleTo",
INTERCEPT: "Intercept",
MOVE: "Move",
SHOOT: "Shoot",
PASS: "Pass",
DRIBBLE: "Dribble",
CATCH: "Catch",
NOOP: "No-op",
QUIT: "Quit",
REDUCE_ANGLE_TO_GOAL: "Reduce_Angle_To_Goal",
MARK_PLAYER: "Mark_Player",
DEFEND_GOAL: "Defend_Goal",
GO_TO_BALL: "Go_To_Ball"}
"""
Possible game statuses:
[IN_GAME] Game is currently active
[GOAL] A goal has been scored by the offense
[CAPTURED_BY_DEFENSE] The defense has captured the ball
[OUT_OF_BOUNDS] Ball has gone out of bounds
[OUT_OF_TIME] Trial has ended due to time limit
[SERVER_DOWN] Server is not alive
'''
"""
NUM_GAME_STATUS_STATES = 6
IN_GAME, GOAL, CAPTURED_BY_DEFENSE, OUT_OF_BOUNDS, OUT_OF_TIME, SERVER_DOWN = list(range(NUM_GAME_STATUS_STATES))
STATUS_STRINGS = ["InGame", "Goal", "CapturedByDefense", "OutOfBounds", "OutOfTime", "ServerDown"]
''' Possible sides '''
STATUS_STRINGS = {IN_GAME: "InGame",
GOAL: "Goal",
CAPTURED_BY_DEFENSE: "CapturedByDefense",
OUT_OF_BOUNDS: "OutOfBounds",
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
ACTION_STATUS_STRINGS = {ACTION_STATUS_UNKNOWN: "Unknown",
ACTION_STATUS_BAD: "Bad",
ACTION_STATUS_MAYBE: "MaybeOK"}
class Player(Structure): pass
Player._fields_ = [
('side', c_int),
......@@ -170,8 +202,13 @@ class HFOEnvironment(object):
def getLastActionStatus(self, last_action):
"""
If last_action is the last action with a recorded status,
returns a 1 for possible success, 0 for no possibility of success,
or -1 if unknown. If it is not the last action with a
recorded status, returns a -1.
returns ACTION_STATUS_MAYBE for possible success,
ACTION_STATUS_BAD for no possibility of success,
or ACTION_STATUS_UNKNOWN if unknown. If it is not the
last action with a recorded status, returns ACTION_STATUS_UNKNOWN.
"""
return hfo_lib.getLastActionStatus(self.obj, last_action)
def actionStatusToString(self, status):
"""Returns a string representation of an action status."""
return ACTION_STATUS_STRINGS[status]
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