You must be logged in to post messages.
Please login or register

Scenario Design and Discussion
Moderated by Sebastien, Mr Wednesday

Hop to:    
loginhomeregisterhelprules
Bottom
Topic Subject: Random numbers in ai
posted 08-11-04 04:10 AM CT (US)   
I recently read something (I forget where (The University, maybe?) regarding AI being integrated into scenarios. In this article (I think) is something about generating random numbers in the AI script. My question is how can I make this work?

Basically, what I have is an AI where a player types something, eg '100' in a chat box, (for example to choose what type of attack they perform). This sends an AI Trigger signal depending on what they typed, and this in turn is recognised in the editor and a random number is generated using the 'random-number-generate' command. It all works fine until here, but when I try to get the AI to recognise which random number its generated it doesn't work. The identifier used in the article is 'random-number==...' but that doesn't work, and nor does 'random-number...' or 'random-number=...'. I've tried having it as an 'effect' in the same 'trigger' as the generator was in, and also having the generator 'trigger' set a goal, and have the random number identifier in that goal.

So, what I am asking is what do I type for the AI to see which number was generated, and how do I put it in the AI (in the same bit as the generator or in a seperate goal activated by the same bit as the generator). I would really appreciate some help, as I have spent a lot of time trying to make it work.

Thanks

Replies:
posted 08-11-04 04:23 AM CT (US)     1 / 12  
How do you know it does not recognise it? (random-number == x) should be working. If not, then maybe you generated too many numbers and it is never chosen, ie, choosing 1 out of 99999999999999999999.

Signed,
DaVe.
posted 08-11-04 08:51 AM CT (US)     2 / 12  
It sounds to me like your not setting it up correctly. Ensure you are setting the AI to a player, sounds obvious but you’d be surprised how often I forget to do this, and then wonder why my AI isn’t working. Make sure you are chatting to everyone when sending the taunt. And have you set the triggers correctly? The example you gave wouldn’t work because there is no space between the random-number and the == but that was probably just your typing here. Below is the script for the AI that does the taunt and random number generator. Copy and paste this, alter it to suit and you should be fine.

(defrule
(taunt-detected 1 100)
=>
(acknowledge-taunt 1 100)
(generate-random-number 3)
(disable-self)
)
(defrule
(random-number == 1)
=>
(set-signal 1)
(chat-to-all “Random number 1”)
(disable-self)
)
(defrule
(random-number == 2)
=>
(set-signal 2)
(chat-to-all “Random number 2”)
(disable-self)
)
(defrule
(random-number == 3)
=>
(set-signal 3)
(chat-to-all “Random number 3”)
(disable-self)
)

So when the player types 100, it generates 3 random numbers, and sends a signal back to the corresponding triggers in the editor. Note: the “chat-to-all” is for testing only, so you know it’s working. Disable this line when you’re finished.

Hope that helps.

posted 08-12-04 09:36 AM CT (US)     3 / 12  
Thanks, I think that I didn't put a space between the random-number and the ==. That will be what was wrong
posted 08-12-04 07:51 PM CT (US)     4 / 12  
I've had some problems with random numbers. It seems that when I generate three different numbers, they don't seem to activate "randomly" at all (they fire one after the other, in sequence). For instance: the first time I test a scenario the first number is fired, the second time the second number is fired, the third time the final number is fired. I can't work out why that happens.
posted 08-12-04 09:33 PM CT (US)     5 / 12  
That's strange, the scenario and AI recycle for each go, it isn't connected. Are you sure it just isn't luck, or bad triggers/AI scripting etc?

Somehow I get the feeling that nathbert was reading my TSU article, it sounds like what he described.



I'm Your Daddy
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your sig.
Can't believe on back on this damned site again.
posted 08-12-04 09:34 PM CT (US)     6 / 12  
Have you tested that a few times? It's possible you just got lucky. There is a 1/9 chance that you will get that order.

Creator of the AOK Trigger Studio, a work not in progress.
Wise men still seek Him.
posted 08-17-04 07:14 AM CT (US)     7 / 12  
The AI no longer has any incorrect typing! Thankyou to all who replied, in particular berserker jerker.

The problem now is that it just doesn't seem to work. I've done a test scenario to see if it is, and I know for sure that all the triggers are correct (right signals and AI trigger settings etc.)

Here is what I have tagged onto the end of a normal AI, and I was hoping someone could tell what I've done wrong, and give me advice etc.(defrule
(event-detected trigger 1)
=>
(acknowledge-event trigger 1)
(acknowledge-taunt 1 100)
(acknowledge-taunt 1 101)
(acknowledge-taunt 1 102)
(acknowledge-taunt 1 103)
(acknowledge-taunt 1 104)
(set-goal 1 1)
)

(defrule
(goal 1 1)
(taunt-detected 1 100)
=>
(acknowledge-taunt 1 100)
(set-signal 1)
(set-goal 1 0)
)

(defrule
(goal 1 1)
(taunt-detected 1 101)
=>
(acknowledge-taunt 1 101)
(set-signal 2)
(set-goal 1 0)
)

(defrule
(goal 1 1)
(taunt-detected 1 102)
=>
(acknowledge-taunt 1 102)
(set-signal 3)
(set-goal 1 0)
)

(defrule
(goal 1 1)
(taunt-detected 1 103)
=>
(acknowledge-taunt 1 103)
(set-signal 4)
(set-goal 1 0)
)

(defrule
(goal 1 1)
(taunt-detected 1 104)
=>
(acknowledge-taunt 1 104)
(set-signal 5)
(set-goal 1 0)
)

(defrule
(event-detected trigger 2)
=>
(acknowledge-event trigger 2)
(generate-random-number 5)
(set-goal 1 2)
)

(defrule
(event-detected trigger 3)
=>
(acknowledge-event trigger 3)
(generate-random-number 4)
(set-goal 1 3)
)

(defrule
(event-detected trigger 4)
=>
(acknowledge-event trigger 4)
(generate-random-number 3)
(set-goal 1 4)
)

(defrule
(event-detected trigger 5)
=>
(acknowledge-event trigger 5)
(generate-random-number 8)
(set-goal 1 5)
)

(defrule
(goal 1 2)
(random-number == 1)
=>
(set-signal 6)
)

(defrule
(goal 1 2)
(random-number == 2)
=>
(set-signal 7)
)

(defrule
(goal 1 2)
(random-number == 3)
=>
(set-signal 8)
)

(defrule
(goal 1 2)
(random-number == 4)
=>
(set-signal 9)
)

(defrule
(goal 1 2)
(random-number == 5)
=>
(set-signal 10)
)

(defrule
(goal 1 3)
(random-number == 1)
=>
(set-signal 11)
)

(defrule
(goal 1 3)
(random-number == 2)
=>
(set-signal 12)
)

(defrule
(goal 1 3)
(random-number == 3)
=>
(set-signal 13)
)

(defrule
(goal 1 3)
(random-number == 4)
=>
(set-signal 14)
)

(defrule
(goal 1 4)
(random-number == 1)
=>
(set-signal 15)
)

(defrule
(goal 1 4)
(random-number == 2)
=>
(set-signal 16)
)

(defrule
(goal 1 4)
(random-number == 3)
=>
(set-signal 17)
)

(defrule
(goal 1 5)
(random-number == 1)
=>
(set-signal 18)
)

(defrule
(goal 1 5)
(random-number == 2)
=>
(set-signal 19)
)

(defrule
(goal 1 5)
(random-number == 3)
=>
(set-signal 20)
)

(defrule
(goal 1 5)
(random-number == 4)
=>
(set-signal 21)
)

(defrule
(goal 1 5)
(random-number == 5)
=>
(set-signal 22)
)

(defrule
(goal 1 5)
(random-number == 6)
=>
(set-signal 23)
)

(defrule
(goal 1 5)
(random-number == 7)
=>
(set-signal 24)
)

(defrule
(goal 1 5)
(random-number == 8)
=>
(set-signal 25)
)

Sorry for the size of the post...

PS Typing is awkward woth a broken finger

[This message has been edited by nathbert (edited 08-17-2004 @ 10:51 AM).]

posted 08-17-04 08:09 AM CT (US)     8 / 12  

The Problem is the FIRST Rule.

You don`t

(acknowledge-event trigger 1)


That means the first Rule will always fire and "acknowledge" all Taunts before they can be detected by the following Rules -

The "construct" should work though if the Editor just fires the AI-Trigger 2-5 - that should turn out some Result.

posted 08-17-04 10:01 AM CT (US)     9 / 12  
Thanks for replying. However, it still doesn't work (I've changed the AI and the AI text in my orginal question to avoid confusion).

This AI is starting to annoy me.

[This message has been edited by nathbert (edited 08-17-2004 @ 10:51 AM).]

posted 08-17-04 04:58 PM CT (US)     10 / 12  
@nathbert, it looks like you are sending a signal to the editor, and then straight back to the AI to generate the appropriate random numbers. This could be done much easier in the AI without the need to send signals back and forth. I can’t see anything wrong with the script, but without seeing the triggers I can’t be sure either way. Type out the triggers, or send me the scenario and AI file and I will check it out, and correct it for you.
posted 08-18-04 06:21 AM CT (US)     11 / 12  

Quote:

I will check it out, and correct it for you.

Thankyou! I've sent the AI File and small testing scenario to you.

Cheers


_____•--« ÑÅTHßÉRT »--•_____
•--«¯¯¯¯¯RIP Woad Creations, RIP Shiva.¯¯¯¯¯»--•
«==========‡==========»
posted 08-20-04 05:15 AM CT (US)     12 / 12  
Berserker Jerker:

I'm just checking you got my email with the scx and ai in it.

Thankyou again!


_____•--« ÑÅTHßÉRT »--•_____
•--«¯¯¯¯¯RIP Woad Creations, RIP Shiva.¯¯¯¯¯»--•
«==========‡==========»
Age of Kings Heaven » Forums » Scenario Design and Discussion » Random numbers in ai
Top
You must be logged in to post messages.
Please login or register
Hop to:    
Age of Kings Heaven | HeavenGames