[HELP] Percentage Formula

bane_

Howardianism High-Priest
Joined
Nov 27, 2013
Messages
1,559
It's 3:51am.
I'm failing at logic right now.

I'm trying to get the AI to be more aggressive with a certain approach when a difference of a number is bigger and less aggressive as this difference diminishes.
First I thought about percentage, but it was an hour ago, so I don't remember exactly how I did it. Right now I have this:

Code:
if iTotalInformation < 50 then
	iModifier = 2
elseif iTotalInformation > 50 then
	iModifier = 3
elseif iTotalInformation > 100 then
	iModifier = 3.5
elseif iTotalInformation > 150 then
	iModifier = 4
elseif iTotalInformation > 200 then
	iModifier = 4.5
elseif iTotalInformation > 250 then
	iModifier = 5
end
if (iTargetNumber - iTotalInformation) > iTotalInformation / iModifier then
	iNumSpies = 6
elseif (iTargetNumber - iTotalInformation) > iTotalInformation / iModifier then
	iNumSpies = 5
elseif (iTargetNumber - iTotalInformation) > iTotalInformation / iModifier then
	iNumSpies = 4
elseif (iTargetNumber - iTotalInformation) > iTotalInformation / iModifier then
	iNumSpies = 3
else
	iNumSpies = 2
end

It works okish, but I do really think it can be made better.

Ideas? :)
 
Back
Top Bottom