A little assistance for CitySim

So much has happened on CitySim development, that I hardly know where to start with this post! I've not only found myself with some spare time to work on the game, but also the blessing of good progress. That good progress is not because of any skill on my part, but rather a clearer picture in my mind of how the game user interface should work, in particular with assistants.

I really wanted the game to help the user with advice on what to do next. Things like pointing out congested traffic, warnings for fires blazing across the countryside, notifications when there is a high demand for more residential areas, tips for keeping down pollution or bolstering education. I had originally thought of using popups, but this seems like a quick way to make the game annoying. If you recall, my theme for the game is "relaxing". The last thing I want is a popup every 10 seconds telling you to do something.

And yet, there needs to be some way that the game tells you what is happening. I think I found a good, balanced way to do that through two useful tools: statistics, and assistants.

The first thing I worked on was city statistics. Much like you would find in other city simulation games, you need some sort of chart or graph that you can look at to know how things are going, and that give you context clues of what to do. Now the game features a hidden stats bar at the top of the screen, which when revealed will show you various bar graphs which will aid you in city development.

 

Rather than have labels, I went with icon symbols that I think are universally understood. A badge for police/crime, a tree for pollution/fresh air, a fire for fire departments, etc. These work well because text labels can take up a lot of space, and the icons don't need translation when used in other languages. Granted, without some sort of explanation, it may take a few tries of the game to figure out each bar graph in relation to high or low being good or bad, but as it stands, it is rather useful if you want it. If you don't, well, you can just hide it with the graph button, and never worry about it again!

Second, I developed the assistants. The original author had already made a sort of notification bar at the top of the screen which if enabled (it was disabled in his repo) would tell you some piece of information. I changed it graphically, making it transparent, and expanded it to include an icon of each assistant, such as the mayor, the fireman, the doctor, etc., and their title as well as a text block of what they want you to know. Just like the statistics, this information bar can be hidden away by tapping on it.

If you do use the assistants, they don't seem to be a nuisance, as they don't popup, flash, move, or make any noise. They certainly are not AI, either. Essentially, part of the logic used for the statistics and upgrade/populate calculations is also used to drive the assistants, pulling up the appropriate person when any metric is met, giving a canned response. For example, the in game logic prevents commercial zones and industrial zones from upgrading past a certain level unless your education score is high enough and that score is based on population and school numbers. When the game builds the statistic bars it also detects that score being too low to upgrade your zones, and it will trigger the appropriate assistant to tell you that you should build more schools. Thus the assistants notification bar changes to the teacher.png icon, and the title and text of that bar change accordingly.

By default, if you have no other call for assistants to tell you something, then the assistants bar will display Margaret, the administrative assistant, who tells you things like: "I'll keep you posted when anything changes by keeping you in touch with the right people." Or ""Hello Mayor! I am your new administrative assistant. Let's build a city!"

There were lots of other small updates as well, as I strive to refine the game a bit, but this was the big change since my last post. Don't forget that you can check out all these commits on Gitlab, too! [1]

Linux - keep it simple.

[1] https://gitlab.com/alaskalinuxuser/citysim-ubuntutouch

Phones ubuntu touch citysim

Setting fire to CitySim

You may recall from my last post, that I boasted about how simple it would be to implement some sort of fire hazard system, where random buildings would burn down, if you didn't have enough fire departments to protect your town. I believe my exact words were:

face a random blaze every now and again, requiring you to rebuild buildings as they burn down. This doesn't seem hard to implement, so I may give it a try and see how I like it.
A bold statement for a wanna be programmer whose C++ skills are lacking, and who knows little to no JavaScript! I did not realize that I would burn five or six hours on this tiny little bit of code alone! What I thought would be simple turned into a huge learning curve that despite eventually getting the results I wanted, didn't lead me to learning the proper way to do it.

Right off the cuff, I wrote a few simple lines of code in under 10 minutes, fired up the game with $ clickable desktop (a type of emulator, you might say, just running the click on your own desktop with a lot of environment variables and things set, as if it was on your phone). I built a little town, and sat back to watch it burn down. And it did. Actually, the code I wrote worked right off the bat, or so I thought.

What actually happened was that it did randomly pick a tile and set it ablaze, leaving the hot, smoldering ashes tile behind it. I thought I'd mastered that, and would have committed my code right then and there, but I thought I should diligently test it a bit more, just to be sure it works properly, and I'm glad I did. Because it didn't. At all.

The first major failure was that what I wrote switched which tool you had selected to now be a "blaze" tool, causing everything the player clicked/tapped on to set on fire. E.g., a flaming version of Midas' touch. Well, that wasn't what I wanted to happen at all. So I fixed it. But now it only worked if you had a tool selected, and didn't work if you did not have a tool selected. So I fixed that. But then it caused "mapBlock" errors, messing up which block was which in the game. So I fixed that, only to have it appear to work, but when you clicked on the smoldered ash tile left behind, the game would lock up. And let me tell you, if you saved the game, while there was an ash tile, you can forget ever loading that saved game back up again!

Needless to say, it took me about six hours to fix my original code. So much changed that I actually started over several times during the process. But, praise God, I eventually got it. In the end, what became the final result actually worked out even better than I had originally planned, because now I could use the new code for other hazards!

Originally, I was just working on a little code for a fire hazard tile. After rewriting it several times, I realized that I could move the bulk of the code into it's own function which I could then call for other hazards, not just fires. Things like a volcano, or a flood. Maybe king kong, or some other disaster like a tornado! While it was my errors that took me out of my way, I'm glad they did, because now the code is much better for implementing other disasters and hazards.

Essentially, I took the "block" code, which is used to make a building when you click on a tool and then on a square of the map, and added a "hazzard" number.

Yes, I know that is misspelled. And yes, when I read it, I also think of Bo and Luke Duke and the rest of the gang. But it was actually convenient to misspell it for searching purposes, so I could jump right to the variable, ignoring any other use of the word hazard. Anyways... back on topic.

This "hazzard" number, when 0, would allow the original block code for point and click/tap to build whatever tool you had selected. However, if the number was above 0, it would be a special hazard. In this case, hazzard 1 is a plain old fire, known as a "blaze". It is also handy, because once I implement meteors, volcano, and other hazards, I can reuse "blaze" for the surrounding areas, since they would be on fire after those events as well.

Either way, I'm glad the code is now properly implemented and fixed, and that I can use it for other fun things!

Don't forget that you can check out the fire hazard commits on Gitlab. [1]

Linux - keep it simple.

[1] https://gitlab.com/alaskalinuxuser/citysim-ubuntutouch

Phones ubuntu touch citysim

Getting CitySim basics ironed out

One thing I've learned from this project is that building a game is not easy. Not just the programming part, which is hard for me, due to my limited skillset, but also the part about planning a game. Figuring out how everything should work is actually a lot of work! At the same time, it is also quite a bit of fun. If you are wondering what I'm even talking about, well, I'm talking about CitySim [1], my fork to build a city simulation (think "Sim City") style game for Ubuntu Touch. It's coming along, and I'm now ready to work on the game part of the game itself. To get to this point, though, I had to 'iron out' some of the rough edges and get all the tiles and pieces ready. Sort of like physically making all the pieces for the chess board, before you can work on how the pieces move.

Some of those basic pieces I built were adding in the entertainment tile, which for now is a baseball stadium. It is expensive to build, but it actually makes you some money and dramatically increases the entertainment value of your city (other entertainment increasers would be things like the park tile). Another fun one is the space rocket launch pad. It is extreamly expensive to build and maintain, but I hope to use it in the game play mode, where the final mission will be putting your city's mark on the moon! Not to mention that it will really help your city stats in other ways.

Previously, I mentioned that I had added pollution to the game. Well, I've also added, crime, health, entertainment, and education to the mix. Now, before a residential area can upgrade past level 2, it requires a certain ammount of entertainment, a low enough crime rate, and the overall availability of doctors and medical care. Likewise, industrial and commercial zones are limited from upgrading past level 2 unless the education level of the workers is high enough, plus a crime rate low enough to support investment, a certain ammount of people to fill the jobs, and so on and so forth. While I may still need to tweak the levels and ammounts, the overall game mechanics are all in place now. Population, income, all of these things are in place.

Other basic features are also now working, such as the ability to save the game, and the ability to load that saved game next time you play. While I didn't have to fix the feature itself, it didn't work before due to some of the saved tiles returning null values that caused issues. That is all fixed. The ability to save and load the game is a huge milestone, as now the game can actually be played whenever you want, being able to whip out your phone at the bus stop, play a few minutes, save the game and come back to it later, instead of having to play the whole game in one sitting, which is not practical.

As I also mentioned before, there are "assistants" which are still a work in progress at the moment, but the idea is that they can "pop up" to tell you when there is a problem. What I am still working out is how often they can pop up. I could have them pop up every time there is a problem. For example, if you can't upgrade a residential zone because you have too much crime, the pollice officer could pop up and tell you the crime rate is too high, reminding you to build more police stations. However, I would need some sort of timer function to prevent six residential zones, all built at the same time, from all trying to upgrade at the same moment, creating six police officer popups. Another option would be to have a certain time of year, where the officer would pop up and make a report. Every month is 30 seconds, so having him pop up once a month seems like too much. You would see a pop up from him twice a minute. Likewise, if you made it once a year, you would get a report from him every six minutes.

A report every six minutes doesn't sound bad, but then again, there is the fire chief, doctor, conservationalist, etc., that all need to make reports. It would end up being a different report, from a different person/division of the game, every 30 seconds, which is a lot of popups. So I either need a non-invasive pop up, or an even more limiting way to keep the reports at bay. I'm still working that out. For now, I have 'tabled' that portion of the game and will focus on it later, as I don't feel it impedes the game development in any way.

Another thing I am still figuring out is the fire department. Currently, the 'crime rate' keeps buildings from upgrading. But I didn't do that with the 'fire hazard rate'. I could just add that in as part of the game, but I was wondering about a possible alternative. One idea I had was that if your fire hazard rate was too high, random buildings would catch fire, burning down, and then you would need to rebuild them. Obviously, if you keep your fire hazard rate low enough, there will not be any fires, so if you don't want to lose buildings, money, potential population, you would just build more fire departments. But if you like living on the edge, you could not build fire departments and face a random blaze every now and again, requiring you to rebuild buildings as they burn down. This doesn't seem hard to implement, so I may give it a try and see how I like it.

Asside from those, the last big hurdle before building all of the game objectives/selection screen is that of the city status page. I really want it to look beautiful, so I am working hard on that. Essentially, when you click on the graph image at the bottom of the screen, you should get a graphical update on all the variables, like crime rate, pollution, fire hazzard, etc., so you know what you need to do for your city. One thought I had was integrating the assistants into this. Perhaps when you click on one, the assistant could pop up to tell you something you should do, but it seems a bit redundant, if you understand the graphs, so we will have to see.

Either way, most of the 'grunt work' is already done, so I'm feeling pretty positive about this project!

Linux - keep it simple.

[1] https://gitlab.com/alaskalinuxuser/citysim-ubuntutouch

Phones Ubuntu Touch CitySim

CitySim Zone Mechanics

While I have very few programming skills, one of the hardest parts of working on this game is not the actual work of programming, but of figuring out the numbers needed for the game mechanics, in order to have a smooth and fun game. Granted, I am struggling a bit with the syntax of the javascript portions of the programming, once I have a general idea of what I want to do, it seems fairly straight forward to implement. So far, it has mostly been if/else statements.

For instance, I already know that I want to keep things very simple. In general, growth is based on population, and population is based on the number of residential zones that are populated, and then based on the level of those residential zones. But I need some game mechanics to keep the player from just building 1000 residential zones that will automatically progress through the levels and max out their population. Otherwise, it would not be a 'game'. So, I have to add something to keep that from happening.

Thus, I'm building in a bunch of dependencies. For instance, I implemented pollution. If pollution is too high, then the residential zones will not level up. The player can physically build all of the residential zones they want, but when they do, those zones can't progress past level 1, which only adds a max population count of 75. Even if they built a thousand of them, as long as pollution is too high, they only gain 7,500 people, and their income would be severely capped. This forces the player to consider building parks and other pollution reducing buildings/tiles.

Implementing pollution was relatively easy, even with my limited programming knowledge. The harder part has been playing the game over and over again to figure out what pollution limits are appropriate.

Likewise, I hope to implement several other things to cap residential zones from leveling up, such as a crime rate, health, and entertainment. In other words, who would move to a city that has a high crime rate, or that had no entertaining things to do there. By setting these caps for leveling up, my hope is that it will affect all stages of the game equally, as each level up will have to check these stats, and as the residential zones level up, and the population increases, it will require more support buildings, such as hospitals, entertainment venues, and police stations to keep up.

Commercial and industrial zones are a little bit simpler, but will follow a similar path. Currently, their level is capped by the amount of populated residential areas, but I plan to add education as a factor as well. E.g., right now, an industrial zone can't level up unless there is a suitable amount of residential zones (population) to support it. But in future work, I hope to also add education as a cap, meaning that you need higher education, for more skilled labor, to support higher levels of these zones, which will ultimately gain the player more money.

One thing I am debating currently is the ability for other buildings, like police stations, to 'level up' or not. If they did level up, would it be enough to keep up with the leveling up of the population? I'm not sure. I want to keep from having to build six police stations in one neighborhood to keep crime down if there are sky-rise residential areas. At the same time, if police stations do level up, I don't want the player to get board because they built one and are now done having to build them ever again.

Other dependencies, such as power and fire departments will work in a different way. Rather than capping the ability to level up, they will impede the user in other ways, but that is the subject of a different post. Don't forget that you can check out the latest commits on Gitlab. [1]

Linux - keep it simple.

[1] https://gitlab.com/alaskalinuxuser/citysim-ubuntutouch

Phones ubuntu touch citysim

Turning CitySim into a game

I'm really ecited about the potential that CitySim[1] has, now that I've taken it on for a project to turn it into a game. Last post I talked about what makes a game, and that is goals. City simulation games can be rather unique, in that you can really continue to play indefinately. If you want, there really doesn't have to be an "end goal" in sight. And yet, if you just build a city with no goals, it can seem pointless. Like two sides of a coin, it can come down to a coin toss on preference.

So, I've decided to take on both sides of the coin. I plan to do that with scenarios and badges.

When you choose to start a new game, you will have the choice of choosing a scenario or free play. If you choose free play, you will be able to build any city you want with any personal goals in mind. Free play will have a few options, such as if natural disasters can happen or not, and you can earn badges for various milestones of your city. Badges will include reaching a certain income, population, education, etc., though there are a few that you can only obtain through completing the scenarios. Essentially, in free play mode, your city can go on forever, with no particular end goal, earning various badges. Scenarios, on the other hand, will have specific goals for you to obtain, and will end the scenario once you have obtained that goal.

While I am still figuring out all of the scenarios, I have a few solid things in mind. For one, if you run out of money for a certain period of time, you will go bankrupt, and the scenario will end. In trying to keep with the overarching feel I want for the game (a relaxing time killer), there will be no time limit to complete these scenarios. E.g., get a population before x number of years, etc. It is my plan to make 9 scenarios, with the first three being 100k, 500k, and 1m people in your population, sort of as a prep for future scenarios. I have a fun idea in mind for the final scenario, which is to build a special building, a launchpad for a space ship, and send an astronaut to space! Not sure of all the intricate details just yet, but overall it will be a very expensive building to maintain, which means you will need a robust income while it prepares for launch.

In the grand scheme of things, the overarching feel that I want for the game is relaxing. In keeping with that, I have decided not to do things like taxes, where you are constantly adjusting things to keep everything in balance. Instead, each structure has a set income/expense based on it's level, and levels go up with time and dependencies. By dependencies, I mean that some things, like industrial and commercial zones will require that there are enough people to support the jobs, so it will go up. Likewise, if pollution, crime, traffic, etc. are too high, residential areas will not level up. You will not have to manually respond to a fire by sending the fire trucks. You simply have to build fire departments, and they will take care of fires. If there is crime, you don't have to click on criminals or direct squad cars, instead, you will just build a police department which will respond to criminal activity on it's own. Overall, the interface design is mobile friendly and simplified.

I have added "assistants" to the game, which will pop up to tell you things you need to know. A fire cheif will pop up and tell you that you don't have enough fire departments. A police officer will report to you the current crime rate. A secretary from the utility company will let you know if there is a lack of power or water. All of these "assistants" will help you know what to focus on in the game, but hopefully will not be too intrusive, as I plan to limit their ability to give you input.

Now that I have a pretty good idea of the direction I want to take the game, I've started adding things like icons and people, as well as things needed for badges. I already added a pollution variable to the different zones, and I fixed the yellow "highlighter" affect that covered all the roads, as well as fixed a few issues with leveling up and the display of the proper image for the buildings at different levels.

All that to say, I'm having fun!

Linux - keep it simple.

[1] https://gitlab.com/alaskalinuxuser/citysim-ubuntutouch

Phones Ubuntu Touch CitySim

Rebuilding a city simulator for Ubuntu Touch

Months ago, when I was updating old Ubuntu Touch applications built for Xenial to Focal and then Noble, I ran across a real gem: Citysim [1]. Similar to "Sim City" in design and concept, it is, of course, a game in which you build cities. The game itself launches and has some beautiful low-polly artwork, and while it is "playable", it really isn't yet a "game". When it was built, it was considered a demo rather than a finished project, and was built by the author while they learned to code.

I spoke with the original author, and they do not intend to finish the project, and said I was more than welcome to fork it and finish making the game. Back when we had this conversation, I was buried up to my neck in projects as I was working through the process of attempted app updates on over 200 apps. Now that things have slowed down a bit, I would like to continue work on this game.

More like a foundation than a game, the original author created a visually stunning framework for creating the city simulator, all in QML, with logic coded in javascript with a little c++. The main interface is complete for desktop or touch screen and is very intuitive. The side bar scrolls up and down, allowing you to choose buildings from the list to create by clicking on squares on the board or map. Visually, I feel like all of the hard work is done. But, that's where it ends. Currently, it has no "point" or "goal". You can't "win" or "lose". The population doesn't increase or decrease, though your money, UBcoins, does go up and down.

The main question is then, what makes a city simulator a game? I think the answer is goals. Goals I can think of would be:

Population size
Income level
Production level
Pollution control
Crime control
Fire control
Disaster recovery
With these goals in mind, I was wondering what I wanted game play to feel like. E.g., when you are playing the game, do you want finite control over everything? Do you want to be busy all the time? Constantly scrolling around and putting out fires, clicking on dollar signs and setting up block parties? I decided on none of these.

I would like the game play to feel relaxing. I want this to be a time killer where you are on the bus and have 15 minutes, so you jump into your city simulator and chill. Build a few roads, throw in a farm or two, and sit back and enjoy the show. I want the city to take care of itself. Roads will not just "collapse". If there is a fire, the fire department puts it out. You don't have to dispatch police officers to a crime scene. A real mayor deals in city planning and budgets, not micromanaging hospital staff.

And that's how I plan to build the game. If you want to join me on the journey, you can follow along on Gitlab. [2]

Linux - keep it simple.

[1] https://github.com/zubozrout/citysim-ubuntutouch [2] https://gitlab.com/alaskalinuxuser/citysim-ubuntutouch

Phones ubuntu touch citysim