PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

A Question on AI

does anyone know where I can get some AI code, or maybe someone can give me some pointers on what to do etc.

The game im working on is a RPG/Advanture/puzzle game, a player can move around a "world" of unlimited size, but normally (100x100 blocks), 15x12 of these are visable to the player on the screen at any one time. I'd like to place some mosters etc in the map, but am unsure how to get them to move/attack/do stuff etc. If anyone has some cool ideas I'm all open

-Thanks, Brendan
I wrote a BIG LONG THING, then I deleted it. :(

Anyway, it depends on how bad-ass you want to be. If you want to go all out, go get a book on game "AI." I put AI in quotes because I am an AI snob, and don't consider game AI to be anything more than glorified state machines and if-blocks...but anyway...

If you just want to do a normal "AI" thing, you can assign properties to each monster (making each monster its own instantiated class is easiest). Then, per turn, tell it to update. The update can be as simple as checking distance relative to the character against some threshhold set as a property. This is the state machine method, and is pretty expandable.
We went over game AI a bit in a thread before (can't remember which).

Have a look at:

http://www.gameai.com

And see if that helps any.

RICoder's right though - a simple state machine for each monster class wouldn't be a bad plan at all... it all depends how "funky" you want to get :D

Cheers,

Refractor
brendan · 18 Apr 2002, 09:05 UTC — mmmm
oh boy this game just keeps getting better and better! :roll:

I knew I should have kept to simple puzzle games.....

I'm sure to "sell" attract more interest if there are actually thing in the game to kill....?

Heres my idea... create a enemy class.

load the map and for every location that has a partiuclar "enemy" add it to a linked list of "enemy classes", giving it details about where it starts etc... then just process the list every now and then ? then if it dies etc it should be a matter of just removing it from the list etc ?

-I've no idea... I PROGRAM PUZZLE GAMES..... :(
brendan,

the way we used to do this in my game programming days (that is a few months ago :wink:), was to setup a singleton class which would take the role of "Manager" for whichever feature you'd like to control. This is the one that keeps on every object of a particular type, their properties, and/or any other things you want it to control.

It is the Manager that you invoke to find out anything you want about the particular objects (e.g. enemy's strength and life expectancy).

This concept was used in our games throughout, so you'd have an Effects manager, Comms Manager, Bullet manager, etc...

Ahhh! Those were the days :D

Cheers!
AL
P.S. By the way, I completely agree with RiCoder, Game AI does not deserve its name. It's a glorified bunch of state machines. But sometimes the results surprise even the programmer who created them!
The usage of design patterns (singletons, managers, factories, etc) in games is covered quite well in "Game Architecture and design":

http://www.amazon.com/exec/obidos/ASIN/1576104257/qid=1019202572/sr=2-1/104-3336988-8043905

Cheers,

Refractor
BurningSheep · 19 Apr 2002, 23:17 UTC
Alfonso wrote:
P.S. By the way, I completely agree with RiCoder, Game AI does not deserve its name. It's a glorified bunch of state machines. But sometimes the results surprise even the programmer who created them!


A game doesn't need a real A.I. it only needs to simulate a human, so people can relate to the computer player.
For instance if you would program a targeting algorithm, you might as well write something that always hits what it aims. And then start changing some of the values with random numbers so it doesn't hit the target dead on everytime. The trick then is to adjust the random values in such a way that the result look like something a real person would do.

The gamer usually doesn't care if a quake bot is has a 'real' AI, as long as he can relate to it.

Another reason not to have 'real' AI in games is that it will probably cost too much CPU power, especially on devices like PocketPC's where everything has to be done by the CPU.
On PC's we get more and more cpu resources for things like AI, because the GPU is taking over all graphics related processing (the same goes for sound ofcourse).
What is an example of "real" AI? Alice isn't "real" AI, she's just a script, but she won the Turing Award a bunch!
brendan · 22 Apr 2002, 00:28 UTC — let me clarify...
OK OK, I seem to have lead you all up the garden path, in saying AI, I did mean scripts / fancy IF/AND/ELSEy style code etc.... I was asking anyone for code examples etc, after all AI does not exist.... :o
BurningSheep · 22 Apr 2002, 00:34 UTC
try gamedev.net I think they have some AI tutorials and stuff related to games
Correction, AI does exist in some forms, as does AL. Which is not to say that there are thinking machines per se, but that there are machines that pass Turing's test.

When they make a Prolog compiler for PPC I will send you some sample code. ;)
BurningSheep · 22 Apr 2002, 01:38 UTC
RICoder wrote:
When they make a Prolog compiler for PPC I will send you some sample code. ;)


Argh, please don't mention prolog, I still get horrible dreams about that every once in a while
Don't you mean "pass Turing's definition of AI"

-Brendan
Turing's test, meaning the test of AI as developed by Turing and extended by followers of such things.

But, moving on, I think this is a really interesting conversation to have. AI is one of those pet-projects I find myself wrapped up in from time to time.