Sunday, 20 August 2017

A.I. Debugging

So yeah, the game library has been re-written in SFML. Don't ask me why, it just has a much nicer API than SDL and, well, I thought it'd be fun to learn it. Anyway, we're back to the stage of programming basic player behaviors. This video shows the debug display to tell what brain state the players are in.

Also added console commands to instruct players and a mouse wheel zoom feature. Again, only for troubleshooting.
Quick Description:

1. Players default to their SUPPORT state. In this state they simply go to the pitch sector as defined in the tactics file for their position. This is depending on the current sector the ball is in.

2. We manually activate the GET BALL state for one of the players. This state simply makes the player run to the ball.

3. When a player senses that he is in control of the ball, he automatically changes to the DRIBBLE state. This state (for now) causes the player to run around the field, changing direction randomly. It also checks for possible short pass recipients (team mates inside the debug triangle). The triangle turns green to show a short pass candidate has been found.

4. If a pass is available, the dribbling player will change to the PASS state (this state is over very fast so difficult to spot the debug text) which does 2 things: a) pass the ball to the designated receiver; b) inform the player who he is trying to pass to.

5. On being informed that he is the receiver, the receiver will change to the RECEIVE state which makes him attempt to intercept the ball. The player in PASS state returns to SUPPORT.

You may have noticed this cycle being broken every now and then. This is caused by the pass receiver taking a heavy first touch and losing control,  thus automatically transitioning from DRIBBLE to SUPPORT immediately.

When the match engine is more developed, there will be a mechanism for teams to recover from such situations.