Vigilante


#1

Since this post got a rather nice reception, I’ve decided to lay my current project bare for you here.

What’s it all about:

I’m trying to simulate a small society living on a decrepit space station. Think of it as a building and management simulator, except without any building or management. That will all be up to the peeps themselves. They should go to work, produce goods, buy stuff, fulfil needs and all that boring stuff humans do. In the next stage I’ll want to add crime - stealing food because of hunger, pub fights, all the way to protection rings and assassinations. And of course some form of law enforcement. If nothing else, peeps should be able to beat up a would-be thief and leave them bleeding on the sidewalk, since crime is no fun if there are no repercussions, though I’d like to make my way up to law enforcement of some sort, though that would require some form of government to pay for it etc etc etc…

I definitely have my work cut out for me. There are limitless way to increase my little world’s complexity to make it that little bit more realistic. But to what end?

Well, above all else this is a learning experience for me. I’ve already learnt so much about coding and I’m having tons of fun. To my surprise, the learning is not limited to programming, as I’m forced to think a lot about all kinds of economical effects and later (probably) about politology, as various systems of government come into play.

As for eventual gameplay, I’ll let the player live in that world and fight crime in any way the see fit (and since I know most players are sadistic bastards, doing crime is going to have to be an option as well). The precise implementation of the gameplay is not really on my radar yet, as I might not even get that far (I’ll probably start with something reminiscent of text-based adventures and build on that), but the idea is that once the player inevitably either fails or gets bored and aborts the game, the world resets back to square one and iterates back to the date where the player ended, this time without their involvement. That will allow me to give the player a “score screen”, showing just how big on an impact their actions had on the game world, whether their presence significantly decreased (or increased) crime rate and maybe even how long their legacy lasted after they stopped.

Current status:

I’ve uploaded the current version to my community page, though there isn’t much to see yet. There are three view modes:

- Map, showing peeps present in each building/corridor
- Peeps, showing a sortable list of all peeps, their stats, actions etc
- Jobs, which is an overview of all buildings/businesses. Note that a lot on that page is mislabeled or just plain confusing. I don’t care.

You can advance time by a specified number with the big black button at the bottom or by pressing space and see how right off the bat the peeps scramble to go get employed and then start going to work and fulfilling their needs (Eating and sleeping, that is. Boredom currently only goes up).

There’s a powerplant, selling electricity to all the other rooms in the background (you can see its owner’s money go up each week), hydroponic farm that produces protein, a food factory turning it into food and restaurants selling that to hungry peeps. There are two kinds of apartments the peeps can rent and “sleep pods” they can use for a single night if they can’t afford better housing. If that’s full, they sleep in a corridor. The dock does nothing at all.

You can’t have any impact on the game whatsoever and since the peeps are (mostly?) deterministic drones, it should play out the same every time. I’m having fun already! Well, I actually am, as I can change stuff up and see what happens (for example the restaurant in room 8 used to almost go bankrupt before I added the power plant and allowed more peeps to make enough money to be able to afford the apartments next door. Now it’s making way more money than the otherwise nearly identical Restaurant 5. Location, location location!), but I’m afraid you’re not going to have much fun with it in its current state.

Oh, I almost forgot! There’s a hidden feature - a prototype face randomizer I made when I wanted to take a break from optimizing and do something more simple and fun. Just mash F1 and a shitty peepface will appear. A few of the graphic elements were drawn by my 5 years old niece, though that hardly excuses the rest of it. She also game me the first “review” of the game:

“Uncle, this is more fun than Minecraft!”


#2

Thanks! That is an ambitious project.
Also any new exciting development challenges recently? =]


#3

Not really a development challenge, but I wanted to set up food/rent prices, wages, opening hours and all that stuff so that all the owners and employed peeps would end up with a positive income before sharing this and it took me quite a while. The model I ended up with sees the owners get very rich while the workers barely scrap together any savings (worst off are the ones working in the power plant, since their wages are actually good enough to afford to rent an apartment).

So the select few will keep getting richer while the unemployed peeps slowly run out of starting money. Once they can no longer afford food, the whole food production chain will go as well, as they need mouths to feed to stay afloat. The homeowners will probably be fine the longest, since I didn’t implement evictions yet and I think the renters will be allowed to go to a to a debt just to pay their bills.

So overall I’d say the game’s surprisingly accurate!

Next step however, is to let the peeps set the wages and prices themselves, which might be the main reason I started this topic. Implementing that is going to be tough and I need to take a breather =D


#4

I actually DID have a little fun with it! But I always liked numbers and data. The variations are really cool.


#5

Haha… I was checking how much randomness I’m actually using and the only instances are that peeps who don’t own any business start in a random corridor at the beginning and when looking for job, if there are two positions that offer the same wage, they’ll pick one at random.

…but none of that really matters, since I left math.randomseed(os.time()) commented out, as I wanted to get the same outcomes while testing and forgot to re-enable it =D

You could get a slightly different outcome if you use the face generator before the peeps get employed, though, as that uses up quite a few random numbers.


#6

Ambitious but fun! Slap some graphics on it and you have RimWorld or similar games!


#7

I’ve officially fulfilled my current goal:

Stick with it long enough to see the code turn into a horrid inefficient mess I don’t understand at all

However - with one last exertion of will I’ve managed to make that confusing mess to behave the way I want, so I guess I can go on and hopefully I’ll be able to tame it by the time I have to revisit that particular part of the code.

One funny thing that happened to me - after a few changes the program started to hang up whenever I ran it. No errors, no crash, just hanged. After hunting the bug down, I realized that the equation to determine minimum price for a product was (expenses / demand) + 1 so that the business would always make some profit. Turns out zero demand made the minimum price Inf + 1, which lead to an infinitely looping for cycle somewhere below…

In hindsight, it makes sense. If you won’t sell anything, you’ll have to sell it for more than infinity to recoup your non-zero losses.

Anyway, now I need to fix anything that got broken, clean it up a bit, and I should have an update shortly.


#8

One way to do it for wages is to configure a stress rating into jobs. Characters then randomly generate an expected stress rating for that job based on the value, and ask for a wage that “pleases” them with that stress rating. The hours/shift they would have to work could also have some sort of effect on their wage. If they are accepted and the stress is much higher than expected, they are more likely to ask for a promotion/raise earlier.

As for business prices, it looks like you’re already way ahead of me.


#9

I have something like that, though I call it “work shittiness rating”.

The problem I had was why would anyone offer better wages than 1 when there are jobless peeps for who even that would be an improvement? What I did was define a minimum wage (just enough to buy one portion of the most disgusting meal available each day) and an efficiency rating based on the percentage of this wage the workers are paid. The function is a hyperbola that goes through (0,0) (so that they don’t work at all if not paid), (1,1) (so that they have optimal work efficiency is paid minimal wage) and as wages trend towards infinity, the efficiency approaches 150%. I can multiply the minimum wage by the shittiness rating so that higher wages are required for the peeps to keep working efficiently for different jobs.

Later on I can add the peep’s own preferences and qualifications to determine how happy they’d be in a job should they take it and change their real efficiency based on that should they take it.

The system seems to be working just fine - the prices and wages usually settle so that the workers are paid slightly more than minimum wage. There’s one outlier though:
The power plant is currently underused, as there are only few buildings and only about one third of maximum production capacity is needed. I was expecting the owner to hire a third of the maximum number of workers and pay them minimum wage to meet this goal, but turns out it’s more efficient to hire close to the maximum number of workers and pay them shit. They hardly do any work, but it’s enough to meet the power requirements. Maybe later I’ll have to adjust the equation to make it ramp up more slowly, but for now I think it’s fine. It’s their lives, who am I to tell them how much to pay their workers?

As an aside - I took math when I graduated from high school and conic sections was the one question out of 30 I picked (and it also happened to be the only subject I didn’t prepare for, as it’s just too painful and hey… 29 out of 30 are not bad odds). My teacher later told be that as I was transforming the equations given again and again in front of the commission (trying to remember what the damn canonical forms were) she was thinking to herself: “Well, he has the correct answer there. I should stop him and tell him he’s made it. But… he’s having so much fun with it… I’ll let him work for just a little while longer”.

Anyway, that was more than 10 years ago and turns out I’ve forgotten so much since then. It took me two days to come up with this equation and it was only thanks to online plotting tools, though I have to admit it felt good to finally crack it.


#10

OK, the investment and price setting system works now. Here’s how:

The game starts with just empty rooms this time. Since there’s currently no way a built business can disappear and things don’t really change during “gameplay”, the investment function only gets run at startup, but I could call it whenever a new investment opportunity shows up, or just periodically.

It finds out which resources are in demand or being produced and then calculates the expected profit of each of the buildings that can be built:

If the building requires workers, it finds out the best combination of number of workers and wages that will allow it to meet the demand, based on the function I’ve described in the previous post.

Then it finds the lowest price for the product which (after expenses) gives it enough profit so that the construction cost (preset, different for each building, ranging from 1000 to 3000) returns within 30 days. The theory is that the price is set in a way that it’s profitable, but a hypothetical competitor can’t undercut it.

The investment which promises the greatest profit gets chosen and then a randomly picked peep (with enough money to afford it) builds it in a random empty room. After that every currently functional building checks its expenses and projected profits again and adjusts its prices and wages accordingly.

To solve the chicken and egg problem (if there’s no food production a dispenser can’t be built, but if there are no dispensers, there is no demand for food, so no production facilities get built), I’ve set up an external maket which sells and buys food and protein for preset prices. If there isn’t enough supply of a resource, the required amout can be bought there, and the prices also function as minimal and maximal prices for good produced by peeps.

So what exactly happens is this:

First a food dispenser is built, since there are 100 peeps who want to eat. It sets the price of a meal to something, based on the expenses determined by the price of food in the docks and some random pre-set price for energy.

The second time around there’s an option to invest into either a second dispenser (it’s still profitable even if it sells only half as many meals) or into a food factory, which can buy protein from the docks, process it and sell it as food at a profit to the dispensors at a cheaper price than that in the docks. The foot factory nets a higher profit than a second dispenser, so that’s what’s built next.

Since the factory lowers the expenses of the dispenser, it start offering the meals for a lower price, which in turn lowers the minimum wage expected by the workers in the factory, furher reducing the price at which it can sell food etc.

More buildings get added this way and the game world ends up with a farm, a food factory, a power plant and 2-4 dispensers. Since the price adjustment cycles through all active businesses based on the room number they happen to occupy, the prices end up slightly different each time, and so sometimes it seems profitable to build more dispensers.

Of course, reality ends up being different from the projections and some of the dispensers may end up not being used at all - if there are two of them adjacent to the same corridor, one of them is never closer than the other one (unless the peep deciding happens to be there already - and there’s currently no reason why they would be), so unless there is a really long queue (which can only happen the first day when everyone gets hungry at the same time, since I’ve made it that buying a meal takes only a minute), nobody will ever visit it.

On the other hand, I was expecting the dispensers closer to workplaces to have more customers, but since a majority of peeps are unemployed and have literally nothing to do than eat and sleep in the closest corriodor, they stay where they are and always use the same dispenser, so the profits tend to be distributed relatively well.

The factory tends to produce slightly more food than is consumed, so it just stockpiles it. I should have it sell off the excess food at the dock, but for now it’s not necessary, as it’s still the most profitable venture.

Next up:

I’m going to give my peeps the dubious gift of hopes and dreams, plus the ability to make a simple weekly budget. I had to cut appartments and such from this build as it’s more iffy to determine the demand there, but I’ll make a system where peeps who could affford better food or sleep in a bed for a change can have an unhappy thought about that not being available and thus get an estimate of demand.


#11

I just read Artemis over a couple of days. Not only is it about a city on the Moon with ~2000 residents, which is pretty much what I’m trying to simulate here, but besides the everyday life there it at times delves into the economic and political aspects, which I’m thinking of a lot. It describes crime both petty and organized, as well as the minimal kind of law enforcement and mob justice that could be enough. It deals with monopolies, cartels and guilds.

While I won’t be aiming anywhere near the novel’s technical accuracy (think a more space-opera vibe will be better for my purposes), it has given me a lot of food for thought. Not to mention that the writing is excellent, I really enjoyed it.

The funny thing is, I got the book just by a coincidence. I didn’t even realize it’s required reading for me when working on this project.


#12

I haven’t got much time/willpower in the past few weeks to move forward with this project too much (still working on the peeps’ budgeting skills) so I decided to ramble about some long term ideas I have instead of sharing my progress - because apparently I do have enough time and willpower to ramble about that sort of thing.

The setting

I’ve got a pretty good idea about the game world, even though that’s something that’s not going to be very relevant for a looong time. Let me walk you through the way I got there:

The original idea

The basic inspiration for this project was the Nemesis system in the LOTR game Shadow of Mordor. You can read about it here in case you don’t know how it works.

The system is relatively simple and just works. It’s awesome. I was honestly expecting pretty much every game made since to rip it off and do something similar, but as far as I know it hasn’t really been copied. Curious.

Anyway, my first idea was to use a similar system and give the player the role of a police officer. Most of the game would revolve around the fact that you’d do your best to get criminal scum off the streets, only to watch them walk after paying off judges or simply doing their time, while the real bosses laugh to your face. The game would give you the option to either stick with this “hard way” or simply snap and start dispensing lethal justice as a vigilante. This was actually meant to be a board game. This simple premise evolved and mutated and eventually I ended up with something completely different (more focused on on player in the role of journalists and/or crime bosses trying to subvert or eliminate various politicians and businessmen). Eventually I decided that the board game has become so different that I might as well give the original idea another go. I found Defold and here I am.

Basic genre

While I haven’t completely resigned on the original police officer approach, it will only be one possible way of playing the game, as I’ve decided to make the whole thing much more open-ended. Which meant that if I want bad guys coming back for more after being defeated, they must have a way to do that even if the player decides to go on a kill frenzy (and I expect that playstyle to be rather popular). So that rules out most realistic settings. For me that meant three possibilities - fantasy, sci-fi or something like superhero comics (comic villains are notorious for their refusal to rest even in pieces). And since sci-fi has always been my thing, I’ve decided to go with that, though I plan to utilize many comic book tropes as well, since they seem to fit my idea rather neatly.

As for subgenre - well, I don’t want to spend all the energy that would be needed to create a hard sci-fi world, so I tend heavily towards space opera (the game Strange Adventures In Infinite Space being a prime example of what it should be like). Additionally, since I’m currently heavily invested into the cyberpunk genre (as I’ve mentioned elsewhere), that’s going to colour the game a lot too.

So the idea is to have a big, colourful and a little bit silly futuristic world with heavy use of body augmentation, surveilance and cutthroat everyday life, which will neatly support the gameplay mechanics I want: character development way beyond baseline human - if the player so choses, higher-ranking NPCs being physically much harder to destroy, plenty of justification for enemies to come back from the dead to haunt you - by ways of cloning, consciousness upload or good old-fashioned miraculous medicine.

So… space station

Given the way I’m doing things, I can hardly simulate a sprawling metropolis (which is where I imagine most of the denizens of my world live). One option was for the game to take place on a tiny colony, a frontier town. Think Firefly. As seductive as that sounds, that lends itself to a western, which is a genre I never explored much. You could say it’s for me an unknown frontier it itself. And even though it would be an interesting challenge, what I don’t want is to add even more challenge on top of the whole actually learning programming to be able to do this.

Besides, space station offers me claustrophobic space with tight corridors, service shafts, possibly entire subspaces for the homeless and undesirable to dwell in and more. While I tend to think of Startopia when thinking about the basic systems I’m working on now, my idea is something like Omega in Mass Effect or the underground city in Demolition Man.

The grander scheme of things

I love when certain gameplay considerations push me towards concrete lore decisions. I want different space stations appearing in the game to differ from one another, especially when it comes to the system of government. For now I’m focusing on anarchy, but I’d very much like autoritative regimes, capitalistic societies, hell, even something like a monarchy isn’t out of the question. The question is - why would someone build something massive like a space-station and then let some rabble run it the way they see fit? And to take it from a different side: I want crime, and I want peeps to be able to hit one another over the head and take whatever money they have in their pockets. Or ransack their homes and find whatever is stashed there. Would there still be physical money in the far future? It always bothered me that in games where all payments you do by wireless transfer (often explicitly called that) you find credits stashed in all manner of places (I’m looking at you, Deus Ex).

Both of those problems can be solved by means mankind has been solving its problems for ages: war. The way I see it, mankind, possibly united in a single empire/alliance/federation has been spreading across the galaxy, until something happened. And since natural disaster on a galactic level sounds far-fetched, it’s better to use war, being a decidedly unnatural disaster. I’ll let the question of whether the war was waged against an alien civilization or “enemy within” undecided for now, but we now know there’s still a much diminished old empire, whose power extends over a couple of core worlds, while the outer planets and space stations have descended into anarchy or declared independence. Pirates reign supreme. Political situation is volatile. Much has been destroyed and/or forgotten, a lot of technology is rare. So the society where the game takes place can be both highly advanced in some ways and rather barbaric and low-tech in others. Perfect for me.

Some more details and gameplay modes

I spent some time thinking about game modes I’d ideally like to have and how they should differ from one another. Obviously the basic one is going to be simply:

  • Sandbox. A randomly generated station, put the player in and go! Do what you want and have fun! This can be spruced up by additional optional rules and customizations, such as an enforced no kill rule, different starting conditions, hell, that police officer thing I was talking about would fit in here perfectly. This mode would probably have heavy rogue-like elements.

  • Challenge / puzzle mode. The existence of this mode fully depends on whether the finished game will be able to support it, which is far from certain, but I imagine it like this: Say I build a set up a game world which is going to be blown up after a month of game time by a madman. It wouldn’t be directly scripted, just overwhelmingly likely (and 100% sure if the player didn’t do anything). The madman in question could be a normal guy who hates his life, works a dead-end job, has no friends etc. Within the month, he’d get fired, robbed and come across a way to sabotage the station’s reactor. The player could solve this in a number of ways - he could find out who the madman ends up being (over multiple playthroughs) and then just go directly to him and put a bullet in his head pre-emptively. Or he could wait and prevent to sabotage. Or he could go on a killing spree and hopefully make enough changes that the butterfly effect breaks something and the sabotage doesn’t happen. Or he could find the guy, befriend him, help him turn his luck around and prevent him from being suicidal.

  • Story mode. This is a personal thing. I tend to think that no game is complete if it doesn’t have some sort of single player campaign, some story, something more than just gameplay, no matter how good it is. Plus I’m a storyteller at heart. Of course there has to be a story mode. It does, however, come with some problems that need solving. Since the game is meant to be very open-ended, it would feel wrong to constrain the player too much, but the story still has to make sense no matter if you’re a by-the-book good guy or a murdering psycho. I’m thinking that each stage should take place on a different space station, so that it woudn’t derail should you decide to make it uninhabitable before your departure. Leaving would then be your objective each time, though it doesn’t have to be a matter of buying a ticket or stowing aboard a trader (though I’d very much like these things to be an option some of the time). You could have an authoritarian regime that simply won’t let you, unless you gain favour with it, topple it or work with the resistance to flee covertly. Other time there could be a blockade by ships outside and nobody could leave until a specific problem was solved, say an outbreak of a zombie virus.

One more note on the story mode

One core gameplay mechanic is going to be the ability to reset the game back to the original state where the (random) events will happen the same way unless you interfere, basically making the game a Groundhog Day simulator. Hopefully that will also allow me to skip making a save/load system, which sounds like pain anyway. What I always liked was when gameplay elements like this were explained in-universe (the Prince of Persia trillogy being a great example). So what I’m thinking is: the player character gets affected by… something. An experiment. A weapon test going wrong. An alien influence. A trillion-in-one freak occurence. What it does is that should he ever die, he’ll return back in time to the start of the game, Edge of Tomorrow style. In case of the story mode that would be time of arrival on the current space station. That can be neatly explained by saying that whatever it is, it’s influenced by whatever kind of warp-travel is typical in my universe and thus resets every time he travels somewhere. The story can then revolve around someone or something trying to get this power for themselves.

So yeah. That’s pretty much where I stand right now in terms of “lore”. None of this matters. It’s going to be ages until it’s time to implement almost anything mentioned above, and things will change. They always do. But the way I see it - you have to have a plan; just so you have something to modify or outright abandon once you get a better idea.

Hopefully I’ll have some actual development news next time, though I do have many more topics to ramble about. We’ll have to wait and see which it is.


#13

Your idea is so great and huge, I wonder if it’s even possible to create such a world :smiley: So, I think you posted an accurate observation: when to end? In my opinion, game devs, especially independent, take care of their work like with an own child. They (/we) are artist, who want to create the opus magnum of their (/our) lives, not wanting to stop when there is at least one imperfection. There is a lot of thing you can add to your universe to make it more realistic and I hope you’ll decide to make it like this, because I think there could be a pleasure only watching those peoples living their lives. Because, I’m hoping you are planning to create a graphic representation for this, yeah? Anyway, awesome idea :wink:


#14

I wonder if it’s even possible to create such a world :smiley:

So do I, really. For now I’m taking it one step at a time, trying not to think too far ahead, since there’s no guarantee I’ll ever get far enough. The other day I was describing the game to a friend and he sensibly pointed out that my plans are rather complex, but the way I see it, I should be able to increase the complexity gradually, until I get something that’s good enough to add gameplay. I can always continue that process if I want, or focus elsewhere.

Graphic representation is somewhere on my to-do list, if far in the mists of future. Once I think it’s good enough to support it, I’ll shift my focus to creating gameplay. At first I’ll settle for a text-based interface (though hopefully neater than what Dwarf Fortress has!) and only after I’m sure that the game can be what I want it to be will I think of graphics. For starters I’m thinking of something inspired by DoomRL, but I’ll see when I get there. If I get there.

I will say, though, that even though I didn’t expect to get far when I started, the positivity of this board is slowly convincing me I might get there after all.

Edit: Damn you! By quoting you, I got the “First Emoji” badge I was hoping to avoid forever!


#15

After a little break I spent working on a different game (which shall remain unfinished for some time) I finally got back to this. I’ve more or less finished implementing housing for the peeps and they finally have a simple budget to inform their spending, though I simplified things a little bit by assigning discrete social classes to the peeps based on how many basic needs they can afford on their budget. Hopefully I’ll be able to replace this system with something more fluid.

It all needs a few small finishing touches, which means I’ve immediately lost interest and started working on something comepletely different - map generation. You can see the prototype here. Above is the old hard-coded layout I’ve been using until now. I’ve finally learnt to use tilemaps and even added some rudimentary graphics. Shocking. Now I have to make it play nice with the rest of the code, which mainly means rewriting the pathfinding system again. After that I’ll see if I can add some useful overlays to make it possible to view peeps in other ways than just the data dump I’ve been using so far.

The map generator works this way: After I specify the map bounds, it picks a random tile to place the first corridor and then loops to place additional corridor in a random tile which is adjacent to an existing corridor and a tile that is still inaccessible. When there are no more such tiles, the rest of the map is filled with rooms facing a random corridor and the corridors themselves are assigned tiles that connect correctly to the adjacent tiles. In some edge cases a corridor ends up adjacent to just one other corridor (other neighbouring tiles are rooms with doors facing elsewhere or out of bounds) so those get converted into a room or - very rarely - into an empty space.
You can notice that there are a few ugly clusters of corridors, but the results are good enough for my purposes.

Hopefully I’ll be able to show it off soon. In the meantime let this post be a resolute “I’m not dead yet”.