Author Topic: Randomness doesn't work here.  (Read 3870 times)

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Randomness doesn't work here.
« on: September 16, 2014, 04:12:26 PM »
There should only be a 1 chance out of 3 for this bot to start shooting when energy becomes lower than body, but that is completely ignored and the bot will always shoot.

Code: [Select]
'If 50 is not 3; shoot!
cond
 *.nrg *.body <
 50 3 !=
start
 -6 .shoot store
stop

'Reset 50 to 0 when .nrg becomes more than .body.
cond
 *.nrg *.body >
start
 0 50 store
 100 .strbody store
stop

'Set 50 to a random number between 1 and 3 when .nrg and .body are equal.
cond
 *.nrg *.body =
start
 3 rnd 50 store
stop
The internet is corrupt and controlled by criminally minded people.

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Randomness doesn't work here.
« Reply #1 on: September 16, 2014, 04:19:04 PM »
You forgot the * on the 50

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Randomness doesn't work here.
« Reply #2 on: September 16, 2014, 04:20:07 PM »
Oops

In the shoot gene

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Randomness doesn't work here.
« Reply #3 on: September 16, 2014, 04:46:32 PM »
OK, that improved it a little but the randomness is only generated when the sim starts, after that the shooting bots will ignore the instruction and always shoot.

So with free variables you always type it like this?

cond
 *random 3 =
start
stop

Not like this?

cond
 *.random 3 =
start
stop
« Last Edit: September 16, 2014, 04:51:01 PM by Testlund »
The internet is corrupt and controlled by criminally minded people.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Randomness doesn't work here.
« Reply #4 on: September 16, 2014, 05:06:08 PM »
Ok, I see exacty what is going on... sorry for the confusion...

If it is a number it is just "50" if not it is always starts with a period as in:

Quote
def pizza 50
.pizza or *.pizza

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Randomness doesn't work here.
« Reply #5 on: September 16, 2014, 05:11:09 PM »
OK. Well, the randomness is only run when the sim starts. After that the bots will be stuck with there choices. I was thinking there should be a way to re-run whenever the bots get "hungry".
The internet is corrupt and controlled by criminally minded people.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Randomness doesn't work here.
« Reply #6 on: September 16, 2014, 05:13:59 PM »
Code: [Select]
'If 50 is not 3; shoot!
cond
 *.nrg *.body <
 50 * 3 !=
start
 -6 .shoot store
stop

'Reset 50 to 0 when .nrg becomes more than .body.
cond
 *.nrg *.body >
start
 0 50 store
 100 .strbody store
stop

'Set 50 to a random number between 1 and 3 when .nrg and .body are equal.
cond
 *.nrg *.body =
start
 3 rnd 50 store
stop

or

Quote
'If 50 is not 3; shoot!
cond
 *.nrg *.body <
 *50 3 !=
start
 -6 .shoot store
stop

'Reset 50 to 0 when .nrg becomes more than .body.
cond
 *.nrg *.body >
start
 0 50 store
 100 .strbody store
stop

'Set 50 to a random number between 1 and 3 when .nrg and .body are equal.
cond
 *.nrg *.body =
start
 3 rnd 50 store
stop

The confusion is between a physical address or a defined operator, they both mean the same thing.

.nrg
is comrehanded by the compiler as some orbitrary number as well as the number itself say 50.

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Randomness doesn't work here.
« Reply #7 on: September 16, 2014, 05:18:19 PM »
Well the way you say it you want a 1/3 chance but you post 2/3 chance

Try 3 50 store as your reset (2/3)

Try *50 3 = as time to shoot (1/3)

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Re: Randomness doesn't work here.
« Reply #8 on: September 16, 2014, 05:34:58 PM »
Yeah, I thought backwards there.  :P I get a little better result now, at least when the sim starts.
The internet is corrupt and controlled by criminally minded people.