The Daily Click ::. Forums ::. Klik Coding Help ::. Random
 

Post Reply  Post Oekaki 
 

Posted By Message

anthracite



Registered
  01/06/2003
Points
  3
3rd June, 2003 at 07:16:34 -

I can generate a random number with a counter, but what does the value mean (e.g.: random( 56 ))???
And where what is the best method of creating AI (like animals or something)?

 
moo

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
3rd June, 2003 at 07:42:43 -

I take it you mean 'what does the 56 mean in random(56)'?

It means that the random number will be between 0 and 56. Random(2 would give a number between 0 and 28. See?

--

Animal AI, now there's a question. Basically, sit down and think about what kind of animal it is. Try and imagine someone on a nature show telling you about it. Eg: 'This creature resides in the tall rushes, waiting for its pray to walk obvliviously by...'. Think how it reacts to sound, if it attacks you blindly, etc. Is it a pack animal? If so, is it a hunter, like a wolf, or a runner, like a Prairiedog?

Then, when you've got ideas like that, you need to work on the coding. Let's say we're making a monster that hides in the shadows and pounces when you walk into its way. Simple enough.

Make active objects in every dark section of the room. Then, make a circle follow the monster - this will be his line of vision. When a dark area is in his vision, and he is not standing in a dark patch already, then he should move towards the new dark part. He should not, however, move if another monster is already in that shadow.

See? You have to think about the monster itself a lot more than the coding.

Random() doesn't need to be used that much for them. The best thing about a game is when you get to understand how a monster 'thinks'. This will give the player more fun, because he will be able to predict, once he becomes a pro, where every monster will be, and how to kill it.

 
191 / 9999 * 7 + 191 * 7

Arf :: FPP Games



Registered
  15/05/2002
Points
  1364
3rd June, 2003 at 10:12:16 -

Random(X) + Y

X is the number of possible values, Y is the lowest possible value. So random(56) would return numbers from 0-55 inclusive.

 
n/a

Arf :: FPP Games



Registered
  15/05/2002
Points
  1364
3rd June, 2003 at 10:14:38 -

Damn smilies! Instead of X) it should be X )

 
n/a

anthracite



Registered
  01/06/2003
Points
  3
3rd June, 2003 at 11:01:31 -

But how can I make also random numbers that are lower than 0?
random( -56 ) doesn't work...


 
moo

anthracite



Registered
  01/06/2003
Points
  3
3rd June, 2003 at 11:25:01 -

@dines
Thanks for that. That really helped me. Right now I’m just trying to collect ideas for a game. I thought of a piece of landscape that lives on its own (for example: a jungle: there are trees, small plants and animals need trees because of the shadow and stuff, bigger animals eat them, etc, etc). The problem is: If e.g. a shadow fox eats a mouse, the mice have to reproduce themselves to keep the mice colony alive, but there mustn’t be 500 mice and one fox that isn’t able to eat that much. I guess, I need a counter, eh? And everything mustn’t be too artificial, I think, so… you know what I’m saying? For me, as a beginner, it’s hard to find the balance between chance and the other things…
And BTW how can I make random negative numbers?

 
moo

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
4th June, 2003 at 02:55:06 -

If random (-56) doesn't work then try:

Set counter to 0 - random(56) or
Set counter to random(56) * -1

They will both make negative numbers, this works in MMF, but i dunno about TGF.

For the animal A.I you should probabley use a status counter. Like this:

Bear.Alt A = 0 - Run randomly
Bear.Alt A = 1 - Search for food
Bear.Alt A = 2 - Run away from player
Bear.Alt A = 3 - Chase Player
Bear.Alt A = 4 - Go to cave.

Then have an event making the alt val a set to random(5).

-Andy

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

David Evans



Registered
  23/08/2002
Points
  1209
9th June, 2003 at 13:13:41 -

Why 0 - random( X )
Why not just random( X ) - X. the expression is shorter in cases like this:
random( X ) - 500 instead of ( 0 - random( X ) ) - 400 ?

Ps. With AI, there should also be a 'do nothing' option. And the action should consider the circumstances (an alien with a bomb should drop it when the player is below them rarther than above them, which would just waste a perfectly good bomb)

 
I are therefore I am
   

Post Reply



 



Advertisement

Worth A Click