The Daily Click ::. Forums ::. Non-Klik Coding Help ::. Hi, Give me a beer!
 

Post Reply  Post Oekaki 
 

Posted By Message

Kramy



Registered
  08/06/2002
Points
  1888
3rd May, 2004 at 13:25:23 -

Hi, your goal is to make an AI.

The AI will say three things.
1) "Thought Patterns Initialized"
2) "Hi"
3) "Give me a beer!"

I'll start.

Jamascript:

myWindow = New Window(320,240); // Window for displaying output

myAI = New BeerAI(); // Make AI

While(1)
{
myAI.Think(); // Make AI Think
Wait(2500); // Pause between thoughts
}


Function BeerAI()
{
This.Thought = 0; // Current Thought

This.Think = BeerAI_Think; // Tell AI to think
}

Function BeerAI_Think()
{
Switch(Thought)
{
Case 1:
Break; // don't say a thing
Case 2:
myWindow.WriteLn("Hi");
Break; // say hi
Case 3:
myWindow.WriteLn("Give me a beer.");
Thought = 0; // reset thought
Break;
Default:
myWindow.WriteLn("Thought Patterns Initialized..."); // Only ran once
}
Thought++; // Goto next Thought
}


Edit: Forgot code tags.


Image Edited by the Author.

 
Kramy

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
3rd May, 2004 at 18:06:51 -

myWindow = New Window(320,240);

myWindow.WriteLn("Thought Patterns Initialized");
while(1)
{
myWindow.WriteLn("Hi");
myWindow.WriteLn("Give me beer");
wait(2500);
}


Image Edited by the Author.

 
- Tigerworks

Kramy



Registered
  08/06/2002
Points
  1888
3rd May, 2004 at 23:31:39 -

Ok, I now realize that wasn't very descriptive, but I can't edit the top post

Making an AI can sometimes be tricky, if you don't know what to start on. This is obvious, from all the crap AI seen in many games. The above example, and below expanded ones, are sort of like branching decision trees. The same principles can be used in a game, I just thought I'd use a funny example instead.

Like many other posts in here, I'm trying to get many differnet "AI's" posted in different languages, to see similarities, differences, which is easier, etc.

So if you think making an AI to ask for beer is stupid, then make one that does whatever you want, and post it. It'll still be interesting.

-Kramy

-----Original Post-----

Aw, come on. You're supposed to make a class that "thinks", not just write things in order...

The top one was basic, but expandable. Here's an expanded version with some diversity.

myWindow = New Window(320,240); // Window for displaying output

myAI = New BeerAI(); // Make AI


While(1)
{
myAI.Think(); // Make AI Think

Wait(2500); // Pause between thoughts
}

Function BeerAI()
{
This.Thought = 0; // Current Thought
This.SubThought = 0; // Intensive Subthought

This.Think = BeerAI_Think; // Tell AI to think
}


Function BeerAI_Think()
{
Switch(Thought)
{
Case 1:
Break; // don't say a thing
Case 2:
BeerAI_Think_2(); // say hi
Break;
Case 3:
BeerAI_Think_3(); // ask for beer
Thought = 0; // reset thought
Break;
Default:
myWindow.WriteLn("Thought Patterns Initialized..."); // Only ran once
}
Thought++; // Goto next Thought
}

Function BeerAI_Think_2()
{
// Get Subthought
SubThought = Math.Random(; // 0-7 Possible Values
Switch(SubThought) // Say a Greeting
{
Case 1:
myWindow.WriteLn("Hello.");
Break;
Case 2:
myWindow.WriteLn("Hi there.");
Break;
Case 3:
myWindow.WriteLn("Hello there.");
Break;
Case 4:
myWindow.WriteLn("Hey.");
Break;
Case 5:
myWindow.WriteLn("Hey there.");
Break;
Case 6:
myWindow.WriteLn("Howdy.");
Break;
Case 7:
myWindow.WriteLn("Greetings.");
Break;
Default:
myWindow.WriteLn("Hi.");
}
}

Function BeerAI_Think_3()
{
// Get Subthought
SubThought = Math.Random(15);
Switch(SubThought) // Ask for beer in 15 different ways
{
Case 1:
myWindow.WriteLn("I want a beer.");
Break;
Case 2:
myWindow.WriteLn("I really want a beer.");
Break;
Case 3:
myWindow.WriteLn("I want a beer, bad.");
Break;
Case 4:
myWindow.WriteLn("I need a beer.");
Break;
Case 5:
myWindow.WriteLn("Oooh god, I need a beer!");
Break;
Case 6:
myWindow.WriteLn("May I have a beer?");
Break;
Case 7:
myWindow.WriteLn("May I please have a beer?");
Break;
Case 8:
myWindow.WriteLn("Give me a beer.");
Break;
Case 9:
myWindow.WriteLn("Please give me a beer.");
Break;
Case 10:
myWindow.WriteLn("Can I have a beer?");
Break;
Case 11:
myWindow.WriteLn("Can I have a beer, please?");
Break;
Case 12:
myWindow.WriteLn("Need beer....");
Break;
Case 13:
myWindow.WriteLn("Please give me beer...");
Break;
Case 14:
myWindow.WriteLn("Oh god, give me beer!");
Break;
Default:
myWindow.WriteLn("Beer....");
}
}


Image Edited by the Author.

 
Kramy

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
8th May, 2004 at 14:11:43 -

My one was a joke.

/me predicts the next rush of newbie games having enemies which bounce around saying 'Hi, give me beer'

 
- Tigerworks

Muggus

Possibly Insane

Registered
  31/07/2002
Points
  2958
9th May, 2004 at 05:19:40 -

I'll have a beer too if your offering.

 
MUGGUS
Come and annoy me more at
www.muggus69.tk
STOUT ANGER!!!

Mr Icekirby



Registered
  18/12/2003
Points
  846
10th May, 2004 at 16:58:51 -

give me a beer? whats next? another game about ashman?

 
Mr Icekirby says so!
OBEY ME!

Kramy



Registered
  08/06/2002
Points
  1888
10th May, 2004 at 17:08:58 -

I'm working on it.

 
Kramy
   

Post Reply



 



Advertisement

Worth A Click