Sunday 30 March 2014

Phew

And after a few hours work, following on from the previous post, here's a first test of "covering" positions for a basic 4-4-2 using the "sector system" of positioning.

Needs some tweaking, but pretty solid for the proof of concept.


This midfield is clearly composed of Juan Mata, Mesut Ozil, Luka Modric and David Silva.

Simplifying Tactics

Well I've just wasted about a week of work by trying to be too clever!

Not truly wasted though, that's the point of the project; always learning something. Anyway, I had some really intricate ideas involving calculating the ball position, distance from ball and taking into consideration opposition positions with vector maths to come up with some "intelligent" movement which could simulate flock behavior, cohesion, separation etc...

It works, to a point. But the problem is that there are so many variables involved and so many different rules for different positions (center back, center midfielder) etc that it becomes almost impossible to allow the user to define his own formations and tactics.

So I'm going back to the basic method which, I assume, the original Sensible Soccer used. Basically the field is divided into a grid of squares and, for each player position, we define a square that he should try to get to depending on which square the ball is in.

It's a LOT of tedious work to set up, but once the initial framework is in place it'll be pretty quick and easy to create custom tactics though copy 'n' tweak.

The more squares there are, the more realistic and customizable (apparantly that's not a word, why not!?) the tactic, but the more work it is to define. For the sake of the game, I've veered to the side of "more squares for more fun." Here's how the tactical layout looks. You can see the potential for customization that when you consider for every ball position, you can specify which square any particular player should try to get to.

Later on, these basic instructions can be modified by general team tactics like "press" or "cover."

That's 285 positions to specify per player position, per situation. Eek! But remember, half of the positions can be simply mirrored to the other side of the pitch, and certain situations don't need to be specified but can be calculated, eg "one square north and one square east."

Sunday 23 March 2014

Look at the State of Ye!

Here we see the power of the state machine pattern. It takes a bit of time and effort to get set up, but once in place it is extremely clean, flexible, extensible, and easy to debug.

Everything is a state machine (well, almost). The player, his brain, the match, the team... all state machines.

Here is a vid of the game automatically going through the start phase of the match -

- state enter pitch
- state lineup
- state kickoff
- state play




we now have the framework in place to start giving the player AI some real goals and objectives, and hopefully get something resembling a real match. Onward!

Friday 21 March 2014

Kickabout

Now the players have an extremely basic brain hacked in, just to show what's possible. Now... time to program some real Digital Minds!! w00t!

Pitches

More updates to report. Variable pitch sizes are now possible. That's pretty cool. I heard Man Utd were thinking about making their pitch a bit smaller to suit their new style and players. Barcelona have a big wide pitch to stretch the opposition with their precise passing and control of the ball, Utd are reducing theirs to a 5-a-side pitch because they only have 5 decent players left.

Anyway, also threw a few wee men onto the field and gave them enough brains to find their starting positions. Looking pretty cool.

Digital Mind...

The very first hint of a smell of a whiff of a bi of AI... the goalie picks it up, runs to a random spot in his box and hoofs it upfield to nobody in particular. STILL better than Jamo then...

David James

You might have noticed a goalkeeper sneaked into the last video. Yeap he has pretty good base position between the goal and the ball and now he can even dive! So that's better than Jamo already then... Oh, also added a stadium for fun.

Mental!

Whilst messing around with the new ball physics, it occured to me that it'd probably be useful for the players to know where the ball is going, and not only where it is.

It helps with stuff like through balls etc, where the player can run directly into the future path of the ball instead of readjusting frame by frame.

Introducing Mr. red dot. It's not a laser sight, just a cool prediction of where the ball is going to end up.

Balls

That good ol' ball optical illusion is still pretty sweet. But lets have a go at enhancing it. A more detailed ball graphic, resizing it depending on the height and a rolling animation in proportion to the speed all makes for a pretty nice effect.

Cookin With Gas

Alright, things are really starting to move nicely. We got some goals in there and actually added a bit of collision detection and reaction. Check it out:


Bananas

Alright this is just another quick sidetrack, experimenting with sensi's famed "aftertouch" system. Certainly potential there and we'll come back to this later! Cool.



Short Experiment

Just for fun, I experimented with some dribbling mechanics. Back in the day, Kickoff 2 was the king of footy with its ping-pong like dribbling and then sensi came along with its sticky-feet approach. This was an attempt to combine the two for some interesting gameplay. It failed. Oh well, it was good fun anyway.

I also resized the game world and added nifty chalk lines. Yep, chalk. Honestly. Did yo know there's limestone in that? Yeah, it's in everything apparently. According to dad, at least. Ok, enough with the inside jokes. Here it is:

Out of the Box

So the next step is to "get out of the box" and implement us some scrolling. This implies a camera too, yay!

Basically what we have here is a map of repeating tiles, with the camera deciding exactly which portion of that tile map to render to the screen.

We also had to add the functionality for rendering the sprites in world space - that means offset depending on the position of the camera. Finally, we can tell the camera to "follow" any renderable object, thus keeping it in the center of the screen. More on that later.

The camera is a bit like the spoon. It doesn't really exist. It's just a bunch of cleverly organized and updated numbers. Pretty nifty.

The first go looks something like this:

Getting Something on The Screen

This isn't supposed to be an overly technical blog, so I'll get the basics out of the way quickly. I've gone with SDL2 for its hardware acceleration and cross platform support. Everything is gonna work on Wiondows, Mac and GNU Linux. W00t!

So, building on top of SDL, we knock up a basic Renderable class and then derive a Sprite class from that. Ahhh sprites... graphics is one of the many things that I just can't do for shit. So for now I'll be begging, borrowing and stealing whatever the hell I can get my hands on.

Eventually, I'm gonna outsource and get some sweet graphics custom made but for now, a shout out to the folks at Yoda Soccer for making theirs available.

So, with some graphics and some code for getting them to the screen, we knock up a simple physics and math library and we code a ball with that nifty optical illusion, an input handler and we come up with something like this:




Wednesday 19 March 2014

The Story So Far

Alright, Sensible World of Soccer (SWOS) is clearly one of the greatest games ever made. As a gamer back in the day, it was like all of our christmases coming at once.

Leaving the gameplay aside, which is legendary anyway, you could play a 25 year, authentic, fully integrated career mode with real competitions, real teams, real players, transfers, hirings, firings, tactics, promotions, relegations and even...... wait for it......... Carrick Rangers. Carrick fucking Rangers!

Anyway, as a programmer, one day it tickled me just how much mileage they got out of a simple shadow. It may be stating the bloody obvious, but that friggin ball doesn't get any higher. It doesn't even get any bigger dammit. You get a pretty spanking cool illusion out of merely moving the position of the shadow on the pitch. Shiny.

So I thought to myself "I'll have a go at that." And I did. Then I thought "why stop here?" And I didn't.

Hence this blog. The first installment of "actually finish a private project instead of just fannying around with cool stuff and then forgetting about it" will be Senseless Soccer - a simple clone of Sensible Soccer with a few twists thrown in here and there for good measure.

P.S. I had the idea for a blog whilst thinking about a bit of A.I. for the players, hence the silly little (yet appropriate) blog title.

Ahoy!

Tuesday 18 March 2014

Dev Rig


No prizes for guessing the most important piece of kit.






(yes, it's the cup of coffee)

Test

This is a test post, tralala.

Here is some test syntax highlighting for blogger:

// ----------------------------------------------------
//   round the angle to nearest x degrees
// ----------------------------------------------------
Vector3 Vector3::roundAngle ( int nearest_angle )
{
        // vector to return
        Vector3 rounded;

        // convert to radians
        float nearest_radians = RADIANS ( nearest_angle );

        // get the angle of this vector
        float angle = ( float ) atan2 ( this->y, this->x );

        // remainder between 2 angles
        float remainder = std::fmod ( angle, nearest_radians );

        // if there is a remainder, do the rounding
        if ( remainder != 0 ) {
                float new_angle = ( float ) round ( angle / nearest_radians ) * nearest_radians;

                rounded.x = ( float ) cos ( new_angle );
                rounded.y = ( float ) sin ( new_angle );
        }

        if ( fabs ( rounded.x ) < TOL ) rounded.x = 0.0f;
        if ( fabs ( rounded.y ) < TOL ) rounded.y = 0.0f;
        if ( fabs ( rounded.z ) < TOL ) rounded.z = 0.0f;

        return rounded;
}
sweet.

Saturday 1 March 2014

Wots Goin On?

Hello. I'm a software developer who likes to code games and things in his spare time. I do it mostly for fun, and to learn shit that I'm interested in but don't have the opportunity to learn at work... like OpenGL and cool balls like that.

Anyway, I've whittled away countless of my "leisure hours" tapping up everything from an object oriented wrapper for the Windows MFC (ugh, remember that?) to a pretty useless OpenGL "game" that allows you to fly around a starfield in a dodgily skinned spaceship model and do absolutely fuck all.

Now I've decided it would be a good idea to actually finish one of these little brain farts and I'm hoping this blog will help give me the motivation to do that.

Finally, to give you a clue where I'm coming from, here's some epic keywords in no particular order:

Amiga NBA Jam Shadow of The Beast Moonstone Counterstrike Championship Manager 93 New  Zealand Story Kickoff 2 Stunt Car Racer Sensible Soccer (goal scoring super star hero) Wrestlefest Supercars 2 FIFA SNES Street Fighter 2 Half Meg Upgrade (!!) WWF Royal Rumble Megadrive Smackdown! Pro Evo Day of the Tentacle Mortal Kombat Monkey Island (Insert disk 12) Speedball 2  (ice cream! ice cream!) Microprose Grand Prix Fate of Atlantis IK+