Creating Weighted Logic/Actions
Hey. Been playing around with GS quite a bit, having other "maker" experience. I've been experimenting quite a bit and enjoying it so far.
I want to build a simple 'weighted' logic system. Basically, I need to have an enemy pick between three commands at the start of a turn. all values are generated from tables.
So I'm starting with a random variable between 1 and 100.
randomvar less than 60 (60%) of the time, he should go with command1
randomvar less than 90 (30%) of the time, he should go with command2
randomvar less than 100 (10%) of the time, he should go with command3
If its less than or equal to 60 (first command), go with command1. Else, If its less than or equal to 90 (second command) go with command2. else, If its less than or equal to 100, go with command3.
This sort of feels like a sloppy way to do this, but I've never done weighted logic before. I feel like im overcomplicating something simple, or overlooking it entirely. Does anyone have any ideas? Or is this the right track to be on?
I want to build a simple 'weighted' logic system. Basically, I need to have an enemy pick between three commands at the start of a turn. all values are generated from tables.
So I'm starting with a random variable between 1 and 100.
randomvar less than 60 (60%) of the time, he should go with command1
randomvar less than 90 (30%) of the time, he should go with command2
randomvar less than 100 (10%) of the time, he should go with command3
If its less than or equal to 60 (first command), go with command1. Else, If its less than or equal to 90 (second command) go with command2. else, If its less than or equal to 100, go with command3.
This sort of feels like a sloppy way to do this, but I've never done weighted logic before. I feel like im overcomplicating something simple, or overlooking it entirely. Does anyone have any ideas? Or is this the right track to be on?
Best Answer
-
gyroscope I am here.Posts: 6,598
@adamhwilk
Hi Adam, without more details I'm not certain what you mean by the term "weighted logic" but still, never mind, what you want to achieve doesn't seem overcomplicating it all; in fact you have to add a little bit more - as far as I can judge from your short description - to make your Rules work properly.
Basically, the way you've got it now: if you make randomvar < 100 then go with command3, this is 99% of the time; similarly with the 90 : you've made it 89% of the time, not 30% as you want.
So, here's the additions to make it work as you want:
When randomvar < 61, go with command1 ---60%
When randomvar > 60 and < 91, go with command2 ----30%
When randomvar >90 and < 101, go with command3 ----10%
Hope that helps out.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers
Not sure if you could do it any more efficiently than what you already have