YesNoOk
avatar

Coding for AI to implement two (or more) moves randomly and interchangeably. (Read 11477 times)

Started by Redben, June 01, 2021, 10:54:11 pm
Share this topic:
Coding for AI to implement two (or more) moves randomly and interchangeably.
#1  June 01, 2021, 10:54:11 pm
  • avatar
  • **
    • Morocco
If I want the AI to apply for example move number 1200 and move number 200 interchangeably, what should I put in the "value" in the changestate of the two moves?

I'm pretty much looking for smth like this:

value = 1300+(Random%2=1)*50  <--- this is for move 1300 and 1350. I need smth similar but for moves that are further apart from each other and for them to be used randomly and interchandeably.
Last Edit: June 02, 2021, 09:30:30 am by Redben
Re: Coding for AI to implement two (or more) moves randomly and interchangeably.
#2  June 02, 2021, 12:21:28 am
  • ****
    • crepa.neocities.org

  • Online
So, either 1200 or 200 with each one being 50% chance, right?

value = ifelse(random<500, 200, 1200)
Re: Coding for AI to implement two (or more) moves randomly and interchangeably.
#3  June 02, 2021, 09:30:23 am
  • avatar
  • **
    • Morocco
So, either 1200 or 200 with each one being 50% chance, right?

value = ifelse(random<500, 200, 1200)


Thanks a lot. So if I want to add 1100 with the same chance as the other two it would be like this:

value = ifelse(random<500, 200, 1200,1100)

 or should it be smth like this:

 value = ifelse(random<333, 200, 1200,1100) ?
Re: Coding for AI to implement two (or more) moves randomly and interchangeably.
#4  June 02, 2021, 03:52:08 pm
  • ****
    • crepa.neocities.org

  • Online
These won't work because "ifelse" can only read 2 possibilities, but you can add one ifelse inside another:

value = ifelse(random<333, 200, ifelse(random<500, 1100, 1200))

one more example using 4 values (adding 1300):
value = ifelse(random<250, 200, ifelse(random<333, 1100, ifelse(random<500, 1200, 1300)))

"ifelse" works like this: if the first condition is true, do this, if not then do something else.
For "random", they will generate a number from 0 to 999, and each random is unique, even if you have 2 random in the same trigger, they will return different numbers.

Hope it helps! ^^
Re: Coding for AI to implement two (or more) moves randomly and interchangeably.
#5  June 05, 2021, 05:14:05 am
  • avatar
  • **
    • Vietnam
So, either 1200 or 200 with each one being 50% chance, right?

value = ifelse(random<500, 200, 1200)

thats the good one and also you can write it down without ifelse like this.

value = 200+1000*(random%2)
------Tremble Mortal and Despair. Doom has come to this world------
Re: Coding for AI to implement two (or more) moves randomly and interchangeably.
#6  June 05, 2021, 05:17:09 am
  • avatar
  • **
    • Vietnam
So, either 1200 or 200 with each one being 50% chance, right?

value = ifelse(random<500, 200, 1200)


Thanks a lot. So if I want to add 1100 with the same chance as the other two it would be like this:

value = ifelse(random<500, 200, 1200,1100)

 or should it be smth like this:

 value = ifelse(random<333, 200, 1200,1100) ?

you can't take two values in the same posibility. you can use varrandom to judge which state are you gonna go, the easiest way.
------Tremble Mortal and Despair. Doom has come to this world------