Sign in to follow this  
Coopephobia

Comparing two sets of numbers

Recommended Posts

My issue involved comparing two sets of data: Set 1: Player 1's attack and defense Set 2: Player 2's attack and defense In a normal battle, the attacker's attack is compared to the defender's defense. If the attack was greater than the defense, the attack would win. In a head-on-head on battle, I am trying to figure out how to compare the two sets of numbers so that there is only one winner. I need to compare Player 1's attack against Player 2's defense. Then I need to compare Player 2's attack against Player 1's defense. Any ideas on how I should go about this?

Share this post


Link to post
Share on other sites
If you subtract a.attack from b.defense, you get a value that is proportional to how much stronger a is over b.

So you can simply compare these relative values.

You may want to make it more interesting though, by adding some randomness or multiple rounds where players damage each other. Simply comparing scores and having the highest win sounds a little dull.

Share this post


Link to post
Share on other sites
If it happens that both players have a higher attack than the opponents defence you could decide the winner on who has the greatest difference, i.e.,


Player 1 -- A = 10, D = 5
Player 2 -- A = 12, D = 1

The difference between P1's attack and P2's defence is 9
The difference between P2's attack and P1's defence is 7

So P1 would win in this case (this also leads to the possibility of a draw).

Is it possible to add another attribute such as speed?
If this is the case you could do one normal battle where the player with the highest speed attacks first, if that attack doesn't win the slower player has a turn to attack.

[EDIT]
ninja'd by rip-off :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this