Well, this also involves the divison by 0 thread. Or actually, the decision there lead to this.
Sure I am going to test the 3 different dice this afternoon. (Finally some time)
But that is just 1 type vs 1 type.
The AI is very simple in that simulation.
Highest health takes the fire.
That's right, the rule is: The defender decides who takes the fire. As long as there is sufficient cover for the other units to hide.
Since taking into account how much cover is needed. I have temporarily discarded this.
1v1 is very easy now.
But what if I have more then 1 type in my army?
Now the problems start. I did work on a concept. But somehow it isn't what I am looking for, because sometimes it didn't work properly.
***
If I have more then 1 type of units in my army. Certain stats have influence on player behavior. And so should the AI behave.
For example, other units always hide behind walls. Until enough walls are broken down.
I am sure that every one agrees; that walls always take fire first. Simply to do the facts that they are cheap and can't supply the army with fire power.
***
The 4 statistics that count are:
- costs; cheaper units takes hits first. But if they are of use, we try to keep them alive when they are damaged.
- health; more health takes hits first. Obviously, this changes during the game. And has to be calculated every time.
- armor; depending on this number, some units have better durability. The health number will be totally different when facing different opponents.
- damage; a combination of a number of shots, multiplied by a weapon type.
2 calculated statistics that I am sure of that matters:
- The total damage that the entire army can do. Against each armor type that matters at the moment.
- The individual damage that each unit can do. Against each armor type that matters at the moment. Especially now, the "that matters" part matters. Since during a game, a certain type might die completely. And that total damage is gone. It could mean that when certain opponents die, the damage becomes low enough, that this unit will now better serve as meat.
An extreme example would be an anti air unit. When all air dies. This unit is just fodder.
Maybe to expensive to be using as meat at first, but still just meat now.
1 extra logical rule that I discovered after my first attempts:
"Meatier" units might have higher chances of dying than other more expensive units or units that supply with more damage.
In that case, the other units take fire first.
***
The goal of the AI is: to survive as long as possible and keep the total damages intact as long as possible.
How would you handle this?
You both have supplied me with new thinking ways. Allow me to reply to each.
A close heuristic algorithm is simply damage divided by (HP+armor), lower units get killed earlier. Walls have 0 value, so are killed first. (HP+armor) should be adjusted depending on your rules, to be (HP*armor, HP + 1.5*armor, HP + 2*armor^0.5, etc.)
Hah!
I was somewhere with durability divided by damage. Turning the way around is indeed more correct. So obvious. Thanks.
How I apply H and A is a bit weird in my game. But bottom line would mean that for each unit needs to be checked what kind of A is working.
In that regard, the factor I use for durability has a part H/A intergrated. Where it is called H/D by that time. D can be lower then A, but never higher. That is the funny math trick that I use to get RPS working with just numbers.
A better but more complicated algorithm is to have whoever take damage if they are sure of surviving. (ie, meat shields) In the case of "every unit can possibly die from the next attack", calculate the chance of a unit dying multiplied by its attack. Lowest value takes the hit.
This makes sense too. I was already pondering about this one. It requires a sub simulation in how much damage is done. However, that is a no problem issue once it is applied.
Excellent suggestions.
***
I'll look into it. However, range is not an issue in the simulation right now. I might add it later on. But then it is simply doing damage until both parties are able to fight.
Excel is only used for calculations. The next step would be simulation, where randomness and a number of replays are added. In that case, I sure can't finish with Excel.
I once programmed a real-time strategy game with resource-gathering and a simple AI as a hobby project. I was surprised how effective even a crude AI using simple heuristics could be.If I wasn't careful and the map wasn't too complex it could sometimes beat me. The techniques which I usd are probably not relevant to you,(I can look up what I did if you're interested) but the point is that many people start off by trying to apply very crude tactics which they sometimes self-sabotage due to laziness or overconfidence, or panic, so even a crude AI which is not susceptible to these can be superior (at least until the human player learns and starts properly using the leetle grey cells). So an AI doesn't have to be highly sophisticated to pose a reasonable challenge to human players.
That is so cool that you made a RTS. Do you have something left for me to see? Because I am interested. Originally, the A=D mechanic that I thought of was meant for a RTS.
Well, I got some experience in programming AI with triggers for my UMS in Starcraft. I too got beaten when I was a bit to slow. In that case. A job well done. Unless you tried your very hard and lost miserably.
I asume you forced the AI to scout first?
Did you steer the production of the AI with what he had scouted? I did, the scout discovered for example my tanks. And he started production of anti tank material to a certain point. And sended this to attack where it scouted.
I could abuse this of course. (placing the right units, right there where the AI scouted) But others where astonished in the smartness of the AI.
One final point: you mentioned AA defences as being useless once the opposing aircraft are gone. Actually, in real life, they were often very useful against ground units too (like the '88s the germans used to kill allied tanks in WWII, or the soviet 23mm AA cannons that were used on american infantry in Vietnam). Even modern SAMS are often adapted for use against small surface warships. Perhaps you could allow AA to be used against effectively land units with a lot of damage but with an accuracy penalty, if your game mechanics allow that.
Edit: Hmmm - I think Andymakespasta's advice is more to-the-point than my long ramble - go with what he said.
Yeah, in the video gaming world. AA means Anti Air only. I discovered that board gamers actually know that AA has secondary effects against ground. Which is logical.
A tank with a simple could also shoot an aircraft if it is low enough to the ground.
My game allows weapons to hit both air and ground. And I have 2 types of these. Those which can shoot both air and ground at the same time. And those who have to choose what to shoot in 1 action. The latter has a +33% penalty cost. The first one has 100% penalty cost.