Code:
Problem description:
While creating some probability algorithms for the Diplomacy AI I got stuck in a simple math problem. And I don't even know why I keep getting stuck in these simple problems...
So I have 3 variables, PowerA, PowerB and Balance.
PowerA and Power B are positive numbers while Balance ranges from -1 to +1
I want +1 to mean that PowerA is double than PowerB and -1 to mean the opposite
ID:1840736
Apr 25 2015, 11:39 pm
|
|
I gather that perhaps victor is instead looking for something like:
var Unless of course, Victorqr, the fact that you said you're balance 'ranges' between -1 and 1 is important, as in it can do this in fractional increments/decrements? In that case i'd suppose your difficulty with the task would instead lie in how to correctly scale the value of balance to a relevant multiplication to be applied to either PowerA or PowerB depending on Balance's sign? |
Firstly thanks to all of you for your time, but GatewayRa got the solution right.
I thought I posted some examples in a 2nd post, might have been an internet connection. Sorry if I was not precise enough. That's a very good implementation GatewayRa never thought about min/max. Thanks again for your help :) |
In response to Victorqr
|
|
Ah, alright, cool.
I was thinking that some elaboration, perhaps in the form of a mock system showing the essence of what you were going for might have been helpful -which i guess you intended to provide within the phantom post, haha :D- but no worries all the same, happy to offer assistance. Btw, is the project this is being used in some kind of empire conquest type game? If so, that'd be sweet :o |
Anyway eventually I came up with another approach in that matter, it is based on that though.
Turboskill yeah we are creating an empire conquest game with some rpg elements, big armies, destructable environment, quests and other stuff. I hope we have it ready by summer... |
What I interpreted though was this.