PDA

View Full Version : How do I Make % Chance Sumtin wil happen



JoRdAnMaN
February 17th, 2006, 11:04 AM
How do i make it like say, if a mc is at a certain frame that there will be like a 50% that the enemy will react in a certain way. Im trying to do sum ai, thx

expensive_pen
February 17th, 2006, 11:13 AM
off the top of my head


if(Math.round(Math.Random())){
//do something
}

hopefully that will work

GPP
February 17th, 2006, 11:58 AM
Why dont you do real AI? Its called RANDOM AI. Here read this:

http://www.kirupa.com/forum/showthread.php?p=126054

SuperBokey
February 17th, 2006, 01:59 PM
try something like this:

if(mc._currentframe == /*insert frame you wanted*/ && (random(99)+1 > 50) {
//insert the Ai stuff
}

Lord Rahl
February 18th, 2006, 01:38 AM
Let say you want a choice of three things. So here is what you would do.


number=Math.ceil(Math.random()*3);
if(number==1){
//something}
if(number==2){
//something
}
if(number==3){
//something
}

Jeff Wheeler
February 18th, 2006, 02:02 AM
Why dont you do real AI? Its called RANDOM AI. Here read this:

http://www.kirupa.com/forum/showthread.php?p=126054

Um, by definition, intelligence is "the capacity to acquire and apply knowledge." Perhaps you could explain to me the application or acquisition of knowledge within a random-based artificial intelligence mechanism?

Yeah; that's not AI. ;)

NiñoScript
February 20th, 2006, 12:02 AM
haha :lol:

nathan99
February 20th, 2006, 12:11 AM
Um, by definition, intelligence is "the capacity to acquire and apply knowledge." Perhaps you could explain to me the application or acquisition of knowledge within a random-based artificial intelligence mechanism?

Yeah; that's not AI. ;)

uh nokrev.. there' s such thing as random AI:huh:

freeskier89
February 20th, 2006, 12:58 AM
I am leaning towards nokrev's side on this one. Although it has been coined "Random AI", it isn't really AI. As nokrev said, intelligence involves learning, and most of the "AI" in Marz's tutorials does not involve learning. Marz is by far not the only one saying it is AI though. In my opinion, swarm intelligence and reinforcement learning are examples of AI.

Don't get me wrong, I think Marz's tutorials are very in depth and are a great resource. :D

Pasquale
February 20th, 2006, 02:07 AM
well you can have kinda random AI- ie AI error or somethign with random events- but essentially random AI doesnt exist- it woudl be a branch off it- like a function- where trial and error allows it to retrieve knowledge.Though most times you can do this in a linear fashion- sometimes i guess ya need to do random tests.

Yeah nokky and freeskier are right- :P random AI doesn't really exist i guess.. :P

ANY WAY back to topic :)

Jeff Wheeler
February 20th, 2006, 11:19 PM
Yeah… sorry… that just has been annoying me for a very long time… and I eventually had to say it. :P

freeskier89
February 20th, 2006, 11:24 PM
Yeah… sorry… that just has been annoying me for a very long time… and I eventually had to say it. :P Me too! :)

Pasquale
February 21st, 2006, 01:54 AM
HAHAHAH :p im such an AS noob :)