coding world cup

Write AIs to play football

This project is maintained by richard shepherd nick pollard

FAQ

Does the order in which the server receive commands have any effect? Say 2 players are within 5m of the ball and they both call take_possession. Say they are players 0 (from team1) and 7 (from team2). Is the outcome the same if you receive the request from 0 followed by 7 OR from 7 followed by 0?

The order makes no difference. The game-engine waits for both responses before processing them. So there is no advantage to being the first to reply. That said, I’m thinking of timing the request-response, and having a secondary prize for the most time-efficient AI.

In the docs you mention that if I call move, it auto-turns me first. Does that mean that the turn command should only really be used for improving kicking accuracy? Also, do I get penalised the same amount for turning before a move if I need to turn by 1 degree or by 30 degrees? (assuming here the server will always turn me to the right direction first before moving me).

Facing the right direction is most useful for kicking accuracy. But it can be good for moving as well. For example, in the BootAndShoot sample, the players don’t make any attempt to face the right direction. So when they need to start moving, they often are facing in a random direction and pay a time cost to turn before moving.

The time cost is proportional to the amount you need to turn. Internally, there is a calculation loop that runs ten times for every 100ms AI update, ie every 10ms of game-time. If you need to turn, you will always pay at least one of these 10ms penalties before you start moving, but you might pay more depending on how far you have to turn. Players turn at 600 degrees/second.

When moving, can I ever overshoot my target point? I.e. if I'm reeeeally close to (x,y), do I need to move at a reduced speed in order to hit (x,y) exactly during the next game tick, rather than overshooting and then having to move backwards?

You can’t overshoot, even if moving at full speed.

Can players move into the goal area? Can the goalkeeper move outside it?

No. The game-engine will prevent players moving into the goal area, or the goalkeeper moving out of it. There is no penalty for trying to do so, the game will just prevent you from doing it.

Is there an offside rule?

No.

How does move/turn work (is move just a “push” toward the specified direction)? Can I move backwards? Is there a speed penalty?

Players can only move in the direction they are facing. When you move, you set a desired point on the pitch where you want to end up. If you are not facing in the right direction, the game-engine will first turn you to this direction. This takes a small amount of time. Players turn at 600 degrees / second.

What happens with player-player collisions? Can 2 players occupy the same space? Can 2 players running into each other end up going through each other?

There are no player collisions. Players can run through each other and can occupy the same space.

What about ball-player collisions? Is it handled same as player-player? Since the ball can move faster, what happens with the “bullet through paper” collision detection? I.e. can a fast moving ball appear in front of me on one tick then behind me on the next?

The ball does not collide with the players. So it can go through them. Players will only interact with the ball is they issue the TAKE_POSSESSION action.

The physics 'engine' in the game runs ten times faster than the AI updates, to give greater precision to ball-handling. In addition to this, when you issue the TAKE_POSSESSION action, your player is on "autopilot" to intercept the ball (as long as you are within 5m of it). This means that you do not need to do manoeuvres that would be smaller than the 100ms precision of the AI updates.

Is kicking cumulative (multiple kicks)? I.e. can I kick the ball in 2 consecutive ticks in order to make it travel faster?

No. You can only kick once.

If 2 players “take possession” on same tick - who wins? If 2 players kick the ball on the same tick, what happens?

The game-engine has an algorithm to choose between multiple players who try to take possession (either of a free ball, or when tackling). This is based on the relative skill of the players, and there is a random element as well. For kicking, see below.

Do I have to have possession to kick the ball?

Yes.

What do the commands actually do (E.g. tackle)?

There is a small amount of documentation in the API reference.

Here is a quick summary of the actions:

MOVE: You set a desired destination (x, y) and a speed (0-100). The player will first turn towards the destination and then move towards it. The player moves at speed/100*playerMaxSpeed. (Note: there was going to be a concept of energy in the game, but this will most likely not be implemented. In the absence of energy, there is very little reason not to always move at speed=100.)

TURN: You set a direction, where 0 degrees is straight up, 90 degrees is facing right. So actions, such as kicking, are more accurate if you are facing the right direction.

TAKE_POSSESSION: This can only be issued if you are within 5m of the ball. It will first move you towards the ball. When you are within 0.5m of it, it will attempt to take possession, including tackling another player if necessary. Whether you are successful depends on the speed of the ball and on the player's abilities (see below).

KICK: You set a destination (x, y) and a speed. Kicking is more accurate if you are facing in the direction you are kicking. Speed is a percentage of the ball's maximum speed which is 30m/s. When passing to a player, you may want to kick at less than full speed, to give them a better chance of taking possession.

What do the abilities actually do? (E.g. kicking...is it power / precision / etc

All abilities are between 0 (low ability) and 100 (high ability). The abilities are:

kickingAbility: How accurately you kick. When facing in the direction you are kicking, 100 will kick completely accurately, 0 will kick completely randomly. Accuracy drops off the further away from straight you kick, even with 100% ability.

runningAbility: Affects the maximum speed you can run.

ballControlAbility: Taking possession of a free ball is affected by the speed of the ball and the player's ballControlAbility.

tacklingAbility: Tackling is decided by looking at the relative tacklingAbility of the player and the player with the ball. This produces a probability of getting the ball. A random element then decides whether you get it or not, based on this probability.

Dribbling - do I just move when in possession or do I need to kick the ball along the way?

You can move when you have possession, but you will only move at 40% of your normal running speed.

How do I know I have / lost possession?

There is no event raised when possession changes, but you can look at the controllingPlayerNumber of the ball object. Or you can check the hasBall field on the dynamicState of a player.

Which values accept floats and which ints? Setting abilities seems to be floats...what about move/kick/turn params? Are floats accepted and used or do you trunk/round on the server side?

Player numbers are ints, all other values are floats. Values are rounded to 3dp (ie, 1mm) when passed to the AIs, to keep the JSON a bit smaller than it would otherwise be.

Do you simulate “noise” in the physics? I.e. if I kick the ball at 90 degrees, does it go precisely at 90 degrees on a straight line until it stops or is there “noise” simulated in the movement?

There is some randomness in kicking (see above). But once the ball is moving, there is no further noise in its movement.