I am making a android game, and it is supposed to have attacks.(Note, this game is 2D). I have implemented things like movement to the base, but I am not too sure about the actual attack algorithm. There are supposed to be to bases, one attacker and one defender. I have tried multiple ways, but I cannot get it realistic enough. Here is what has to be a part of it:
public void attackCalculations(){
Random r = new Random();
int[] aa = att.ARMIES;
int[] ab = def.ARMIES;
}
I thought about making random casualties based on who have more troops(attacker or defender), but it will not work(tested it, and the casualties were often 0, and it was a loss for the attacker...) There are ten troops(the ARMIES-variable is a array-int with a max of 10)
int ARMIES = new int[10];
So, how can I calculate who wins based on all the troops(cannot make a single integer due to different troops)?