Soccer AI, can it be done?

I'm planning on making a 1 vs 1 soccer game where you can play against an AI opponent. The Ball will bounce off of walls that are placed around the field. Is it possible to have the AI always trying to hit the ball so that the ball is aimed towards the player goal? Even if it requires the AI to bounce the ball off the wall?

Comments

  • HopscotchHopscotch Member, PRO Posts: 2,782

    Absolutely @GreenfroggGames , with a bit of maths and a bit of tables you can make a very intelligent AI soccer team (both opponent and your own). It can get complex though, so start with the small things. Break it down in small problem and master each of them before tackling the big picture.

  • GreenfroggGamesGreenfroggGames Member Posts: 224

    @Hopscotch Do you mean placing a lot of coordinates in a table?

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @GreenfroggGames

    Sure, keep track of all the player positions in a table.

    That way you can build up logic for each player according to their position (defensive, midfield, attackers), such as passing to other team mates, going for the goal or falling back into formation.

  • GreenfroggGamesGreenfroggGames Member Posts: 224

    @Hopscotch Sounds great, I'll give it a go. Thanks :)

  • smurftedsmurfted Member Posts: 586

    I started trying to work this out a while back and got lost, very lost. If it wasn't for the bread crumbs i'd still be lost now..

  • GreenfroggGamesGreenfroggGames Member Posts: 224

    @smurfted Sounds like I might not want to go down this path :smile:

  • PhilipCCPhilipCC Encounter Bay, South AustraliaMember Posts: 1,390

    @GreenfroggGames said:
    @smurfted Sounds like I might not want to go down this path :smile:

    I can't commit enough time to try this myself, but what about a two-players game like tennis or handball as a place to start figuring this out?

  • GreenfroggGamesGreenfroggGames Member Posts: 224

    @PhilipCC I don't get that much time to work on games nowadays, so this kinda scared me off. Will stick to simple and small games for now. Thanks tough :)

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited January 2017

    @GreenfroggGames , @PhilipCC

    "Complex" does not equal "Complicated"

    One can come up with 2 or 3 very simple rules for each player and have very clever "looking" and complex behavior emerge from it.

    Just as a start:

    Defence/midfield

    • If ball is close, move to ball and pass to a player in an attacking position
    • If ball is out of range move back into formation

    Attackers/strikers

    • If ball is close, move to ball and shoot at goal
    • If ball is out of range move back into formation

    Get these simple rules implemented and you already have the semblance of a cooperative team.

  • GreenfroggGamesGreenfroggGames Member Posts: 224

    @Hopscotch Thanks for the tip. I think I'll do a 1 on 1 game with some fun gameplay twist :)

  • smurftedsmurfted Member Posts: 586

    True hopscotch. What i started getting lost on was ownership of the ball & control handover. While it was working it didn't feel very smooth..

    That said it was a while ago, maybe i should have another bash.

  • PhilipCCPhilipCC Encounter Bay, South AustraliaMember Posts: 1,390

    @Hopscotch I love the way you break things down into a simple algorithm. :)

    Once I download Sierra on my IMac I'm going to give those instructions to Siri and see what she comes up with. :D

  • hybridhybrid Member Posts: 183

    the first game i made was a "table football" style. i made it that way because its a more easy approach than having real players running free , the AI its just the bar moving up and down following the position of the ball. So its really not that accurate but it seems that people like it.

    so i think its posible to do a simple 1 on 1 soccer style game

    good luck! =)

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @PhilipCC said:
    @Hopscotch I love the way you break things down into a simple algorithm. :)

    Once I download Sierra on my IMac I'm going to give those instructions to Siri and see what she comes up with. :D

    That gives me an idea for a voice driven soccer app for Alexa, with the gameplay given back as running commentary. Coming soon! :D

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I built an AI for my air hockey game. Building a simple AI is a good place to start. The tricky part of building a good AI is adding the human element into it. It's easy to build an accurate AI, it's much trickier to build one that makes mistakes randomly.

Sign In or Register to comment.