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
}
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....");
}
}