foundaons)of)game)ai · elizais)notintelligentbut...) •...
TRANSCRIPT
![Page 1: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/1.jpg)
Founda'ons of Game AI
Level 7 – AI Scrip'ng
Prof Alexiei Dingli
![Page 2: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/2.jpg)
What is AI scrip'ng?
• Simple programming language • Serves a specific task • Enable game designers (not programmers) to hand craE game
mechanics • Players can also modify the game • Scrip'ng languages such as Lua or Python can be used but also
graphical representa'ons • Scripts are edited using standard text editors • Some games allow real 'me scrip'ng during game play
![Page 3: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/3.jpg)
Scrip'ng AJributes
• Easier to tweak AI opponents (no need to re-‐compile)
• Anything can be tweaked – Intelligence – Speed – Strength – Magic
![Page 4: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/4.jpg)
Example AJribute Script
CREATURE=1; INTELLIGENCE=20; STRENGTH=75; SPEED=50; END
![Page 5: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/5.jpg)
Example Condi'onal Script CREATURE=1; If (LEVEL<5)
BEGIN INTELLIGENCE=20; STRENGTH=75; SPEED=50; END
ELSE BEGIN INTELLIGENCE=40; STRENGTH=150; SPEED=100; END
END
![Page 6: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/6.jpg)
Example Behavior Script
If (PlayerArmed==TRUE) BEGIN DoFlee(); END
ELSE BEGIN DoAJack(); END
![Page 7: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/7.jpg)
Example AI Behavior Script
If ( PlayerChallenge == DIFFICULT ) BEGIN DoFlee(); END
ELSE BEGIN DoAJack(); END
![Page 8: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/8.jpg)
Example Patrolling Behavior
If (creature.state==Patrol) Begin move(0,1); move(-‐1,0); … End
![Page 9: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/9.jpg)
Example Verbal Interac'on If (PlayerArmed ==Dagger)
Say("What a cute liJle knife."); If (PlayerArmed ==Bow)
Say("Drop the bow now and I'll let you live."); If (PlayerArmed ==Sword)
Say("That sword will fit nicely in my collec'on."); If (PlayerArmed ==BaJleAxe)
Say("You're too weak to wield that baJle axe.");
![Page 10: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/10.jpg)
Example Scrip'ng Events
If (PlayerLoca'on(120,76)) Trigger(kExposionTrap); PlaySound (kExplosion);
If (PlayerLoca'on(56,16)) Trigger(kPoisonTrap);
![Page 11: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/11.jpg)
Example Keyword Scrip'ng
If (Ask("what") and Ask("name") ) begin Say("I am Merlin."); end
![Page 12: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/12.jpg)
Scrip'ng a ChaJerbot • Eliza, the first chaJerbot : a computer program that mimics
human conversa'on – Joseph Weizenbaum, MassachuseJs Ins'tute of Technology
• User types in natural language
• ELIZA then analyzes the user's statement and generates some response which it types out
12
![Page 13: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/13.jpg)
ELIZA Sample
conversa'on
Men are all alike. IN WHAT WAY? They're always bugging us about something or other. CAN YOU THINK OF A SPECIFIC EXAMPLE? Well, my boyfriend made me come here. YOUR BOYFRIEND MADE YOU COME HERE He says I'm depressed much of the Hme. I AM SORRY TO HEAR YOU ARE DEPRESSED It's true. I am unhappy DO YOU THINK COMING HERE WILL HELP YOU NOT TO BE UNHAPPY I need some help, that much seems certain. WHAT WOULD IT MEAN TO YOU IF YOU GOT SOME HELP Perhaps I could learn to get along with my mother. TELL ME MORE ABOUT YOUR FAMILY
13
![Page 14: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/14.jpg)
Eliza's strategy Keywords
• Input is read and inspected for the presence of a keyword
• When keyword is found, the sentence is transformed according to a rule associated with the keyword
• Else a content-‐free remark or, under certain condi'ons, an earlier transforma'on is retrieved.
• The text so computed or retrieved is then printed out
14
![Page 15: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/15.jpg)
ELIZA Example transforma'ons
"I am X" à "How long have you been X?«
I am very unhappy. HOW LONG HAVE YOU BEEN VERY UNHAPPY?
"X YOU Y ME" à "What makes you think I Y you?«
It seems that you hate me. WHAT MAKES YOU THINK THAT I HATE YOU?
15
![Page 16: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/16.jpg)
ELIZA Why does it work?
• Rogerian psychotherapist à Can pretend to know
almost nothing of the real world "I went for a long boat ride" "Tell me about boats"
• Not a real dialog (no real communica'on)
– ELiza generates a reac'on (oEen a rather non commital one) to the user's statement
– The user cannot ask for informa'on. – The user cannot issue an order
16
![Page 17: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/17.jpg)
ELIZA Does it really work?
Eliza: Hello. I am ELIZA. How can I help you? You: I went to Paris yesterday Eliza: Can you elaborate on that? You: I took the train Eliza: Can you elaborate on that? You: The train was late Eliza: Please go on. You: All the seats were full Eliza: Please go on. You: A liKle boy was having a tantrum Eliza: Please go on.
17
![Page 18: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/18.jpg)
ELIZA Does it really work?
Indexicals (I, you, here, now) User: I am having fun right now. Eliza: Does it please you to believe that I am having fun right now.
World Knowledge User: I am a human. Eliza: How long have you been a human?
18
![Page 19: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/19.jpg)
When Eliza fails • Yes/No QuesHons
User: Are you a good therapist? Eliza: Would you prefer it if I were a good therapist? User: I'm wondering about your skills as a therapist; Eliza: Does it please you to believe I am wondering about my skills of therapist?
• Wh-‐QuesHons User: Who are you? Eliza: Would you prefer it if I were not? User: What do you want me to tell? Eliza: Does that ques'on interest you?
• Complex AsserHons User: I don't have a problem. I'm quite happy, I have a girlfriend, I study. Everything is OK! Eliza: Why do you not have any problem, I'm quite happy, you have a girlfriend, you study. Everything is OK!
19
![Page 20: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/20.jpg)
Eliza is not intelligent but...
• Regardless of what people believe or know about the inner workings of computers, they talk about them and interact with them as social en''es.
• Weizenbaum (1976) notes that many people con'nued to believe in ELIZA’s abili'es even aEer the program’s opera'on was explained to them.
• People act toward computers as if they were people and expect that computers should be able to understand their needs and be capable of interac'ng with them naturally.
• Given these predisposi'ons, speech-‐ and language-‐based system are not supposed to be intelligent
• But they may provide users with the most natural interface for many applicaHons
20
![Page 21: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/21.jpg)
Exercise
• Have a chat with the Eliza Bot (index.html)
• Have a look at the rules (elizadata.js)
![Page 22: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/22.jpg)
The Eliza Rules ["<key>", <rank>, [ [ // first decomposi'on paJern "<decomp>", ["<reasmb>", "<reasmb>", "<reasmb>"] ], [ // second decomposi'on paJern "<decomp>", ["<reasmb>", "<reasmb>", "<reasmb>"] ] ] ]
![Page 23: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/23.jpg)
The Eliza Rules • Keywords with higher rank take precedence
• Decomposi'ons are matched in defini'on order
• Reasemblies are chosen by random or cycled through if the no-‐random flag is set
• The special keyword "xnone" holds the rules for default phrases (no match)
• Pres, posts, synonyms, keywords, decomposi'ons all in lower case
• All defini'ons are op'onal but at least elizaKeywords should be supplied
• If no keywords are found `transform()' returns the default string "I am at a loss for words.”
![Page 24: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/24.jpg)
Decomposi'on Rules
• * ... any words (incl. none)
• $ ... (in first posi'on) reassemble for memory only
• @synon ... subs'tute entry with a synonymous expression
![Page 25: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/25.jpg)
Reassambly
• (n) ... insert param of posi'on n (first is "1")
• posi'ons are any matchings of "*" or "@synon"
![Page 26: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/26.jpg)
Eliza Examples
["sorry", 0, [ ["*", [ "Please don't apologise.", "Apologies are not necessary.", "I've told you that apologies are not required.", "It did not bother me. Please con'nue." ]]
![Page 27: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/27.jpg)
Eliza Examples
["* i am* @sad *", [ "I am sorry to hear that you are (3).", "Do you think coming here will help you not to be (3) ?", "I'm sure it's not pleasant to be (3).", "Can you explain what made you (3) ?" ]],
![Page 28: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/28.jpg)
Eliza Examples
["forget", 5, [ ["* i forget *", [ "Can you think of why you might forget (2) ?", "Why can't you remember (2) ?", "How oEen do you think of (2) ?", "Does it bother you to forget that ?", "Could it be a mental block ?", "Are you generally forge~ul ?", "Do you think you are suppressing (2) ?" ]], ["* did you forget *", [ "Why do you ask ?", "Are you sure you told me ?", "Would it bother you if I forgot (2) ?", "Why should I recall (2) just now ?", "goto what", "Tell me more about (2)." ]] ]],
![Page 29: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/29.jpg)
Exercise
Create a bus booking Chatbot. 1. Gree'ng 2. From 3. To 4. Bye
![Page 30: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/30.jpg)
Crea'ng a conversa'onal agent
• AIML – Ar'ficial Intelligence Markup Language – Used in ALICE (Ar'ficial Linguis'c Internet Computer En'ty)
– Won the • Leobner prize 3 'mes • ChaJerbox challenge
30
![Page 31: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/31.jpg)
Cycle
Human inputs
sentence
Chatbot searches database
Chatbot produces response
31
![Page 32: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/32.jpg)
Cycle
Human: “How are you
doing?”
Chatbot: “How are * … Template: I’m fine, thanks
Chatbot: I’m fine, thanks
32
![Page 33: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/33.jpg)
PaJerns
<aiml> <category> <paJern> HELLO </paJern> <template> Hi! How are you? </template> </category>
… </aiml>
33
![Page 34: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/34.jpg)
AIML shorthand
! A bot will not know this line is here p Hello t Hi there! I hope you are \ having a great day!
34
![Page 35: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/35.jpg)
AIML Macros
! Remember...comments begin with the ! character ! The macro on the next line defines the bot's name $ my_name Larry p what is your name t My name is $$my_name.
35
![Page 36: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/36.jpg)
AIML Macros
$ i_am_a robot p you are weird t Please don't hold my $$i_am_aness against me :-‐(
36
![Page 37: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/37.jpg)
Loops pf hi hello "what is up" hola howdy "what is going on" t Hi, it's very nice to meet you! p hi t Hi, it's very nice to meet you! p hello t Hi, it's very nice to meet you! p what is up t Hi, it's very nice to meet you! p hola t Hi, it's very nice to meet you! …
37
![Page 38: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/38.jpg)
Complex Loops
p I pf really " ” pf like love p being with pf dogs cats animals t Really? I enjoy being with animals, too!
38
![Page 39: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/39.jpg)
Loops and Macros $ like_terms like love p i pf $$like_terms p fish t You like fish? I HATE fish! p i pf $$like_terms p dogs t I like dogs, too!
39
![Page 40: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/40.jpg)
Advanced Loops p i pf " " really p love pf dogs cats fish animals t You love $$[1][*]? I love all kinds of $$[1][3]!
40
0 1 2 3
0 “ ” really
1 dogs cats fish animals
![Page 41: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/41.jpg)
Random Lists
p hello t r l Hi! It's nice to meet you! l Hello, how are you today? l Gree'ngs! l Hi, what are you up to?
41
![Page 42: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/42.jpg)
Random Lists
<paJern> HELLO </paJern><template><random> <li> Hi! It's nice to meet you! </li> <li> Hello, how are you today? </li> <li> Gree'ngs! </li> <li> Hi, what are you up to? </li> </random></template>
42
![Page 43: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/43.jpg)
Condi'ons
p how do i look t I think you look cnv gender male handsome cnv gender female preJy t !
43
![Page 44: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/44.jpg)
Case Study: Robo BaJle Pigs
![Page 45: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/45.jpg)
Case Study: Robo BaJle Pigs
• Objec've
– To destroy your opponent's Robo BaJle Pig by inflic'ng five points of damage with your laser or powerful robot fist
![Page 46: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/46.jpg)
Case Study: Robo BaJle Pigs
• Rules
– For two players, the pigs start the game on opposite sides of the board, just to the right of the center line, facing the center of the board
– Each round of the game is made of five moves. Both players plan their five moves. The players then reveal their "programs", and move their pigs simultaneously.
![Page 47: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/47.jpg)
Case Study: Robo BaJle Pigs • AI Challenge
– Must create a string containing five encoded commands, separated by spaces
– Must use the standard command
– Must issue one Damage(X) command for each wound suffered by the pig
– Must ensure that the Repair(R) command is used correctly, which means that Repair(R) commands may only be given if all five commands are Repair(R)
![Page 48: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/48.jpg)
Case Study: Robo BaJle Pigs • Variables
– X -‐ Your pig's x-‐coordinate – Y -‐ Your pig's y-‐coordinate – Health -‐ Your pig's health – Facing -‐ The direc'on your pig is facing, encoded as an integer, where N=0,
E=1, S=2, W=3 – opponentX -‐ Your opponent's x-‐coordinate – opponentY -‐ Your opponent's y-‐coordinate – opponentHealth -‐ Your opponent's health – opponentFacing -‐The direc'on your opponent is facing, encoded as above
![Page 49: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/49.jpg)
Case Study: Robo BaJle Pigs • Command Encoding
– "^": Move the pig one square forward. – "v": Move the pig one square backward. – "/": Move the pig diagonally forward and right. – "\": Move the pig diagonally forward and leE. – "TL": Turn the pig to the leE. – "TR": Turn the pig to the right. – "F": Fire a laser beam in a straight line in the direc'on the pig is facing. – "H": Swing the massive robo baJle pig baJle fist, striking the three squares in front of
the pig. – "R": Repair one point of damage. – "X": Do nothing. One Damage(X) command must be issued for each point of damage
suffered by the pig.
![Page 50: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/50.jpg)
Random AI
String randomCommand() { // Math.random() returns a random double between 0 and 0.999... // Mul'ply by 8 and cast to an int, and we should have a num in [0,7]. int n = (int)(Math.random() * 8); switch(n) { case 0: return "^ "; case 1: return "\\ "; case 2: return "/ "; case 3: return "TL "; case 4: return "TR "; case 5: return "v "; case 6: return "F "; case 7: return "H "; default: print("This should never happen."); } } // This will hold the result String result = ""; // Make sure we have one Damage(X) command for each wound int i; for (i=0; i<5-‐health; i++) result += "X "; // All other commands are random for (; i<5; i++) result += randomCommand(); // The last thing in the script must be the command string. result;
![Page 51: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/51.jpg)
Sit and Shoot AI
// This will hold the result String result = ""; // Make sure we have one Damage(X) command for each wound int i; for (i=0; i<5-‐health; i++) result += "X "; // All other commands are Fire(F) for (; i<5; i++) result += "F "; // The last thing in the script must be the command string. result;
![Page 52: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/52.jpg)
Exercise
• Try the
– Random AI – Sit and Shoot AI
![Page 53: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/53.jpg)
Exercise
• Using the BeanShell scrip'ng language (hJp://www.beanshell.org) write your own AI
• Use your AI to fight against your neighboring classmate
![Page 54: Foundaons)of)Game)AI · Elizais)notintelligentbut...) • Regardless)of)whatpeople)believe)or)know)aboutthe)inner)workings)of) computers,)they)talk)aboutthem)and)interactwith)them)as)social](https://reader033.vdocument.in/reader033/viewer/2022052104/603eec951019772f6f0bf51d/html5/thumbnails/54.jpg)
Ques'ons?