Sports Simulation Simple Soccer

Similar documents
Sports Simulation Simple Soccer

Sports Simulation Simple Soccer

1. 4 Corners Passing:

Northern SC U6 Playing Format 3v3

U14 CURRICULUM. S t o u g h t o n A r e a Y o u t h S o c c e r A s s o c i a t i o n. Page 9

Spring/Summer Session

(10, 11 and Some 12 Year Olds)

The Novice Coach s Guide to a Successful Soccer Season

Northern SC U12 Playing Formats 8v8 (7 field players + 1 GK)

(8, 9 and Some 10 Year Olds) Shield and Steal Activity Description Coaching Objective. Coach divides the players into two

Season: Spring 2016 Age Group: U8 Week: 1

Topic: Passing and Receiving for Possession

GLOBAL PREMIER SOCCER 2016 SPRING CURRICULUM

CYSA Coach s Training Guide

(10, 11 and Some 12 Year Olds) Inside Outside Activity Description Coaching Objective Passing and receiving

U8 CURRICULUM. S t o u g h t o n A r e a Y o u t h S o c c e r A s s o c i a t i o n. Page 9

United Soccer: Game Rules

*This is a Recreational and Developmental league. The goal is to have fun and introduce them to soccer. WE DO NOT KEEP SCORE AT THIS AGE.

Weeks 1-3 Dribbling/Ball Control and Throw In Focus

Possession games, Youth Training Sessions. Accents U13s

Small Sided Games SHARP SHOOTER

Topic: Conditioned Games

GRADE LEVEL STANDARD DESCRIPTION

Season By Daniel Mattos GLSA Futsal Director FUTSAL

United Soccer: Game Rules

U10 Soccer Program Stage 3: Learning to Train

Warm Up. Technical Practice / Development 1

SSA Under 14 to Under 19 Practice Activities

Basic organization of the training field

Lesson Plan Topics. Module 1 Dribbling Module 2 Passing & Receiving Module 3 Defending Module 4 Shooting and Finishing Module 5 Conditioned Game

Attacking & Defending. One versus one each player attacking and defending. 1 central gate:

FUBA RULEBOOK VERSION

SoccerDrive.com Tryout Resources

Topic: Conditioned Games

STAGE 2 ACTIVITIES 6-8 YEAR OLD PLAYERS. NSCAA Foundations of Coaching Diploma

Arlington Recreation Rules

Dribbling, sharks minnows, shielding, turning, youth soccer drill, fun soccer drill, free soccer drill, dribbling

COACHING FUTSAL: NSCAA LEVEL 1 FUTSAL DIPLOMA

Topic: Striking Lofted and Driven Balls (Long Balls) Objective: To introduce the players to the technique of striking lofted and driven long balls War

5. Performance Phase Model Sessions

5 th Grade and older Coaching Manual

NEENAH SOCCER CLUB Recreational Program U8C&G Age Group Week 1 & 2

Natural Soccer User Guide

Active for Life: Warm Up #3

Copyright Notice - IT IS ILLEGAL TO POST THIS DOCUMENT ONLINE

Soccer Practice Plan 5 th Grade and Up

Youth Academy Player Development Lesson Plans

DAKOTA UNITED SOCCER CLUB U8 U12

U8 Week 1 - Dribbling

Laws of the Game. Education Session. Created by John Olivia Presented by Abbi Lezizidis February 28, 2015

AGES 10 AND UNDER. Small Area Games LESSON WORKBOOK. roger grillo

When the offense attacks our goal, they are most dangerous when they can get to the center of the ice or when they have clear passing lanes.

14U Pella Soccer Club. Curriculum & Practice Plan

Soccer Study Guide. The Game

Newton Youth Soccer Fall 2017 Curriculum 1 st & 2 nd Grade

Newton Youth Soccer Spring 2017 Curriculum 5 th & 6 th Grade

Traffic Lights. From the card 1. Red cone stop 2. Yellow cone change direction 3. Green cone speed up

Benefits of Playing Futsal

Soccer Manual. Rules, Regulations, & Training Information.

Suggested Week 1 Topic: Passing and Receiving for Possession. 3v3 5 Goal Game: In a 20x30 yard grid, five 2 yard goals are positions

Active for Life: GAG Intro-Game

Soccer Drills. Develops dribbling skills with speed and works on the defender getting back in front of the ball on a breakaway.

Contact with your suggestions for this chapter. Chapter1 Standard 4 v 4

Global Premier Soccer Curriculum u14 Curriculum 8 Week Training Program

Queue analysis for the toll station of the Öresund fixed link. Pontus Matstoms *

Beacon Soccer Club Game Operating Procedures

Soccer. Construct and execute defensive plays and strategies.(11- 12)

Training Centers Interactive Lesson Plan

ACTIVITY PLAN. Author: White Age Group U10. Key Coaching Points: Cooperation Agility Fun

Training Game U-10 Players 1V1 Four Gate Soccer

AGES 14 AND UNDER. Small Area Games LESSON WORKBOOK ROGER GRILLO

KIRKWOOD INDOOR SOCCER RULES

LegenDary 2012 Soccer 2D Simulation Team Description Paper

4 th -6 th Grades Week 1 Session Dribbling Activity Description Diagram Coaching Points

Developing Game Intelligence for 11- years- old football players. 1 st Simplified Game. Maintaining Ball Possession 3 on 1

RETREATING LINE INTRODUCTION

U12 Activities - Passing & Receiving for Possession

MERIDIAN SOCCER CLUB

Soccer Skill Building Games

Spartans FC Youth Section Skills Program

Fantastic Fours. Field Layout

COACHING FUTSAL: NSCAA LEVEL 1 FUTSAL DIPLOMA

Playing in a (Flat)

Possession Playing Away From Pressure

Soccer Manual. Rules, Regulations, & Training Information.

WINTER FUTSAL EDUCATION SERIES

Rio Rapids Durango Soccer Club U13/14 Player Standards

WESTON SOCCER CLUB FALL CURRICULUM 5th & 6th Grade

Johnston - Urbandale Soccer Club U9-U10. Coaching Curriculum

AGE BALL SIZE GAME LENGTH # OF PLAYERS

Defend deep to counter-attack

AKATSUKI Soccer 2D Simulation Team Description Paper 2011

The Multi-Purpose Offense and Shooting Drill

12U Pella Soccer Club. Curriculum & Practice Plan

Drills and Conditioned Games To Improve and Develop Team-Play

Weekly Practice Schedule:

Active for Life: GAG Activity

Fun Soccer Drills that Teach Soccer Skills to 5, 6, and 7 year olds

Where to Sit? Rules: Kickoffs. Rules: Goal Kicks. General Soccer Rules. Coaches and players from both teams sit on the same sideline.

SOCCER DRILLS AND PRACTICE PLANS

Transcription:

Sports Simulation Simple Soccer Artificial Intelligence for Interactive Media and Games Professor Charles Rich Computer Science Department rich@wpi.edu [Based on Buckland, Chapter 4 and lecture by Robin Burke] IMGD 400X (B 09) 1 Plan for next three weeks (re Soccer) Mon/Tues/Thu: Simple Soccer Anatomy Sun midnite: My Team homework due [3 pt] set up code to make modifications study game play carefully to look for improvements Mon: Discussion of Team Improvements Weds midnite: Team Design homework due [3 pt] Weds midnite: Tournament Team due [10 pt] full credit for beating Buckland s team Fri Nov. 20: Soccer tournament (IMGD Lab) bonus points for winning elimination matches IMGD 400X (B 09) 2 1

1 Tue, Oct 27 Intro/Overview/Admin Wed, Oct 28 1 - Hello West World [3%] Thu, Oct 29 Chapter 2 State Machines Fri, Oct 30 Chapter 2 Event Messages Sun, Nov 1 2 - Bar Fly [5%] 2 Mon, Nov 2 Chapter 4 Simple Soccer Anatomy Tue, Nov 3 Chapter 4 Simple Soccer Anatomy Wed, Nov 4 3 - Tank States [5%] Thu, Nov 5 Chapter 4 Simple Soccer Anatomy Fri, Nov 6 Futures: AIIDE Conference Highlights Sun, Nov 8 4 - My Team [3%] 3 Mon, Nov 9 Brainstorming: Simple Soccer Strategy Tue, Nov 10 Chapter 6 LUA Scripting Wed, Nov 11 5 - Team Design [3%] Thu, Nov 12 Chapter 6 LUA Scripting Fri, Nov 13 Futures: Neuroevolution of Combat Bots Sun, Nov 15 6 - Scripting [5%] 4 Mon, Nov 16 Chapter 7 Raven Anatomy Tue, Nov 17 Chapter 7 Raven Anatomy Wed, Nov 18 7 - Tournament Team [10%] Thu, Nov 19 Fri, Nov 20 Futures: AI and Animation Soccer Tournament (IMGD Lab) Sun, Nov 22 8 - My Bot [3%] IMGD 400X (B 09) 3 Simple Soccer 2D sports simulation (no interactive player) 2 teams ( red and blue ) 5 autonomous agents per team 4 field players 1 goal keeper 1 field ( pitch ) 2 goals 1 ball IMGD 400X (B 09) 4 2

Simple Soccer Demo Red Team: BucklandTeam Blue Team: BurkeTeam Keyboard controls P for pause/resume R for reset (new match) Frame (update) rate default 60 Hz (FrameRate in Params.ini) can slow down to study behavior more closely Match default 5 min (TimeLimit in Params.ini) scoring bonus for using less CPU time (details later) IMGD 400X (B 09) 5 Why? Why should we learn all this complicated, detailed soccer strategy? this is a course about general techniques for game AI, not soccer specifically some students asked the same question about chess in IMGD 4000 Answer: Because there is no other way to appreciate the complexity of building a game AI and the software issues it forces without mastering something complex. IMGD 400X (B 09) 6 3

Issues in Simple Soccer Geometry and Physics steering navigation Tiered AI overall team state machine each player has state machine each player has (changing) role in team e.g., pass receiver messaging between players e.g., pass me the ball Soccer-specific strategy and design IMGD 400X (B 09) 7 Avoiding Perfection Like many other genres (e.g., FPS), AI opponents in sports simulations must be beatable AI s may have inherently weak strategies (e.g,. no defensive plays in Simple Soccer) explicit fudge factors (e.g., n% of shots go wild) Inaccurate (approximate) physics modeling saves compute time, but causes AI s to make mistakes e.g., circles instead of ellipses to calculate interception in Simple Soccer IMGD 400X (B 09) 8 4

Stats -driven Play individual AI performance governed by stats (e.g., speed, shooting accuracy) interactions between AI s calculated based on stat comparisons and random factors typical in reality-based sports games (NBA, etc.) not illustrated in Simple Soccer IMGD 400X (B 09) 9 IMGD 400X (B 09) Soccer Rule Simplifications ball cannot go over heads of players ball rebounds off walls no corners or throw-ins no off-side rules 10 5

(Chapter 3) IMGD 400X (B 09) 11 As aid to implementing strategies, pitch divided into 18 regions (numbered 0-17 as above) Each player has a home region starting point for match may change during play IMGD 400X (B 09) 12 6

Soccer Ball Physics Three elementary kinematic equations v = u + at d = ut + ½ at 2 v 2 = u 2 2ad Dynamics: F = ma Acceleration (a) is Friction in Params.ini Soccer ball only checks for collision with pitch boundaries angle of incidence equals angle of reflection ball moves freely through players feet IMGD 400X (B 09) 13 Kicking a Soccer Ball In reality: player swings foot toward moving ball force on ball at moment of collision with foot changes velocity of ball Approximation in game: pretend ball stopped at moment of kick player gives ball fixed initial velocity easier to calculate looks ok IMGD 400X (B 09) 14 7

(Chapter 3) 15 Player Roles in Soccer Team Class Receiving Player waiting to receive kicked ball may be null Closest Player to the Ball updated every tick never null Controlling Player more contextual: passer, receiver, attacker may be null Supporting Player works with controlling player always defined when controlling player defined May need to extend these to improve team strategy! IMGD 400X (B 09) 16 8

Scoring Support (Sweet) Spots SupportSpotCalculator instance for each team possible destinations for supporting player in opposing half-pitch (default 13x6) each rated for (weights in Params.ini) safe passing (Spot_PassSafeScore) goal scoring potential (Spot_CanScoreFromPositionScore) distance from controlling player (Spot_DistFromControllingPlayerScore) IMGD 400X (B 09) 17 Code Walk Non-agent entities: Soccer pitch Goal Soccer ball Support spot calculator Main loop IMGD 400X (B 09) 18 9

Team States (Upper Tier AI) other team possession Defending Attacking our team possession goal scored goal scored Prepare..Kickoff play starts IMGD 400X (B 09) 19 TeamStates::PrepareForKickoff entered start of match after goal scored sends all players to (defending) home regions waits until all players are home transitions to Defending state IMGD 400X (B 09) 20 10

TeamStates::Defending change home regions to blue (defending) set steers all field players to homes if team gets control, transition to Attacking IMGD 400X (B 09) 21 TeamStates::Attacking change home regions to red (attacking) set choose supporting player / spot if team loses control, transition to Defending IMGD 400X (B 09) 22 11

FieldPlayerStates::GlobalPlayerState handles messages between players Msg_SupportAttacker Msg_ReceiveBall Msg_GoHome Msg_Wait (not used) and from team to players Msg_GoHome Msg_PassToMe no messages from players to team in this implementation (could add!) IMGD 400X (B 09) 23 Field Player States MSG: ReceiveBall MSG: SupportAttacker ReceiveBall in receiving range SupportAttacker team lost control not closest MSG: GoHome Dribble can't shoot or pass kicked in range KickBall ChaseBall can't kick closest ReturnToHR at home MSG: PassToMe MSG: Wait goal or pass attempt Wait IMGD 400X (B 09) 24 12

FieldPlayerStates::ChaseBall turn on seek steering to ball s current position if in kicking range, transition to KickBall if no longer closest player, ReturnToHomeRegion turn off seek when exiting IMGD 400X (B 09) 25 FieldPlayerStates::Wait hold position at current steering target turn on arrive steering to return if jostled by another player (collision avoidance) if upfield of teammate in control, send Msg_PassToMe to controlling player if closest to ball and no current receiver (and goalie does not have ball), transition to ChaseBall IMGD 400X (B 09) 26 13

FieldPlayerStates::ReceiveBall entered in response to Msg_ReceiveBall telegram contains target location of ball at most one player on team in this state choose between arrive vs. pursuit steering towards ball always use arrive if close to goal or threatened otherwise, random variation if close enough to ball or team loses control, transition to ChaseBall IMGD 400X (B 09) 27 FieldPlayerStates::KickBall if max kicks/sec exceeded or goalie has ball, transition to ChaseBall if CanShoot (see later), Ball()->Kick() random noise, pot shots transition to Wait assign supporting player and send Msg_SupportAttacker else if threatened and CanPass (see later) assign receiver and send Msg_ReceiveBall otherwise, transition to Dribble assign supporting player and send Msg_SupportAttacker IMGD 400X (B 09) 28 14

FieldPlayerStates::Dribble turn upfield if necessary (maintaining control of ball) repeat kick ball short distance transition to ChaseBall which will transition to KickBall which will transition to Dribble IMGD 400X (B 09) 29 FieldPlayerStates::SupportAttacker steer ( arrive on ) to selected support spot support spot re-evaluated every update if CanShoot and not threatened, then send Msg_PassToMe to controlling player (attacker) if cannot request pass, the remain at support spot and track (face) ball if team loses control, transition to ReturnToHomeRegion IMGD 400X (B 09) 30 15

Goal Keeper always faces ball steering behaviors use velocity-aligned heading special vector m_vlookat IMGD 400X (B 09) 31 GoalKeeperStates::GlobalKeeperState handles two messages Msg_GoHome Msg_ReceiveBall IMGD 400X (B 09) 32 16

Goal Keeper States too far from goal (unless closest to ball) ReturnHome MSG: GoHome too far from goal back at goal or not our team possession ball within range TendGoal pass ball has ball InterceptBall has ball PutBall..InPlay MSG: ReceiveBall IMGD 400X (B 09) 33 GoalKeeperStates::TendGoal move laterally, using interpose steering to keep body between ball and rear of goal if ball comes within control range, transition to PutBallBackInPlay if ball comes within intercept range, transition to InterceptBall IMGD 400X (B 09) 34 17

GoalKeeperStates::PutBallBackInPlay send Msg_ReturnHome to all field players (including opponents!) pass to teammate transition to TendGoal IMGD 400X (B 09) 35 GoalKeeperStates::InterceptBall steer towards ball using pursuit if close enough to trap ball transition to PutBallBackInPlay if move too far from goal unless goalie is closest player to ball transition to ReturnHome IMGD 400X (B 09) 36 18

Typical Goal Scored on Keeper IMGD 400X (B 09) 37 Key AI Methods in AbstSoccerTeam ispasssafefromallopponents CanShoot FindPass GetBestPasstoReceiver IMGD 400X (B 09) 38 19

ispasssafefromallopponents direct pass assume kicked ball speed > max player speed then any player behind kicker is safe how to calculate behind? IMGD 400X (B 09) 39 ispasssafefromallopponents (cont d) transform to local coordinates of kicker all opponents (e.g., W) with negative x coordinate are behind kick (i.e., safe) IMGD 400X (B 09) 40 20

ispasssafefromallopponents (cont d) Q how about opponents beyond receiver (x coordinate > B), e.g., Q? if distance to receiver (BQ) is greater than pass distance (AB), then safe IMGD 400X (B 09) 41 ispasssafefromallopponents (cont d) how about side passes? same condition for opponents beyond receiver, except use side target points IMGD 400X (B 09) 42 21

ispasssafefromallopponents (cont d) how to eliminate remaining opponents? compute closest intercept point (e.g, Xp, Yp) compare time for ball vs. opponent to reach intercept point adjustment for ball size and capture distance ignoring time for opponent to rotate IMGD 400X (B 09) 43 CanShoot choose random points along back of goal check that not too far (force vs. friction) call ispasssafefromallopponents IMGD 400X (B 09) 44 22

FindPass call GetBestPassToReceiver on each teammate beyond MinPassingDistance choose teammate who can safely receive pass that is furthest upfield IMGD 400X (B 09) 45 GetBestPassToReceiver eliminate if receiver too far (force vs. friction) doesn t consider receiver running toward passer consider side passes IMGD 400X (B 09) 46 23

GetBestPassToReceiver (cont d) compute range (dotted circle) of receiver within time duration of pass using time duration to current receiver position reduce range to 30% to allow safety margin (turning, etc.) side pass targets are ip1 and ip2 check that inside pitch call ispasssafefromallopponents IMGD 400X (B 09) 47 Code Walk ispasssafefromallopponents CanShoot FindPass GetBestPassToReceiver IMGD 400X (B 09) 48 24

Params.ini... // weights used to calculate the support spots Spot_PassSafeScore 2.0 Spot_CanScoreFromPositionScore 1.0 Spot_DistFromControllingPlayerScore 2.0... you might think that the name on each line identifies the variable that is set WRONG you might think that the variables can be listed in any order WRONG ParamLoader.h IMGD 400X (B 09) 49 Parameter File Loading We ll see a much better version of this using Lua in Raven code any order add variables use expressions as values IMGD 400X (B 09) 50 25

Strategic Parameters // scoring values for support spots Spot_CanPassScore 2.0 Spot_CanScoreFromPositionScore 1.0 Spot_DistFromControllingPlayerScore 2.0 // when an opponent comes within this range the player will attempt to // pass (the higher the value, the more often players tend to pass) PlayerComfortZone 60.0 // minimum distance a receiving player must be from the passing player MinPassDistance 120.0 IMGD 400X (B 09) 51 Strategic Parameters (cont d) // minimum distance a player must be from the goalkeeper before it will // pass the ball GoalkeeperMinPassDistance 50.0 // the distance the keeper puts between the back of the net // and the ball when using the interpose steering behavior GoalKeeperTendingDistance 20.0 // when the ball becomes within this distance of the goalkeeper he // changes state to intercept the ball GoalKeeperInterceptRange 100.0 // how close the ball must be to a receiver before he starts chasing it BallWithinReceivingRange 10.0 IMGD 400X (B 09) 52 26

Making Buckland s Code Multi-User To support tournament play Factory pattern for teams Unsolved problems: reusing states changing parameters IMGD 400X (B 09) 53 Factory Pattern Goal: decide at run-time (e.g., by loading info from Params.ini) which team class to make an instance of avoid directly calling new with class name in game initialization code Solution: define an abstract class (AbstSoccerTeam) with a factory method (maketeam) use inheritance/polymorphism IMGD 400X (B 09) 54 27

Factory Pattern [singleton registry] TeamMaker->newTeam( BurkeTeam ) [singleton factory] BurkeSoccerTeamMaker->makeTeam(...) # [subclass AbstSoccerTeam] new BurkeSoccerTeam(...) IMGD 400X (B 09) 55 What s Not Solved All the states need to be copied why? Changed values in Params.ini need to be replaced at point of reference why? G.J. Sussman: The flexibility of a unit of code is directly proportional to the number of levels of indirection it uses. IMGD 400X (B 09) 56 28

Homeworks Sunday: My Team Weds: Team Design Weds: Tournament Team IMGD 400X (B 09) 57 29