Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*/__pycache__/
*/__pycache__/*
*.pyc
.vscode/
venv/
lib/network/__pycache__/udp_socket.cpython-36.pyc
lib/Player/__pycache__/
Expand Down
5 changes: 4 additions & 1 deletion base/generator_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def __init__(self):
def calculate_min_opp_dist(self, wm: 'WorldModel' = None):
if wm is None:
return 0.0
return min([opp.pos().dist(self.target_ball_pos) for opp in wm.opponents() if opp is not None and opp.unum() > 0])
opp_list = [opp.pos().dist(self.target_ball_pos) for opp in wm.opponents() if opp is not None and opp.unum() > 0]
if len(opp_list)==0:
return 9999
return min(opp_list)

def evaluate(self, wm: 'WorldModel' = None):
self.min_opp_dist = self.calculate_min_opp_dist(wm)
Expand Down
3 changes: 3 additions & 0 deletions base/generator_shoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ def check_shoot(self, wm: 'WorldModel', target_point: Vector2D, first_ball_speed

for o in range(1, 12):
opp = wm.their_player(o)
if not opp:
log.sw_log().shoot().add_text("## cant see an opp")
continue
if opp.unum() < 1:
log.sw_log().shoot().add_text( '## opp {} can not, unum')
continue
Expand Down
5 changes: 3 additions & 2 deletions lib/player/player_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ def run(self):
if self.is_decision_time(timeout_count, waited_msec) or (self._last_decision_time != self._current_time and self.world().see_time() == self._current_time):
self.action()
self.flush_logs()
if len(message) > 0:
print(pt.get())
# if len(message) > 0:
# print(pt.get())
self.send_bye_command()

def debug_players(self):
Expand Down Expand Up @@ -444,6 +444,7 @@ def do_catch(self):
return False

self._last_body_command.append(self.effector().set_catch())
return True

def do_turn_neck(self, moment: AngleDeg) -> bool:
self._last_body_command.append(self._effector.set_turn_neck(moment))
Expand Down
1 change: 1 addition & 0 deletions lib/player/soccer_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def parse_arguments(self):
parser.add_argument('-g', '--goalie',
help='Server Trainer port',
action='store_true')
parser.add_argument("-n",help="number of players",type=int,default=11)
args = parser.parse_args()

if args.team_name:
Expand Down
2 changes: 1 addition & 1 deletion lib/rcsc/game_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def is_penalty_kick_mode(self):
GameModeType.PenaltyReady_Left,
GameModeType.PenaltyReady_Right,
GameModeType.PenaltyTaken_Left,
GameModeType.PenaltyReady_Right,
GameModeType.PenaltyTaken_Right,
GameModeType.PenaltyMiss_Left,
GameModeType.PenaltyMiss_Right,
GameModeType.PenaltyScore_Left,
Expand Down
8 changes: 8 additions & 0 deletions lib/rcsc/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ class GameModeType(Enum):
PenaltyMiss_Right = "penalty_miss_r"
PenaltyScore_Left = "penalty_score_l"
PenaltyScore_Right = "penalty_score_r"
PenaltyOnfield_Left = "penalty_onfield_l"
PenaltyOnfield_Right = "penalty_onfield_r"
PenaltyFoul_Left = "penalty_foul_l"
PenaltyFoul_Right = "penalty_foul_r"
PenaltyWinner_Left = "penalty_winner_l"
PenaltyWinner_Right = "penalty_winner_r"

GoalieCatchBall_Left = "goalie_catch_ball_l"
GoalieCatchBall_Right = "goalie_catch_ball_r"
IllegalDefense_Left = "illegal_defense_l"
Expand Down Expand Up @@ -231,6 +238,7 @@ def is_catch_fault(self):

def is_ind_free_kick(self):
return self == GameModeType.IndFreeKick_Left or self == GameModeType.IndFreeKick_Right


def is_penalty_setup(self):
return self == GameModeType.PenaltySetup_Left or self == GameModeType.PenaltySetup_Right
Expand Down
14 changes: 11 additions & 3 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#!/bin/sh

export PYTHONPATH="${PYTHONPATH}:`pwd`"

# take argument -n into num_players, with default value 11
num_players=11
while getopts n: option
do
case "${option}"
in
n) num_players=${OPTARG};;
esac
done
python base/main_player.py -g ${1+"$@"}&
sleep 1
i=2
while [ $i -le 11 ] ; do
while [ $i -le $num_players ] ; do
python base/main_player.py ${1+"$@"}&
sleep 0.2

i=`expr $i + 1`
done

sleep 2
python coach_main.py ${1+"$@"}
python base/main_coach.py ${1+"$@"}