I made a strategy game. It was/is life changing

Page 1 of 1 [ 3 posts ] 

stratozyck
Deinonychus
Deinonychus

Joined: 28 Jun 2022
Age: 41
Gender: Male
Posts: 366
Location: US

01 Jul 2022, 8:53 pm

Here is a screenshot: https://imgur.com/3Yrlw84

I have been working on it since ~ May 2018. I don't really know when to say the start date was because I just kindof ran with it. I had just started a job that turned out to have awful managers and I needed an outlet.

I didn't draw the art, before I hired an artist about 18 mos into it this is what it looked like: https://imgur.com/tbnK3go

About one year ago I did a major redesign of the internals. It is no longer a game but more like a set of tools to create turn based strategy games. The first screenshot is actually the second game. The first one was more of a "experiment with improving the tools" game.

The turnaround time is a lot quicker and I am adding more ability to modify the base game. My goal at the start was to make decent enough quality "fast casual" strategy games for iOS. I wanted games that were easy to learn but had enough replayability via random maps and content creation ability.

In its current form, when the game starts up it reads in mod folders. You can choose which mod to play. The rules and gameplay of the two ones I have now are so different, but the tile graphics are shared so I guess its unfair to call them two separate games. Eventually, I will add the ability to change the tile graphics with mods and other aspects.

I am proud of the second one. The first one was kindof a "I just want to get it to work and be able to play a complete game without crashing" thing. But this one is fun and I would play it. It plays quick and is simple to learn, but because each map is randomly generated each game is different.

It is called "People's Conquest," and it is named that in homage to "Strategic Conquest," a 1980s game that I used to play. It has a few similarities beyond the cities with no name, and the three sides: Red, Black, and Green (neutral). In the original, you played as Black, but in this one you play as Red. The economy has more options and the units are more complex without requiring much headache. I don't like strategy games with lots of little tiny buttons and text so I made the options fewer with larger text.

There are also more tactical options. Infantry units can fortify and use artillery. Armor units move fast but don't see as far so that makes them vulnerable to ambush if you charge ahead without knowing what's there. The way tile movement works, tile move costs decrease with consecutive turns of visibility. What this does in effect is gives defenders more movement. This can be countered by using fighters to scout ahead, which gives you instant max consecutive turns (it resets if you don't do it again next turn).

Infantry units can also build airbases (it consumes the unit) and each additional infantry unit can increase the airbase level, adding more capabilities - higher levels can paratroop nearby infantry units and hold more fighters and bombers.

All units also have a position within a tile. This matters for defense. You set your defense to point a direction. So in a defensive line, your infantry units will be next to each other about 1 tiles apart (units can't move in-between enemies) and be fortified. Their artillery will hit any unit that comes in range and slow down their advance. Infantry units in defense mode also have increased anti air abilities, but armor units in defense mode have strong anti air capabilities.

So, optimal defensive setup is infantry facing forward, with armor a tile or two behind (air defense has a range of 2) in defensive position. Beware though - units facing one direction get severe combat penalties if attacked from the side or especially rear.

Optimal offensive strike is to use fighters to scout ahead and attack through a forest with armor with infantry following up. Forest gives great cover from air attacks and other attacks. Infantry can be set into "cover" mode which assists units in a small range that are attacked.

It is also possible to advance via infantry, but a lone infantry unit can be easily outflanked by a lone armor unit and will be vulnerable to air attack. Air units can be set to cover, and bombers can hit cities and reduce their economic and population stats.

The economy is entirely defined by three numbers - a city's population, its population growth next turn, and its productive capital. I use "kapital" in the game because I am an economist by training. The economy is defined by population and the kapital to labor ratio (K/L for short). If you are producing an infantry unit, it takes two turns. The unit that gets produced gets the sum of the population growth of those two turns and it gets a K/L ratio that is the same as the city.

Cities get a random allocation at the start of each, and there is an internal economy that allocates workers to nearby tiles to produce things in between turns. It handles it automatically but you can see it happening on the map.

Cities with high K/L and low labor growth will produce smaller, better quality units.

Cities with low K/L and high labor growth will produce larger, lower quality units.

Of course, there are cities with both high growth and high quality, and low growth and low quality.

A unit also has military skill. It gains military skill from combat. As it loses soldiers in combat, reinforcements can be produced in cities (instead of more units). A reinforced units maintains most of its combat skill it loses from loses. So, a reinforced unit is preferable, in general, to a new one.

If a city is producing reinforcements and there is no unit in range to reinforce, it gets increased population and increased kapital the next turn.

The goal is to defeat the AI, and the AI right now can win but is pretty stupid. I am going to spend some time improving it.

I spent a lot of time improving the AI development methodology and long story short, I ended up writing a scripting language to help facilitate AI creation. I can have separate AI decision trees per unit in text files and make changes without a recompile. That has enabled me to do a lot more than my original methodology, which was to write the AI in the source code.

My hope is to get it on iPad this year and iPhone after that. I think it would make a good mobile game, especially if I had multiplayer. Downside of turn based strategy game multiplayer on mobile is that contrary to what you might think initially, it uses more data than you'd think. The reason is to do multiplayer, you have to send the save file back and forth each turn. So a FPS game might send data fast, but it doesn't actually need that much data. Each save file is about 5MB and if you are on mobile data, doing each turn would be 5MB upload and download each turn. So 10 turns would be 100 MB. I can probably compress it and get it down to half, but its still going to eat up data.

Anyways, its been a life changing experience even if I make $0 from it. It definitely gave me a lot of confidence. The codebase is over 220k lines of C code. Its been a confirmation that I am weird as heck because its not something that normal people do.

It is also cool how it will outlive me and people will be able to interact with me in a way after I am gone. I like that part the most.



klanka
Veteran
Veteran

Joined: 31 Mar 2022
Age: 46
Gender: Male
Posts: 1,888
Location: Cardiff, Wales

02 Jul 2022, 10:38 am

well done for getting the AI going as I've found that is the hardest part...and balancing.



stratozyck
Deinonychus
Deinonychus

Joined: 28 Jun 2022
Age: 41
Gender: Male
Posts: 366
Location: US

03 Jul 2022, 7:06 am

klanka wrote:
well done for getting the AI going as I've found that is the hardest part...and balancing.


The trick is to read in decision trees in a text file. So you make a parser that reads a text file that can be pointed to in a field in the unit. This is what my AI text files look like:

https://imgur.com/s2zozlS

They are behavior trees. Each node is begun and ended with "BEGIN MOVEMENT" and ended with "END MOVEMENT" and priority determines its.. priority.

It reads them in and orders them so they don't need to be in order and new ones can be put in by using 1.5 to put something in between 1 and 2.

The problem with AI is that you need to be able to try a lot of different things easily, and it also helps if each unit can have a separate AI for different behavior. You don't want "one AI."

Also, a lot of people think its going to be some complex machine learning stuff. Its just decision/behavior trees. The people that do machine learning do statistical methods on data to build behavior trees, and the process of updating the trees automatically is called "machine learning."

The big mistake is to code AI in the same code you made the game. This makes you have less diversity and change less because every time you change the code, its a double pain - first you gotta make the change, then you got to debug it.

The other must do thing is to set a timeout for your AI. If you are reading in text files that contain the AI, it is much easier to make an AI that hangs up on decisions and takes a long time (if not loop forever looking for a decision). You just set a timeout and have a default decision. I just set the default to after 1 second, it moves randomly. People don't like to see an AI that sits there and even a random movement AI is better than one that does nothing.

My day job involves statistical modeling and I have worked on AI stuff in the financial industry. Its all just decision trees. There's no "well we used a bivariate double normal half logistical recursive method to analytically impute the vectors to better optimize the AI." That was a made up sentence but I am sure if you used it in a job interview, no one would know that was BS.