Advertisement

Military Simulation Game

Started by February 18, 2018 01:25 AM
10 comments, last by Katie 6 years, 8 months ago

Hi, I am trying to develop a military war simulation game. The game will be text based / web app and I am looking for help in the simulation logic development.

The language I would prefer is Java. My issue is simulating a situation and outputs based on various factors. For example, various factors determine the output in a war situation. Number of units on either side, technology level of units, etc. How do I put all factors and determine the winner? Any pointers would be helpful / source code, etc. 

I have a decent programming experience so even if you throw a sample in C, C++ , etc I should get my answer from there. Ask me any details if I missed anything. 

alokforu

You need to be more specific.  Right now your question amounts to "how do I write the game?".

Advertisement

Possibly. I am little new to gaming development world. 

But I am trying to find a solution to the simulation problem at hand. Side A (Has some units with specific strengths and specific weakness) and Side B (has some units with specific strengths and weakness). How do I simulate the war and determine the winner? Its more of a algorithm question I guess.

alokforu

7 hours ago, alokforu said:

Possibly. I am little new to gaming development world. 

But I am trying to find a solution to the simulation problem at hand. Side A (Has some units with specific strengths and specific weakness) and Side B (has some units with specific strengths and weakness). How do I simulate the war and determine the winner? Its more of a algorithm question I guess.

One solution is to have Side A always win.

If that isn't a good enough solution, then you need to implement some way of quantifying the strengths and weaknesses. A simple algorithm would then just tally up the various stats, and the side with the highest point tally wins. Maybe add some random scaling factor if you're feeling really fancy.

Or be more granular, assign strengths and weaknesses to groups. This would allow a group to be removed during simulation, and not affect other things once dealt with. But now there's suddenly more questions to answer -- how to decide which groups face each other? How to handle strengths and weaknesses if you simulate injury to a group? Do we care about groups gaining experience and becoming better at what they've done before? Is aging something which could realistically affect long-term group performance?

What about terrain, weather, sickness, moral and other external factors?

 

Basically, this isn't a programming question, this is a design question. The core question is "in scenario x, who whould win?", which we can't really answer for you.

 

Your best bet would be to create a rule set and apply it to various scenarioes. If the outcome of a scenario isn't what you'd want it to be, make changes to the rules and keep iterating.

There might be points where you go "this is my current rule set, but this given scenario doesn't play nice with it, regardless of what I do", at which point there might be some suggestions we could give. As it stand, you are asking us to design your rules for you, which is far too open-ended.

Hello to all my stalkers.

I can think of two different approaches:

 

Simple:

Make everything part of a formula, and run the formula, then apply the losses to each side accordingly.

 

Complex:

Make a simulation (with internal ticks and actual actions and order per units). Though you don't get to see any of it, you can run a complex simulation in but a few milliseconds which might result in more believable results.

 

Each approach comes with a very different mindset.

If you're struggling with the algorithmic part I can only suggest that you 'try something' and then fix it :)

3 hours ago, Lactose said:

One solution is to have Side A always win.

This is actually a great way to solve the math.

In short SideA - SideB so if the end answer is larger than 0, side A wins. Lower than 0 Side B winds and 0 = draw.

Doing it this way can reduce the need for IF statement by feeding the numerical result into functions.

 

I would recommend Rock,Paper, scissors to start with; except call it Soldiers, Calvary and Archers.

It's easier for me to draw than explain:

BattleStrength.jpg.ae8b1cd984c74cb611b3320463ac0d0e.jpg

BattleResolve.thumb.jpg.f09cd5626ff9e2c7c3fcf8df9cacf09c.jpg

The AI here can be summarized as this:

1.) The largest group with the most counter types attack.

So when Team A had 2 horses and 2 soldiers, the horses attacked because they had more targets.

2.) Game stops when there is no counter targets left for either team. This simulates a retreat when a small army is attacked by a larger one.

 

The system above gives advantage to first attackers, to counter this you can use this attack pattern. TeamA -> TeamB + TeamB ->Team A + Team A -> Team B + Team B.

In short the first attacker gets one attack, then for the rest of the battle everyone gets 2 attacks. This prevents the problem where team A could use it's horses before they died.

There is a million ways to make this system your own. You could even include formation calculations.

 

As you can see from everyone's responses, it's all math.

Rock, paper, scissors is a good place to start and allows for easy expansion.

Advertisement
12 hours ago, alokforu said:

Possibly. I am little new to gaming development world. 

But I am trying to find a solution to the simulation problem at hand. Side A (Has some units with specific strengths and specific weakness) and Side B (has some units with specific strengths and weakness). How do I simulate the war and determine the winner? Its more of a algorithm question I guess.

I would recommend looking into tabletop war-games as a starting point for ideas. Those rulesets are typically very detailed and have been used by many in the same situation to kickstart designs for rulesets. Games like Flames of War, Warhammer 40k, etc. are great starting points.

Thing is, how detailed are you getting with your simulation? You can get as detailed as you want or just build some sort of simple formula, as others have said. Tell us how complex you want to go, so that we can help you more.

No one expects the Spanish Inquisition!

4 hours ago, Lactose said:

Basically, this isn't a programming question, this is a design question.

Agreed. Moving to Game Design for now.

-- Tom Sloper -- sloperama.com

Got it. Thanks everyone. I started thinking too complex into AI libraries etc. Got a direction for now. Will keep posted with further problems.

alokforu

One simple way of simulating large battles between two armies can be:

You run ticks so each side alterates in killing units from the opponent side.

An attack:
Calc attack points from number and types of troops (spearmen get x2 points for each % of cav in opponent army for example).
Calc defense points (+30% if has castle, etc whatever)

This balance amounts to some "kill x points of defenders". Pick out poor guys to die.

Then reverse the process (defender now gets to hurt the attacker). Repeat until one army is dead or flees.

This topic is closed to new replies.

Advertisement