A simple diagram A.I for Soccer and other sports games


I've played a few soccer projects on Hopscotch and there's virtually no A.I. For detecting where the player is and having the CPU players pass the ball to another CPU player away from the players character.

This diagram is hopefully an easy way to explain how to do this.

The green"P" is the players character.
The blue 1,2,3" are the CPU players
The red lines between the CPU players are sensor sprites.
When the "P" is touching line 1, this tells the CPU players 1 and 2 not to pass the ball to each other as the "P" is in the way
When the "P" is touching line 2, this tells the CPU players 2 and 3 not to pass to each other.
When the "P" is touching line 3, this tells th cpu players 1 and 3 not to pass to each other.

When "P" is touching a line, you set a value "Block" to that line.
So if touching line 1 , a Block value is set to 1 etc.
Hopefully this can help someone when making A.I for a soccer or similar type game.

I know trigonometry can be used for getting the distance and angle from a CPU player to the other CPU players and the players character.
I just posted this so it's easier for most viewers to understand.


Very cool.


Ayyyyee Cubs
Anyways, thats an awesome diagram and a great start for any sports game!


Kewl! :thumbsup:!!!!


Noice!!! :clap:🏻

I didn't understand a word of that but noice


Wow! That's cool!

I'll never be able to make something like that but it would be cool if someone else tried it (I don't have any time on Hopscotch)