Beispiel #1
0
    def compute_strategy(self, state, id_team, id_player):

        if id_team == 1:
            position_milieu_but = Vector2D(x=150.0, y=45.0)

        if id_team == 2:
            position_milieu_but = Vector2D(x=0.0, y=45.0)

        vector_acc = state.ball.position - state.player_state(id_team, id_player).position

        if state.ball.position.distance(state.player_state(id_team, id_player).position) < BALL_RADIUS + PLAYER_RADIUS:
            vector_shoot = position_milieu_but - state.ball.position
        else:
            vector_shoot = Vector2D()

        return SoccerAction(vector_acc, vector_shoot)


team1 = SoccerTeam("team1", [(Player("t1j1", RandomStrategy())), (Player("t1j2", RandomStrategy()))])
team2 = SoccerTeam("team2", [Player("t2j1", RandomStrategy()), (Player("t2j2", RandomStrategy()))])
team3 = SoccerTeam("team3", [Player("t3j1", RandomStrategy())])
match = SoccerMatch(team1, team2)

soccersimulator.show(match)
tournoi = SoccerTournament(1)
tournoi.add_team(team1)
tournoi.add_team(team2)
tournoi.add_team(team3)
soccersimulator.show(tournoi)
Beispiel #2
0
                       help="Watch live")
    parse.add_argument('-noretour',
                       action="store_true",
                       default=False,
                       help="Play 2 sides matches")
    parse.add_argument('-date', action="store_true", default=False)
    args = parse.parse_args()
    path = args.path
    print args
    fname = str(datetime.datetime.now()).replace("-", "").split(" ")[0]
    nb_tournois = args.nbp if args.nbp else [1, 2, 4]
    retour = not args.noretour
    if args.replay:
        tournoi = None
        try:
            tournoi = SoccerTournament.load(args.replay)
            tournoi._matches = dict([
                (kk, v) for kk, v in tournoi._matches.items()
                if not args.only or tournoi.get_team(kk[0]).login in args.only
                or tournoi.get_team(kk[1]).login in args.only
            ])

            print("Tournoi charge")
            print(tournoi.format_scores())
        except:
            pass
        if tournoi is None:
            try:
                tournoi = SoccerMatch.load(args.replay)
                print("Match charge")
            except:
    parse.add_argument('-login',nargs='+',default=None,help='List of logins to play')
    parse.add_argument('-only',nargs="+",default=None,help="Play only matches including logins")
    parse.add_argument('-nosave',action="store_true",default=False,help="Don't save scores and matches")
    parse.add_argument('-replay',action="store",help="Watch replay")
    parse.add_argument('-nowatch',action="store_true",default=False,help="Don't watch live")
    parse.add_argument('-noretour',action="store_true",default=False,help="Play 1 sides matches")
    parse.add_argument('-date',action="store_true",default=False)
    args=parse.parse_args()
    path = args.path
    fname = str(datetime.datetime.now()).replace("-","").split(" ")[0]
    nb_tournois = args.nbp if args.nbp else [1,2,4]
    retour = not args.noretour
    if args.replay:
        tournoi = None
        try:
            tournoi = SoccerTournament.load(args.replay)
            tournoi._matches = dict([ (kk,v) for kk,v in tournoi._matches.items() if not args.only or tournoi.get_team(kk[0]).login in args.only
                                      or tournoi.get_team(kk[1]).login in args.only ])

            print("Tournoi charge")
            print(tournoi.format_scores())
        except:
            pass
        if tournoi is None:
            try:
                tournoi = SoccerMatch.load(args.replay)
                print("Match charge")
            except:
                pass
        if tournoi is None:
            print("Format non reconnu")
Beispiel #4
0
        BaseStrategy.__init__(self,"Random")
    def compute_strategy(self,state,id_team,id_player):
        
        if id_team==1:
            position_milieu_but=Vector2D(x=150.,y=45.)
            
        if id_team==2:
            position_milieu_but=Vector2D(x=0.,y=45.)
            
        vector_acc=state.ball.position-state.player_state(id_team,id_player).position
        
        if (state.ball.position.distance(state.player_state(id_team,id_player).position)<BALL_RADIUS+PLAYER_RADIUS):
            vector_shoot=position_milieu_but-state.ball.position
        else:
            vector_shoot=Vector2D()
        
        return SoccerAction(vector_acc,vector_shoot)
    
    
team1= SoccerTeam("team1",[(Player("t1j1",RandomStrategy())),(Player("t1j2",RandomStrategy()))])
team2= SoccerTeam("team2",[Player("t2j1",RandomStrategy()),(Player("t2j2",RandomStrategy()))])
team3= SoccerTeam("team3",[Player("t3j1",RandomStrategy())])
match=SoccerMatch(team1,team2)

soccersimulator.show(match)
tournoi=SoccerTournament(1)
tournoi.add_team(team1)
tournoi.add_team(team2)
tournoi.add_team(team3)
soccersimulator.show(tournoi)