Thursday, February 15, 2007

Ok, a little later than I had hoped but today I started working on match engine elements. More specifically, the problem of devising the basic formations, and with that the positions a player will take up depending on the situation.



I built this editor today. The basic system is the same as that of Sensible Soccer, Championship Manager, New Star Soccer 3, Football Manager, and probably countless other management games out there. The pitch is split into twelve segments in a 3x4 grid, and players are given rough positions on the pitch for when the ball is in each grid. This is duplicated for possession (the Wibble in the combo box above referring to "With Ball", which any CM players might be familiar with).

It's a starting point, and nothing more. The first big hurdle of football AI is getting a player to have an idea of where he's supposed to be, and you've basically got two choices. You can build a hugely complex module which factors in every known factor, from the number of players on either team to the length of every blade of grass, and results in a perfect position for the given situation at the cost of several billion clock cycles... or you can just use your intuition and do it manually, once. (Don't take the screenshot as an example of my intuition.... those are woeful positions for a left wing ball)

Then you tweak. You tweak for all the little things - where's the ball, exactly? Is it safe to move? Will I have an advantage if I go over here? Why can't I get enough alcohol home from the shop in one trip?

Tweaking, when we're worried about clock cycles because you want to process as many matches as possible, is cheap. Stick a bag of grass in front of a sniffer dog and he's going to find it much quicker than when you shove it up your... chimney. Mainly because a dog isn't a burrowing animal. No, not burrowing.... chimney sweep. Yes... that will do.

I've decided upon 38 unique positions a player could possibly have, and they're on the right. The guys who play in the centre each have five different values because there are always differences depending on how many are playing at the back. A flat back four doesn't want to have any of its players assuming the same role as a the middle guy in a back five, so I've tweaked accordingly. I've also thrown in three sweeper positions just so you can too.

What I haven't done is take into account how positions change depending on the other guys on the pitch - having a central defender might well change where the "ideal" positions are for your centre backs. But to throw that into the mix would mean my list of positions would be a lot greater, and worse it would be more complex to actually devise the individual formations.

The theory, at present, is that these are created simply by using the defaults. Two strikers in a 4-4-2 will always begin their position-finding routine at the same place as two strikers in a 4-2-4, where the other guys are the "advanced wingers" as I've put it. The routine ought to change those positions accordingly to best use the space available.

If this theory falls down, then I'll run with the ability to change the positions for all the formations, but these defaults created will serve as a simple method for giving me a base from which to build each formation.

Elsewhere, I've been working on player generation, which I'm mostly happy with but clearly there are a few things that need ironed out.


The first, most obvious one if you check that screenshot is that player names are a little on the poor side. These guys were all randomly generated (and I've added a flag to them so I can remove them with ease), but the existence of chaps like Sabatino Greenwood means I need to work on a much better method for creating player names. At the minute, all the English names are kept together, which is lovely when you get William Carr, but not so nice when Ciaran El-Salahi rears his ugly head (he's not there on the screen before you look for him, but he did come up once).

The flaws don't end there - the physical characteristics haven't panned out too well yet either but then I knew they would be borked from day one. It's entirely random at the moment so when you get several seven-footers with light blue dreadlocks and bum-fluff moustaches roaming the midfield, you can't really say you're surprised. I'll work in a normal distribution there to the generator to ensure more normal people.

What are working well are the routines that deal with player attributes. Positions are linked, so if the game sees fit to throw up a centre back, there's a chance he could work well in a defensive midfield role, or even as a full back. Attributes are then linked to positions, depending on competence in that role - a natural striker is throwing up strong finishing and movement, whilst a reasonable defender might not be a great tackler, but he won't be shit at it either.

This early random generation means I can knock up a number of teams for use during the development for the match engine, which should hopefully prove invaluable. Better still (can something be better than invaluable?), when the match engine has reached a solid, playable point, I can swiftly create and populate enough teams to turn a collection of reasonable looking screens with no real purpose into an actual working game. At this point I will stroke my beard and proclaim victory over the elements, chiefly boron. I have issues with boron. Don't ask.

Finally in a lengthy blog post, work continues on FryGUI and I'm hoping to get the latest release out this weekend. A lot has been added since the last version, the most spiffing of which being the inclusion of a canvas gadget, but there's also a few image buttons (of the rectangular and circular kind, too) and some other smaller stuff. Oh, and I wrote a new data editor for the game (that'll be it there in the second screenshot), which started off annoying because I think it's the fifteenth so far, but it works cross platform and is significantly more attractive than the drab, grey look. One problem with it is that I can't cut and paste, and more annoyingly I don't think I will be able to on anything other than Windows, but I'll see if I can build a character map or some other form of adding the rarer characters
into FryGUI.