Randomization = Super Sausage Corp.

This week, wanting to mix things up, I decided to focus on some superficial random generation. Always fun! So I worked on a random name generator, that I will be using to generate company and product names for the competitors in Software Inc. and an employee generator, which basically means I colorize and combine faces/hair/jackets/pants in to one texture, so that each employee looks a little unique.

Employee generator

25Screen
So creepy…

The employee style generator, or creepy-on-the-fly generator,  is basically a quick shader I wrote for Unity (which can be downloaded here) which starts with a base color, which is the skin color, and then adds layers on top of the base color, each layer being colorized individually. Specifically, the layers I add are textures for the face, hair, jacket (or blouse or what have you) and pants, and each of them has an alpha channel, so that they don’t overwrite the previous layer. I then have a class which keeps track of all the textures for each group and assigns them randomly.

The texture class also has Gradients for the skin, hair, jacket and pants to determine which colors can be used to colorize the textures and, effectively, which colors are more likely, by how much space they take up in the gradient. Gradients in Unity are extremely cool and allow you to visually edit color gradients to use directly in your scripts, I really recommend that you try them out!

The generator is far from finished. If I get someone competent to model the employee, I hope to use BlendShapes to morph the model between skinny/obese and woman/man. Currently, there are only male looks, not because I’m being sexist, but female hair is just harder to model and texture.

Name generator

Names
Screw Coredumping, Super Sausage Corp. sounds way better!

My random name generator uses a tree like structure to generate random strings of words. A generator can be loaded from a file with a very simple structure, eg.

-start(base)
-base(base2,end,stop)
Hello
Hi
-base2(end,stop)
, you
-end(stop)
.

Will create a generator that can generate the strings:

Hello
Hi
Hello.
Hi.
Hello, you
Hi, you
Hello, you.
Hi, you.

It works by starting from the first node start (nodes are the ones with a hyphen in front of the name), it appends a random string from the list of strings below it (in this case there’s nothing to pick), it then picks a random node from the parenthesis of the current node (which can only be base in this case), and then it continues until it reaches the node stop.

I then have a generator for each type of software and for the companies. It’s a very simple algorithm, and as you can see in the picture above, the results can be pretty dumb, in a good way. The source can be downloaded here.

Fourth update – … I need an artist

24Screen
Showing off the bar chart. Note the work items in the upper right corner.

So for this update I reworked the GUI style so that it isn’t completely obvious this game was made with Unity, I’m not sure if it looks any better. I implemented a bar chart, I was really hoping there was a library for Unity similar to the System.Drawing.Graphics in .NET, so that I could draw the graph to a texture using all sorts of shapes and line styles and then draw that texture to screen. I ended up just using GUIStyles and the unity GUI system, I lose the ability to draw fancy lines and geometry and the chart has to be redrawn every frame.

22Screen
A simulated office with two teams. Testing out pathfinding, room designation and building complexity.

I refined the development cycle and added delays and bugs. I decided that marketing is a separate “work-item” on par with the design document, the alpha and such. Basically, to market a product you assign a team to do the marketing, as you would when developing a product. There are two types of marketing: Advertisements and press relations. With advertisements your product gains a lot of attention when the marketing is done and with the press, your product gains attention while the marketing is in progress. When you start a marketing work item you decide how long it will last for and how much money you want to spend.

Currently, you can only market products that are released, and products slowly loose the ability to generate income over time, so if you haven’t gained 100% attention at day one, you will be loosing a lot of money. So, I need to find a way to enable marketing for a product before it it has been released, because currently the marketing work items need instantiated products, but products only get instantiated when they are released and before that, they are work items. So, it looks like I might have to refactor some things.

21Screen
Employees staring at the screen waiting for me to model a keyboard…

Finally, I did a lot of work on the graphics-side of things, other than enabling shadows, which is apparently a thing in the free version of Unity now, I modelled, rigged and animated the employees.

The employees look horrible and I hope to find an artist to redo them at some point. My plan is to use blendshapes to have the model dynamically change between woman/man and skinny/obese and then having the texture for their clothes, hair and face randomly generated. Normally you would probably model the clothes and make blendshapes or bones for the facial features, but I want the game to be pretty simplistic graphically and I think textures will do. I would rather have less graphical fidelity with a timeless design than going all-out on graphics and having it look comparatively ugly in a couple of years.

20Screen
Awkward meeting. I used the editor tab for perspective projection, don’t know if this should be a thing in-game. I like the hallway in the background.

Third update – Starting to look like a (Unity) game

11Screen

So, for this week I got a lot of the UI done, which is obviously using the Unity GUI system. Unity Technologies recently announced a switch to a better GUI system in the upcoming release, so it’s going to suck pretty hard redoing the entire GUI when the time comes, but I’m sure it’ll be worth it.12Screen

I also finally implemented some of the development cycle. You can now choose what type of software you want to release, how much you want to focus on innovation, stability and usability, pick a team to design it, then promote it to alpha and release it when its done.

In the final version there will be delays at the end of the alpha, depending on how competent your employees are, a beta phase of fixing as many of the bugs as possible and after release you will have to take care of marketing and assign a team to support customers and fix bugs, or get a bad reputation. All of these steps will be affected by many factors, which includes how good your employees are and how well they are doing.

When you release a product, its quality, compared to similar items on the market, will have an effect on how well it sells. So, if you release a 3D modeling application  right as another company has released a much better one, yours will sell less, but you can use it on your next game without having to buy a license. I use a large amount of variables when calculating how much your product will sell each month and how much popularity it generates.

13Screen

Finally, I simulated winter. It seems like a good way to illustrate time passing, though the snow texture and particle effect could use a loving hand.

Behavior trees

03Screen
The initial behavior tree for employees. “Work” consists of staring at a screen until “GoHome”.

For Software Inc. I decided to learn a bit about implementing AI, so I read a couple of paragraphs, got impatient and started coding stuff, because I am not smart and, apparently, I like messing things up I could’ve otherwise avoided by just studying a bit.

Normally when I implement AI I end up with a 1000 lines of IF-THEN-ELSE and switch case statements. Behavior trees seemed like a cool alternative, so I went looking for implementations, because when it comes to programming, NEVER reinvent the wheel, so after seeing something to the tune of “200$”, I decided to reinvent the wheel… Poorly… And share it with you, of course, for free(Requires .NET 4.5, only works with C# files, simply select a cs file and the program will generate two new partial classes, one of which (class.impl.cs) contains the methods you need to fill in. It will not overwrite previous state methods when you export on top of it. BACKUP BEFORE USING).

So I made a small application in which I can visually draw states and connect them, and when I am done, I simply choose a C# file with my class in and it will generate all the method stubs and the code to generate the behavior tree, as seen in the picture below.

04Screen
Example of the code generated to construct the behavior tree seen earlier.
09Screen
How the behavior tree looks now. Notice “WantCoffee”, this game is going to be so stereotyped. I don’t even drink coffee…

Second update – First steps

06Screen
Testing how the buildings look with flat textured walls.

For this week of development I had a lot to implement to get to a point where I wasn’t just going to abandon the project. I expanded the AI of the employees (more on that later), I implemented stuff like hunger, energy and satisfaction. I also strayed from the blocky look by making the walls thin, which required making corner walls and dealing with all sorts of z-fighting issues, which eventually culminated in a convoluted algorithm that rebuilds all rooms on a floor when you change something, and merges all the walls, windows and doors in to one big mesh.

I also implemented meetings. I work as a student programmer and we have meetings once a week, and they’re always very interesting, I learn something new and I get motivated. I wanted to recreate that in Software Inc. by giving boosts for a team if they’re in a meeting, which requires a team leader setting them up, and tables and chairs to sit in.

07Screen
Here are some rooms, including a meeting room with a large table and chairs around it. Dat rent tho…
08Screen
Alonzo (Have to fix the name generation algorithm) having a meeting with his team… He is very satisfied, but hungry 🙁

It took me some time to decide how tables and chairs should be implemented. I ended up with a solution which determines which tables are touching and groups them together. Chairs can only be added to tables and will be added to the group the table belongs to and when a leader wants to use a table group, the room finds the largest available one. And finally I started modelling furniture, as seen below, I am NOT a 3D modeller.

10Screen
Very… Wood-colored… Furniture… And abstract shapes…

I also felt like I had to implement the ability to choose working hours  for each team individually so the game doesn’t get boring between 4 PM and 8 AM.

Pathfinding

05Screen
The red line illustrates paths between rooms and the green line is one specific path from the outside on the lower left to the room on the ground on the right, which has no doors, so you have to go through the corridor in the middle and take an elevator.

Software Inc., as you can imagine by looking at the pictures, is a grid based game. As such, it was really easy to decide on using a gridbased pathfinding algorithm. My problem was that I wanted multiple floors and if I just made a giant grid for each floor, if I then wanted to go from one building on the fifth floor to another building on the tenth, I would have to do a lot of testing to see which floor led where while also navigating each floor.

My solution was to implement a layered pathfinding algorithm, which probably seems completely obvious to you, but bear with me. Instead of measuring how far away something is geometrically when using a pathfinding algorithm we can use any definition of distance that we desire, we might say, “What is the distance between happiness and cake?”, as long as we can figure out some way to actually measure that distance we can find the shortest path from A to B (it is direct in this case).

What I did was to ask: “What is shortest amount of doors/elevators to traverse to get from room A to room B?”, notice the distance is not in meters or feet, but in number of doors and elevators between room A and room B. Then, for each room I want to traverse to get from A to B, I ask: “What is the shortest distance from door A to door B?”, which I work out by giving every room its own little grid for the pathfinding algorithm. In the end, I append all the paths found in to one big path and call it a day. To make people avoid rooms I simply ask, before going through a door: “Does this room belong to a team, and if so, is it my team?”.

Both of these algorithms are implemented using A*, which I think is pretty neat.

To finish off, I make a giant invisible room on the ground floor that connects all rooms to the outside, because logic.

First update – Software Inc.

01Screen
My first room.

After more than 12 years of developing games in my spare time, I finally managed to stick to one project for longer than a couple of weeks and I really think it’s looking promising.

The kicker for me in actually keeping my motivation, I think, was having a large detailed todo-list of everything that needs to be done in order to make the game playable. I’ve tried this before, but I usually slack a lot in keeping it updated. I’ve found that dedicating some time for cleaning the list and elaborating on points has helped keep up the motivation and I always have an idea of what to do if I get bored. I really can’t overstate how important this has been and if you’re into game development, I recommend that you try always having clearly defined tasks waiting to be completed.

I’ve been thinking about creating this game for quite a while now. I first started developing a school tycoon game, but realized all the action happened once a year when the it was grading time, the rest of the time was spent waiting. I then tried developing a 2D version of what I am making now, but I got stumped on some technical issues. Then I had a sudden burst of inspiration for a pathfinding algorithm and it motivated me to start again in 3D.

I was also hugely inspired by Game Dev Tycoon and I felt there were so many possibilities to go more in-depth with the software tycoon game idea. With Software Inc., my goal is to go more in-depth when it comes to the development cycle, the buildings and staff management. I want you to not just push out virtual products to gain some points in a game, but also feel like there’s an entire ecosystem just below the surface, that you have to manage.

02Screen
After playing around a bit I created a completely abstract uninhabitable building.

When these pictures were taken I had implemented rooms, doors, elevators and lamps to create buildings with. I also had an employee type person, who would turn up once a day to sit at a desk/box, to test the pathfinding algorithm.