Sunday, 6 April 2014

Quirks

One of the quirks of sensible soccer is that the player can only run in eight directions. This was a necessary mechanic back in the day due to the joysticks and gamepads being strictly 8-directional.

Believe it or not, the modern style FIFA games worked pretty much the same way until quite recently (you can see them making a big deal out of "360 degree movement" in their ads) where they take advantage of the analogue "thumbsticks" on modern controllers.

Such a system wouldn't really work with a retro style sprite based game, as you'd have to have either a huge amount of sprites to cater for small differences in the angle of movement, strictly top-down sprites that can be rotated by the game, or ridiculous looking players who look in a slightly different direction to where they're headed.

So we're sticking with the simple sprite-based 8 directional movement scheme. It'll be slightly unrealistic for players like Rio Ferdinand, who only seems to be able to move in 4 directions these days, but what can ya do.

This does throw up a few quirks though. For example, with the movement of the AI players, you can't simply calculate the best direction to run in and update it every frame as this results in a very unrealistic zig-zag path as they attempt to reach their target.

[note there is more complexity to this when you consider static vs moving targets but we'll simplify it for the sake of explanation]

So to get a relatively realistic behavior that mirrors how humans use the controller, we calculate the heading to the target, round it to the nearest 45 degrees and set the player off on his merry little way. Obviously, if the target didn't just happen to lie on a 45 degree angle, he'll never actually reach it and the whole thing will fall apart. To counter this, we add a check to compare the distance from the target each frame. If the new distance from the target is larger than the last distance, this is a good time to recalculate the heading to the nearest 45 degrees. This *roughly* simulates how a human player would manipulate the controller to get where he wants to go.

This is an extremely simple solution to what is a huge field in game design (path finding etc) but it's interesting nonetheless and should be a good enough solution for our purposes.

Interestingly, the original sensi solved this problem with a complete and utter cheat. Its computer controlled players are not restricted to the 8-directional movement. It's not so galling visually when the computer does it, but there was always a subconscious "hmm that's not quite right" factor without knowing exactly what was up. If you go back and play or watch it now, it's quite obvious when you know what's happening.

Who knows, perhaps there are other reasons for the "cheat" that will force us to adopt this strategy later on. Living and learning!