Sunday, 12 April 2015

Now That's Interesting...

Another milestone dev session tonight. Amongst a few other things, I decided to add code in so that the buildings now spawn people. Neutral buildings spawn neutral people, light buildings spawn light people and dark buildings spawn dark people. Neutrals have a 1/1000 chance to spawn, dark 1/2000 and light 1/4000. I thought that over time, there would be more and more neutrals, but instead something quite interesting happened.



When you start the game, you get something like this:



Leave it running a few minutes, and you end up with:





Even though neutrals spawn more often and start off much more numerous, they quickly choose sides and the 'battle' becomes more and more polarised.

The reason I found this interesting was that, when I first started creating this, I wanted it to be a game about media and ideologies. I wanted there to be a simple simulation of the processes that occur in real life. I thought about it in terms of systems but didn't ever think about the end results. Now what I'm seeing is that over time, these little game people become more and more polarised, which in some ways reflects real life.

Obviously, my little computer people are defined only by their beliefs. They move, they have a level of belief in one of two ideologies, and they can influence others towards that same ideology. In real life, there's a lot more to people that that. There's a much bigger proportion of people who don't care about politics, and there are many reasons for that. I'm starting to wonder now if I should try modelling all these other things, stuff like work and family commitments for example. The original plan was to require the player to have some needs that needed attending to, but that was essentially going to just be something like a 'needs' resource that reduced over time and had to be topped up.

I'm a little worried that adding complexity is going to make the mechanics very opaque, though. In a sense, the mechanics are the point, so I'm kinda wary about it. I dunno, it'll take a bit of pondering.

In the meantime, here's the code for having a building spawn people:

if ( irandom (neutralSpawnChance) = 1 )
{
    //spawn oPersonNeutral at top, right, bottom or left
   
    if ( irandom (4) = 1 )
    {
        instance_create (x, (y-42), oPersonNeutral);   //top
    }
   
    if ( irandom (4) = 2 )
    {
        instance_create ((x+42), y, oPersonNeutral);       // right
    }
   
    if ( irandom (4) = 3 )
    {
        instance_create (x, (y+42), oPersonNeutral);       //bottom
    }
   
    if ( irandom (4) = 4 )
    {
        instance_create ((x-42), y, oPersonNeutral);   // left
    }

}

The first part chooses a random integer, out of neutralSpawnChance (a global variable, set elsewhere as 1000). If that random number is a 1, we go spawn a neutral person. Now, I didn't want the people to all spawn at the same point of the building, so I basically made it so that they can spawn at the top, bottom, left or right. So after it's been decided that a person will be spawned, I've used irandom again to decide where. On a 1, it'll spawn top, 2 is right, 3 is bottom and 4 is left. I'll just use the top (1) as an example:

if ( irandom (4) = 1 )
    {
        instance_create (x, (y-42), oPersonNeutral);   //top
    }

So there's a 1 in 4 chance that the person will spawn at the top of the building. We use instance_create to do that. instance_create has three arguments in brackets - x coordinate, y coordinate and the object to be spawned. X is along the horizontal axis, so we don't need to worry about that - so putting "x" there just means "current x coordinate". We have to change y though. GameMaker, somewhat unintuitively, has y increase as you go down the screen, so in order for the object to be spawned further up from the the current object's y coordinate, we have to use it - hence the -42.

(I did originally want to do this based on sprite heights and stuff, rather than a set integer but I kept getting it wrong and then reached the point where I was like "why am I making this difficult for myself?")

oPersonNeutral is the object that is then spawned at the stated location.

So now, as far as the basic mechanics go, I just need to add the stuff for the player's own influencing and that's about it. I'd like to go about tweaking things and look into modelling systems a little more in-depth, but I'm just worrying about the basics for now.

Anyway, nearly midnight. Time for dinner.

No comments:

Post a Comment