Author Topic: Combat Resolution Problem  (Read 1141 times)

Offline applesauce

  • Level 4
  • *
  • Posts: 10
  • Reputation: +0/-0
    • View Profile
Combat Resolution Problem
« on: January 09, 2009, 07:47:08 PM »
I am starting on a project that I need some help on. Please image this if you will.

2 players in a war game.  Player one attacks player 2 and invades their territory with the following units:  100 Soldiers, 50 Tanks, and 10 Planes.  Player two has the same, or a little less of the same units.

I am unsure how to simulate a realistic combat situation?  How does this pan out?

I have tried to give HP to each unit and an attack and a defense score but still fail to come to anything more than a random roll of the dice.

Who losses which units, and is there a formula to help in solving this type of conflict?

Offline Barrikor

  • Level 21
  • *
  • Posts: 248
  • Reputation: +3/-0
    • View Profile
Re: Combat Resolution Problem
« Reply #1 on: January 10, 2009, 02:05:22 AM »
Maybe give each type of unit straights weaknesses in different areas, Ex:

[Soldiers]
Ground Attack = 60% ; attack against other soldiers
Ground Defense = 50% ; defense from other soldiers
Artillery Attack = 0% ; Don't have cannons ?
Artillery Defense = 50% ; defense against tanks
Air Attack = 0% ; Can't attack by air
Air Defense = 75% ; defense against planes
;
;
;
[Tanks]
Ground Attack = 25%
Ground Defense = 60%
Artillery Attack = 65%
Artillery Defense = 50%
Air Attack = 0% ; Can't attack by air
Air Defense = 10%
;
;
;
[Planes]
Ground Attack = 0% ; doesn't attack by ground
Ground Defense = 99%
Artillery Attack = 0%
Artillery Defense = 20%
Air Attack = 75%
Air Defense = 20%
;
;
;



Also, you'd have to pick a % of damage an army can take before they retreat from battle, otherwise one side would always get wiped out...
Projects: Pith Framework (at 0.5), CactusGUI (at 0.3)

Offline applesauce

  • Level 4
  • *
  • Posts: 10
  • Reputation: +0/-0
    • View Profile
Re: Combat Resolution Problem
« Reply #2 on: January 10, 2009, 05:05:22 PM »
I see your point, but... "who attacks who?"

Say for example I have 100 soldiers, 50 tanks, and 10 planes in my military that I attack you with.  You have the same.

Now, if the game is to figure out how much damage my forces do...then does the game need to calculate damage from my soldiers against each of your units?

Do my 100 soldiers first attack your soldiers, then if I have any left they attack your tanks, then followed by my soldiers attacking on your planes?

Another thing I was thinking about today was this:

Say I have 100 soldiers with the following stats:  1 HP, 1 ATK, and 1 DEF.  You have 100 soldiers as well with the same stats how would the fight resolve and be fair?

1. Lets say I attack you for 100 damage, and because your units have one HP each , they all die and there is no counter-attack.  (not fair)

2. Lets say I attack for 100 damage, and you absorb all of it because of your 100 DEF, a counter attack does the same and no one dies.  (unrealistic)

3. Lets say the 100 damage I deal floats for a second... your units counter attack and your damage floats for a second, the the system inflicts damage on each player's units at the same time... which either results in no unit dying or all units dying.  (again unrealistic)

3a.  Lest say now have 101 units and attack for 101 damage, you absorb 100 damage from your 100 DEF score and one of your units dies leaving you with 99.  Your counter-attack does nothing as I have 101 DEF to your 99 ATK.  This turns into a one-sided battle resulting in the player who started the battle with less units ultimately losing.  (not fair)

I believe retreat would not be a realistic option either.  If I attack you in your territory to invade and take over, where do you retreat too?  Perhaps the attacking team could retreat back home, but the defending team would simply lose the battle and whatever territory they were defending.

Thanks in advance for any help provided.  I am hoping to find a reasonable solution to this problem.




Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Combat Resolution Problem
« Reply #3 on: January 10, 2009, 05:19:33 PM »
I don't really know what military losses are like in real life.

But I'd go for the 'fair' way instead - first of all, set a cap on the amount that anybody can lose in a battle. Say, 60% losses at most and the battle ends. You don't need to call it retreat if you don't want to, but there should probably be a reason why it ends :P

What I'd do is just kill off a certain percentage of the armies. A larger army will kill more. There are several ways to do this, and to get it right I think all you can do is try it out with simulated battles.

An example would be to take the difference in size or power of the two armies, and subtract that from the larger army's losses:

Army A starts with 100% troops - 120
Army B starts with 100% troops - 100

Army A is 20% larger than Army B, so the final result is this:

Army A ends with 60% troops (40% + 20% = 60%)
Army B ends with 40% troops (loser, battle is now over)

Quote
This turns into a one-sided battle resulting in the player who started the battle with less units ultimately losing.  (not fair)

I completely disagree with this :D Surely with a larger army you would expect to win. If I played a game and I had 100 soldiers, the enemy had 60 and then I lose against him, I wouldn't play it anymore :P

You could add a little randomness to make sure that battle losses are varied though.

You could also completely take out the idea of 'winner' and 'loser' or change them so they're not directly related to how many soldiers you and your enemy have left. After all, you can still be a winner even if you lose a large part of your army.

Offline applesauce

  • Level 4
  • *
  • Posts: 10
  • Reputation: +0/-0
    • View Profile
Re: Combat Resolution Problem
« Reply #4 on: January 10, 2009, 09:03:04 PM »
thanks again for your reply.

In your example of compare damage and end battle would result in a conflict of say one click.  Where as I am looking for a battle to last a while and include such things as tactics or some kind of military training to effect the results.

For example, if I attack your territory while you are offline and it is over in one click, you (as the defender) can not respond and could loose a great deal from it.  I am online for several hours a day and can play the whole time, attacking and kill other players, while you can only log on during lunch, but still want to remain competitive in the game.  So if I attack you with 100 troops and the battle ends with me having 60, and you having 40.  I just invade again and again until there is no more opposition and gain your territory.  You log on the next day to see that I have taken 3 territories with little chance to get them back.

This is one reason why I want the battle to last say... at least 8 hours.  I declare my attacks, and they resolve immediatly showing troop losses and the such but I really do not want the battle to end.  Then a few hours later when you get home from work, you log on to the game and see that you are now in a battle and can respond with some attacks or other actions, possibly even a treaty of peace or something.

Have you ever played the board game Risk?  Well in the late game, it takes several rolls of the dice to decide the winner of wars between players and both players take losses.  Some times the larger army does loose.

But I can see where you are coming from with a percentage being lost and seems like a general way to calculate battle damage.  But what if Army A is comprised of several different troop types?  So in a soldier versus soldier battle it would be simple to say 20% troop loss, but what about an army of just soldiers versus an army of soldiers and tanks?

I also was thinking of bringing some sort of skill factor into it as well.  Like 100 "regular Joes" fighting 10 elite troops where the elites would win each time.  If I compared numbers 10 to 100, you would think the larger number wins... but with a skill factor the lesser looses.

i am not sure how complicated a battle system I will end up, but I even thought about adding in weather effects, morale of troops, and terrain modifiers that effect the outcome.

But at the most basic idea, I want to see how to best tackle the 100 versus 100, then once I found something workable I could expand from there.  So I turned to the community.

 :D


Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Combat Resolution Problem
« Reply #5 on: January 11, 2009, 05:14:58 AM »
Ah, okay.

I think the easiest way is to use ticks, every 10 minutes. And every tick you update battle results.

I think you could still use the same method as I described above, except reduce the maximum damage each tick to small amounts so that the battle will last many ticks. To keep it simple, you can see it as 'each tick x number of troops from each side battle to the death, with at least one survivor'. I suppose you want larger armies to be in battle for a longer time, so x would have to be a small, absolute value, not a percentage.

Your idea is sounding very interesting! Big battles could last for days and you could probably code in some pretty cool ways to visualize and manage your army :)

As for having different unit types, I like Barrikor's suggestion of strengths/weaknesses, or attack/health.

Here's a way of calculating the losses:
Quote
3. Lets say the 100 damage I deal floats for a second... your units counter attack and your damage floats for a second, the the system inflicts damage on each player's units at the same time... which either results in no unit dying or all units dying.  (again unrealistic)

You could do it this way for regular battles. Since each tick you only take a tiny portion of units to battle, it doesn't matter if they all die. But if it bothers you, you could check after the battle results are calculated whether any units are still alive. If not, then pick a side at random, and keep a random unit alive. This also takes care of the problem of two soldiers attacking each other and killing each other. One will always be alive in the end. Or you could also perform this 'resurrection' code at random, so not all 1v1 battles (and other battles) will result in a winner. Occasionally they manage to kill each other :P

Then you could also add a feature of tactical advantages - in a battle, the damage might not float, instead one team with the advantage gets to attack first. You could take into account weather, terrain, player tactics, etc.

This might be useful for letting the player to attack with an 'ambush' option selected, in which they have a chance of successfully leading an ambush and having the first hit. But there's also a chance that the enemy finds out about it and they reverse the situation, dealing first hit to the player.

Well, I hope this gives you some stuff to think about :)

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Combat Resolution Problem
« Reply #6 on: January 11, 2009, 05:25:54 AM »
I think you should go other way. What is your designer goal?
- do you want a stable territory control game - make defenders have an advantage
- do you want to make an agressive risklike conquest game - make attackers have the advantage
- what about combat death rate? Will the army be wiped out completely after loss? What percentage of troops you want to player lose on average battle? Or maybe there will be no casualities at all?
- what is the game scale, strategic or tactic? In case of strategic scale equal forces battle outcome is just a dice roll, on a tactical scale you take into account players "order of battle".
It's really hard to say how it should work without knowing the rest of the game (economics, invasion reward/casualities ratio, ability to replace troops).

For starters just make one unit, infantry, the same quality for everyone. If this is strategic scale game it will be enough to make it playable, you can add more units later as a flavor.

If you are making tactical war game you need some orders, troops placement, etc. The army composition won't be enough.


Post something more about the game as a whole.

Offline Piny2u

  • Level 10
  • *
  • Posts: 56
  • Reputation: +1/-0
    • View Profile
Re: Combat Resolution Problem
« Reply #7 on: January 11, 2009, 06:43:39 AM »
Yeap... I agree Chris's idea. And u can add something more... u need to make a complex game if u want a realistic game.

-make territory advantages... (where your army is positioned and etc... )
-u need to make weak and stright conditions for army ... (soldiers are weak against something but stright against other thing ... tank against other thing and etc... i think u got the ideea)
-u can make different kind of attacks and defens... (like in warcraft .. if u played :) )
-make percents for attack and defens... if are attacked with 100 dmg .. your army have an amount of def... your defense absorb a percent of the dmg... or something like this  ;D
-make battle strategies .. and here u can put weak and stright conditions ..

If i will have other ideeas i will post here :) Good Luck man!  8)

Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: Combat Resolution Problem
« Reply #8 on: January 11, 2009, 07:44:16 AM »
You could read the art of war for some "battle tactics" ideas.

And maybe it will be an inspiration for other things as well, it's one of my favorite books :). The Dutch title for it is actually "Winning without battle", what, I think, is a better title for the book.

Offline applesauce

  • Level 4
  • *
  • Posts: 10
  • Reputation: +0/-0
    • View Profile
Re: Combat Resolution Problem
« Reply #9 on: January 11, 2009, 10:00:07 AM »
Thanks this is turning it to a real brainstorming discussion, please continue to post your ideas.  I am not trying to be difficult, I just want to make sure all my questions about combat are answered.

Quote
make defenders have an advantage

How, give them more defense?

Quote
Post something more about the game as a whole.

I suppose a general description would be a game of conquest, by starting with one territory and try to take over the others that are being run by other players.

Quote
In case of strategic scale equal forces battle outcome is just a dice roll, on a tactical scale you take into account players "order of battle".

I am looking for a little bit of tactical and strategic.  In the case of dice roll, I suppose would be simple.  you have a 100 soldiers, roll (1d20) and you loose that many units.  A percentage would be unfair to bigger armies.  20% of 1,000 is a lot more than 20% of 100.  The larger army owner would wonder why he was loosing so many units to a smaller army.  But what if the same group of 100 soldiers is attacking tanks?  Should they even be consider in the result.  This brings the "order of battle" into play.

Say I attack you, and within the game, I am consider the attacker and you are the defender. And the game gives a 20% defense score to your units because you are defending.

I invaded with the previously mention army of 100 soldier, 50 tanks, and 10 planes.  Your forces are similar.

What would be a good way to decide order?  here is an example I thought of:

My soldiers attack your soldiers (dice roll - losses)
Your soldiers attack mine. (dice roll - losses)

WAIT:  are my damages to your taken into effect  before your attack lowering your attacking force, or after you attack?  This seems important to know.  I the answer is "Yes" then the aggressor seems to have the advantage. -- attacking first always wins.  (I do not like auto-win scenarios)  No matter what, as a player I want to have a way to win, even if slim or hard, I want the chance.

Next in the order, do I now calculate my soldiers attacking another of your units, or does the game need to move on to the next of my units?  For example do my soldiers attack your tanks, or do my tanks attack your tanks?  What if I have tanks and you don't?  What if I don't have any soldiers and only tanks?

The question here is what would be a good "order of battle" for the above scenario?


Quote
u need to make a complex game if u want a realistic game.

I hope to make is complex, yet in its simplistic terms I need to know how to "add" before using "algebra".

Quote
It's really hard to say how it should work without knowing the rest of the game (economics, invasion reward/causalities ratio, ability to replace troops).

I have talked about this before with friends and it always seems to boil down to the same thing.  Regardless of the economics of the game, it does not matter how or why you at the point of war, I am just trying to figure out  when a player attacks another how does the combat resolve.  The ability to replace troops is always an option, but that adds complexity to it, for now I want to be able to resolve combat in simple terms.

Causalities ratio is another way of thinking about it?  I do not know this as it could be based on a few things. Order of battle is another thing I am unsure about the correct way to implement this?



 :)

Offline Scion

  • Level 27
  • **
  • Posts: 402
  • Reputation: +11/-0
    • View Profile
Re: Combat Resolution Problem
« Reply #10 on: January 12, 2009, 07:58:55 AM »
i would avoid the 'calculate one side then the other' approach....rather calculate the losses for both sides then apply them at the same time.

as for how you want battles to work, i would start off by writting down some rules for my game universe...

such as

infantry cannot destroy tanks, max damage they can inflict is 50%.
tanks cannot move if below 60% damage.
planes are impervious to infantry and tanks.
infantry do not receive movement penalties bassed on damage.

this helps set the framework for your game, and also provides you with a set of rules that you can check your battle engine against,

next i would build a test harness that allows you to run the same battle several times through your battle engine, structure your battle engine so that the actual engine can be swapped out for an alternative one, ie isolate the code that calculates the results from the rest of the code, then start with a simple attacker allways wins and slowly expand and refactor it runnig the tests each time
eventually you will reach a point where the results are good enough and the performance acceptable.



Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: Combat Resolution Problem
« Reply #11 on: January 12, 2009, 10:07:21 AM »
What Scion says looks like a good way to do it.

Offline Scion

  • Level 27
  • **
  • Posts: 402
  • Reputation: +11/-0
    • View Profile
Re: Combat Resolution Problem
« Reply #12 on: January 13, 2009, 01:42:50 PM »
thanks, btw i say i would do it that way....because thats exactly what i did when i was trying to develope an admitably simpler but balanced combat system...

It still took me a good 4 full re-writes (and many minor tweaks) of the engine before i had something that i was happy was balanced properly...

Offline applesauce

  • Level 4
  • *
  • Posts: 10
  • Reputation: +0/-0
    • View Profile
Re: Combat Resolution Problem
« Reply #13 on: January 13, 2009, 05:41:29 PM »
i would avoid the 'calculate one side then the other' approach....rather calculate the losses for both sides then apply them at the same time.

as for how you want battles to work, i would start off by writting down some rules for my game universe...

such as

infantry cannot destroy tanks, max damage they can inflict is 50%.
tanks cannot move if below 60% damage.
planes are impervious to infantry and tanks.
infantry do not receive movement penalties bassed on damage.

this helps set the framework for your game, and also provides you with a set of rules that you can check your battle engine against,

next i would build a test harness that allows you to run the same battle several times through your battle engine, structure your battle engine so that the actual engine can be swapped out for an alternative one, ie isolate the code that calculates the results from the rest of the code, then start with a simple attacker allways wins and slowly expand and refactor it runnig the tests each time
eventually you will reach a point where the results are good enough and the performance acceptable.





Wow, this does appear to be an acceptable approach to a new combat engine.  I started writing some rules down now and will write some code later tis week to test the theroy.  Thank you for your feedback.

 :D

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal