Vigilante

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.

2 Likes

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.

1 Like

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.

1 Like

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.

3 Likes

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.

4 Likes

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.

6 Likes

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:

2 Likes

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!

4 Likes

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”.

4 Likes

To celebrate my progress I’ve decided to set a version number. Allow me to present…

Version -1.00
(I’ll be slowly making my way to version 0.00, which should have a basis for the intended gameplay)

What’s new:

  • A starting menu with a few options
  • Randomly generated map
    • There’s a button in the bottom-left corner that turn on an overlay showing peep density in the various rooms.
  • Remade list of peeps which is nicer to look at and conveys less information in a less practical manner!
    • You can scroll with the mousewheel. The scroll speed is kinda too slow. I made it so the peeps leaving the visible part of the list fade away and any reasonable scroll speed would make the effect impossible to see, sorry. I’ll add some buttons to skip by pages later.
    • Selecting a peep in the list will track their position and activity on the map.
  • Similar list for all buildings.
    • Buildings are no longer placed randomly. Food dispensers, for example, will prefer to be placed close to Sleeping pods (as peeps tend to be hungry after sleep) but away from other dispensers. This helps to keep the buildings bunched up together, though some seeds still end up with some weird placements.
    • The production information might be slightly off, but it should give you a general idea
    • If you raise the number of peeps (and thus the number of built buildings), some of the sleeping pods and dispensers will go bankrupt over time if they happen to be in the wrong location. C’est la vie. Handling buildings that consistently lose money is probably going to be my focus going forward.
  • Peeps now have a name and a face. While it seems like a superficial change, it pushed me from relying on just their internal ID too much. Plus anything to make them feel more alive is good.
    • Additionally they start with randomized hunger and fatigue. Money is randomized as well, but the range is currently set to 5000-5000 to make sure even unemployed peeps are able to participate in the economy for a while.

And that’s about it. There’s a lot of changes under the hood as well including a big overhaul of the data structure, utilization of different collections, re-rewrites of many functions and so on.

Next up:

  • Aside from handling unprofitable buildings and improving the UI somewhat (for example making the job list clickable the same way the peep list is), I’d like to add a log window that would display some things that are currently just dumped into the console - some less frequent “thoughts” of the peeps, notification that power output of the power plant(s) isn’t enough to cover the station’s needs, stuff like that.
  • Higher-tier dormitories and restaurants have been almost done for a while but I still haven’t found the time to actually put them in, so maybe next time.
  • With a bigger map it is now possible for a peep to be late for work, as the peeps always set their clock to 30 minutes before the work starts and getting from one tile to another takes (kinda unreasonable) 5 minutes, but it’s rare and I’ve yet to see one be late by more than 5 minutes. Rather than fixing their alarm clocks, I’ll see if I can add some consequences, since right now all that happens is that the building loses a tiny amount of its normal production.
  • If you generate a map with multiple sleeping pods, you’ll sometimes see a peep ping-pong between them as they find out the queue is too long and try the other one. I’m going to give them some memory of places they’ve been to for this case.
  • In the longer term I’d like to start working on giving peeps opinions on the various rooms as well as other peeps, so that if a particular room has a queue every time a peep tries to use it, they’d eventually start to dislike it and maybe prefer to go to another one, even though it’s a bit farther.
5 Likes

Hi @Klear
Where can we try your sim ?

The community page.

Seems like I haven’t posted any updates this year. That is in part because I haven’t got much time to work on this lately. Additionaly, as I wrote earlier:

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.

Yeah. The time to revisit that code has come and it wasn’t pretty, but I’ve finally managed to make it work. I hope. Namely - I now have a function that can take real demand for a service over the past two days including the price the peeps would be willing to pay for it and decide how many buildings of said types is it worth it to build, taking into account that some of them might prefer a better but more expensive option and set the prices accordingly. I still have to implement this for most building types, but it’s a start.

Oh, and I have some pie charts now, so that’s nice. I was going to write a bit about some things I will have to solve further down the road, but this will do for now.

3 Likes

Sigh. I wanted to post a new version showcasing a fully supply/demand driven economy, but the last-minute addition of restaurants (better quality alternative to food dispensers) makes the economy really volatile, so I’m going to have a add a couple of extra things I thought I could do without. Trying to fix crashing economy might be harder than fixing crashing code, but it’s kinda eye-opening.

  • The major thing I didn’t take into accout is where the costs of a business come from. The idea was that a restaurant meal would be more expensive, because the price to build a restaurant is much higher than a simple dispenser, staff needs to be paid and energy demands are higher. While all that is true, turns out the biggest item on the budget are the raw goods and that is the same for the dispenser and the restaurant. As it happens, with enough demand the minimal price (to cover expenses and see enough return on the investment) ends up being the same for both types of eateries after being rounded to a whole number and as soon as restaurants start offering better meals for the same price, demand for dispensers drops dramatically (they still sell some to peeps who get hungry at atypical hours when the restaurants are closed) and that leads to the dispenser meal price shooting up. And since all wages are calculated from the price of a dispenser meal (which should in theory be the cheapest sustenance available), everything starts getting more expensive, which means less and less peeps can afford food at all, further increasing the costs for the rest of them and the whole economy goes down the shitter. It’s equally frustrating and fascinating to watch.
    Now, the easiest fix would be to make sure the price of a dispenser meal can never be equal to or more than any other available meal, but I’m trying to create a libertanian nightmare here, so I’d prefer to avoid code that could be interpreted as government intervention, no matter how small. Right now business owners are setting their prices so that their initial investment returns in 30 days, so maybe lowering this number could help me. Other than that, I’ll fiddle with the preset values and hopefully come up with a solution.

  • Additionally, I’ve noticed there’s more than few notifications of peeps being unable to pay for something. Right now there’s no penalty, as available money is checked before most transactions, so this only happens when business owners need to buy resources for their factories etc. They should have enough money to cover these expenses, but with the market being as volatile as it is, there are occasinal shortages, which means the rest has to be bought from the dock for more money.
    I guess I’ll require business owners to keep a certain amount of cash on hand at all times. They can buy the penthouse suites once their business starts consistently making money.

  • Finally, a lot of the volatility of the market is caused by the fact that a lot of demand/supply (and therefore prices/wages) are calculated based on the amounts needed/sold the day before, which sends the prices up and down dramtiacally if anything happens and it takes a while to settle… and by that time the homeless and jobless peeps run out of food money so the economy shrinks and causes new upheavals.
    What I’m going to do is to track supply and demand over longer periods of time to make any changes more gradual. It might lead to longer shortages as the market will take a bit longer to adjust, but the tradeoff in having all prices more stable should be worth it.
    Second, I’ll automatically be giving some free money to every peep who wants to buy food but can’t afford it. This is a stop-gap measure until I implement begging and stealing later, but it will let me observe the economy for longer without it crashing. And finally, I’ll implement a system to make the peeps actually close businesses that are in the red. I was avoiding this, as I didn’t want them to close buildings that just happened to have a bad day due to some hiccup, but with the other improvements to the economy it should work well.

So that’s about where I am right now. Depending on how much time I have, I should be able to post version -0.90 later this week.

9 Likes

Version -0.90 is live! It’s not spectacular, but I’ve done some good work behind the scenes.

New stuff

  • Three tiers of housing: Hovel, Appartments and Penthouse.

    • The peeps will look for the best tier they can afford with their income for at least 30 days and they perfer houses close to their place of work, if they have one.
    • Rent was meant to be collected weekly, but I chickened out at the last minute so it’s paid every day for now. If a peep fails to pay it, they get evicted.
    • Rent is based on the budget of peeps who were looking for a home the day before (more on the log system later). So if there is one peep who would be willing to pay 30 and five peeps who could pay only 10, the price is set to 10, since 60 > 30.
  • Restaurants are a better quality alternative to Food Dispensers

    • They are more expensive to build and maintain, require to be staffed (which means they are only open for 8 hours a day) and have a limited capacity, but peeps will prefer them IF they can afford it.
    • Unlike production facilities where wage determined the amout of work done, here the employees are simply paid half of minimum wage. I was going to let them eat there for free as a perk, but forgot to implement it, so the waiting staff is seriously underpaid right now and there are no tips. Tough for them.
    • Working hours are determined by demand, unlike working hours of production facilities, which as as of now randomly to a random early hour.
      • The restaurant can’t change its opening hours once they are set, because the why, how and when of that is a bit too nebulous for me at this point.
    • The location where a restaurant is built also depends on where the most demand is (together with when). The same goes for Dispensers and Sleeping Pods.
  • Peeps now have the first vestiges of memory - when looking for a place to eat or sleep, they’ll remember places they already checked and decided that the queue is too long so they no longer ping-pong between two dispensers waiting for the queue to go away. They forget this whenever they go to sleep. (I’ll come up with a better memory disposal system later, but for now this works well enough).

  • Added a new graph screen (switch from map view in the top right corner). I’ll be adding more graphs as I think of interesting data to display there.

  • Workplaces which have working hours now have separate graphics for when they are closed. Except for the Power Plant (I was tired) it looks pretty good!

  • Workplaces can now go bankrupt, or rather, if a place has negative profit over the past 7 days and there was no profit yesterday, the building will get shut down. For now I let the buildings exists on the map so I could give the owners the option to reopen them if they think they will be able to make money again, but for now that’s not implemented, as the economic situation is unlikely to improve over time.

  • Added a log system with three uses:

    1. Reports on the state of the world (such as a new building being built)
    2. Reports used to guide some decisions (such as peeps wishing for a new service)
    3. Error messages
    • This replaces all the various “print” lines I used to track all kinds of stuff. Now I can easily switch specific reports on or off depending on what I want to see.
    • Early on the hungry and broke peeps kept reporting their lack of sustenance every damn minute of game time which obviously filled GBs of memory with junk, but now it’s working reasonably well. Of course, in the future I’ll come up with a system that would delete old useless logs.
    • There is a tiny display showing the latest five logs below the map. For now it only shows buildings being built or shut down. In the future it should be expandable and allow filtering and stuff like that, but this is all you’re getting for now.
      • The question mark next to it is supposed to take you to a help screen in the future, but since I hate designing UI, for now it only covers the screen with a nasty gray rectangle and… huh. Seems like that’s it. You can’t even get rid of it in any way. Yeah, you don’t want to click the question mark.

Background fixes and stuff

  • Buildings are split into four classes:

    1. “Dispensers” are automated places where a peep pays and gets food or a place to sleep
    2. “Housing” can be rented and the room then belongs to the renter until they can no longer pay or they move to a better place
    3. “Production” have employees and produce something based on their wages
    4. Employees of “Services” are paid a flat wage no matter the production. As long as they are staffed, they work the same as dispensers.
    • I rewrote the functions finding out demand, setting prices and determining if a building is worth the investment. Previously I tried to fit every building type into a single function, but it just ended up extremely convoluted and hard to read. Splitting them like this made the whole thing a lot more smooth and readable, and allows me to make adjustments much easier.
    • Demand is no longer estimated by guessing wildly (huh, there are 150 peeps? Better prepare 150 meals, economy be damned!) but by evaluating the demand from the previous day, in the case of housing including the purchase power of the peeps. It mostly works just fine, and when it doesn’t, it’s usually a problem with the economy rather than my programming.
    • Whichever building of a certain type has the most production gets to determine the price. That means that a dispenser that’s used by a hundred peeps sets the price accordingly and another one that only gets ten customers per day has to survive with that (or get shut down).
      • This is an interesting effect - a less popular place that is otherwise identical to a very popular one should, in theory, have higher prices to offset the lesser demand, as long as the higher price doesn’t drive all the customers away. I will be solving these cases way later, since for now there is a single universal price for each good and service.
  • I finally put all functions into local modules. Didn’t seem to have any impact, but it’s nice to know my code is a tiny bit more in line with what’s considered reasonable.

  • Magical free money for the homeless! That is to say, to make sure the economy doesn’t crash immediately after the jobless peeps run out of their starting money (which is presently set to 20 - 500 for most peeps, 1000 - 50000 for 20 lucky ones to make sure something actually gets built), once a peep gets hungry and can’t afford a dispenser meal, they gain 3x that much money out of nowhere so they can continue being good customers.

  • Made the loading bar a bit smoother

  • Scrolling the list of peeps is now a bit faster and thus more convenient. Still didn’t find the time to add buttons to skip by pages because I hate making UI.

Since the html5 version is starting to become unreasonably slow, here’s a bundled windows version:

Vigilante.zip (2.5 MB)

I’ve also noticed that in the html5 version no Hovels get built (their price remains inf) which is kinda strange and probably bears investigating. The way the numbers are set, the question whether Hovels will be profitable is on the knife’s edge, though, so it’s probably just because a different set of numbers are generated from the default seed. Changing the seed sometimes results in profitable Hovels (and sometimes locks the game up sometime during the first week… oops!

What’s next

There’s a couple of things I’m kinda looking forward to implementing:

  • Entertainment! The peeps do have a (hidden) boredom stat which only ever goes up. Time to give them something to do. Unlike fatigue and hunger which cause peeps to try to satisfy them once they reach a set threshold, I think boredom will have an upper limit and the value will determine just how much of their budget they want to blow on entertainment - meaning that rich peeps will be able to party until they drop while to poor ones will only seek entertainment once in a blue moon, or possibly never.
  • Liking and disliking stuff, namely other peeps and different rooms.
  • Begging and petty crime! There are still tons of unemployed homeless peeps. Let them annoy the rest of the peeps by begging and steal from dispensers if they get really desperate. I think that there won’t be any possible repercussions at this point, but it will lay some groundwork for security guards, law enforcement and repair services later.
  • More detailed information in the jobs display and implement sorting, by type at the very least. It’s getting quite crowded.
  • Speaking of crowded, the map gets filled up pretty fast and if you set the number of peeps much higher than the default 150 (or making the map smaller) will cause problems as there’s no more room to build. I’m going to come up with a completely new design for the map. This one was really only meant to help me this far. It’s high time to come up with something more compact and space-station-like.
  • You can notice that aside from housing (which is set to inf), there are some default prices. And yes - setting them to anything else does cause problems. I should probably fix that.
7 Likes

So I’m starting to implement entertainment and it got me thinking about the way I check needs overall, so I decided to put it all in writing here to make more sense of it.

Basic needs

Peeps have a “hunger”, “fatigue” and “boredom” stats which increase by one every minute (or rather, increase in bulk once the peep’s current action finished or if the simulation is stopped). Once they reach a pre-determined value (1000 right now), the action “hungry” or “tired” gets added to that peep’s action queue and once they get around to it, they will go an solve it.

Now that I think of it, adding these actions is a bit useless and it has been causing problems in the past, so I’ll change it to simply check the hunger/fatigue levels when peeps are deciding what to do, which will also allow these decisions to be more fluid.

Entertainment

Entertainment is different. If you can’t afford food, you’ll die (or get magical charity money if you live on my station), if you can’t afford a place to sleep, you can sleep on “the street”, but if you can’t afford entertainment, you life will suck but it’s not a matter of life and death, at least in the short term. Boredom just doesn’t quite work like that. I don’t think it can be reduced to some physical process that builds up and then lets itself known much like hunger or tiredness does. After all, people are quite capable of having fun all the time if they have the time and money. So instead of having a clearly defined threshold, I’ll let the boredom stat decide just how much of their budget are the peeps prepared to pay to have some fun (and then do it if there’s a venue which they can afford for that).

Budgeting

I can get a peep’s budget from a function which adds up all sources of a peep’s income, optionally subtracts housing and/or food expenses and adds the peep’s current money divided by the number of days he’s budgeting for (30 by default). All wages and other income and currently work on a per day basis (this is why I eventually decided not to implement weekly rent) so this gives me exactly how much money peeps have to spend in a day. Note - when peeps are looking for food and their daily budget is less than the price of dispenser meal, but they do have enough money, the result gets overridden so that they always buy food if they can.

There isn’t much the peeps can spend their money on so they are mostly programmed to go all in - they rent the most expensive housing they can and eat the best food with no regard for saving money for the future (that will come at a later time though). The biggest expenses are buildings being built, but that doesn’t concern anyone beyond those who already own a workplace or two and as such have enough income to realistically save enough money for investment. I don’t want them to blow all their money on entertainment and then get hungry and evicted. I mean, I kinda do, but not everyone and not every day.

So - what I’m going to do is have the “boredom” stat represent the willingness to pay for some entertainment. Time to create another neat curve. It should be low (but not zero) at 0 boredom, so let’s say 5%, rounded down. A peep whose daily budget is less than 20 won’t even consider paying anything for entertainment if he’s not bored at all. Someone richer with a budget of 200 would be willing to pay 10 for some thrills even though he probably just left such an establishment (otherwise his boredom would have been higher).

As boredom goes up, so does the acceptable price. Let’s make the nice round 1500 (which is 25 hours worth of boredom) the level at which the peeps is bored enough that he’d pay his whole daily budget for some entertainment - which sounds good to me. The poorer peeps will thus only spend the entertainment money when they are really bored, that is, close to once a day, depending on the prices.

The question remains - what if the boredom goes up even more? My first instinct is to let the peeps spend even greater percentage of daily budget, double, triple, if they’re really desperate (and the budget is very small), but I have a bad feeling that this is going to peeps being evicted for not paying rent regularly. At any rate, the increases in percentage spent is going to have to increase way slower than in the 0-1500 range. Just how many days, weeks, months without any entertainment would make you forgo food and a warm bed just so you could have a peek in a VR kiosk? I don’t know! But I happen to have just the simulation to answer these questions for me.

4 Likes

Regarding needs, did you consider applying some more math, and I mean here fuzzy logic for this? The Sims are designed basing on this and it works pretty cool and kind of realistic. Fuzzy logic allows you to implement complex and yet logical solutions to the queue of needs :wink:

3 Likes

Well I’m considering it now! Just read up on it and it looks kinda neat. For now the decisions the peeps face are few and simple enough, so I have a simple hierarchy to decide their next action. While stuff like going to work has an obvious precedence before anything else, a tired AND hungry peep will eat first and sleep after that (I think, it might be the other way around).

I knew I will have to set something up so they’d decide more intelligently and this looks like the perfect way to do it! Thanks!

As I’ll be rerwiting most of the code that has something to do with needs anyway, I might as well use this. I especially want to add a proper scheduling system - right now their alarm goes off 30 minutes before work and they (mostly) drop everything and go there, but I don’t want them to, say, pay for an hour in the VR Lounge only to leave after five minutes…

2 Likes

It made me think if I schedule my time basing on my needs in that way, because of the fact, that usually indeed I’m giving on everything and going to work :smiley: but wait, all the basic needs are fulfilled before so the queue is scheduled somehow by some logic :stuck_out_tongue: I think, in a field of fuzzy logic, the need to go to work should rise drastically just before the job starts, like in the Sims - when the car arrives, a Sim immediately adds ‘going to work’ to the queue :wink: your game is a very interesting point of view :smiley:

1 Like

Yeah. I tend to view my everyday life through the game’s logic now. It’s interesting (and potentially insanity inducing).

Going to work will have to have an utmost importance until I can figure out penalties for being late. Plus less work done might in theory lead to problems in the demand/supply chain as it is currently set up, though I haven’t noticed any detrimental effect just yet. Since I don’t want to deal with that, I’ll rather make sure they are all on time for now.

Redoing the map so that it doesn’t take forever to get anywhere will help too.

1 Like