[General Algorithme] Working with AI

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Duck
Sir Posts-A-Lot
Posts: 231
Joined: Sat 18 Dec, 2004 3:38 am

Post by Duck »

Kozak wrote:For my UOH (uniform object handler) I thought of a way to handle characters on screen. I had a general update loop which checked what input the character got:
- player input character, check for keypresses (so I could have 10+ character controlled chars)
- inverse player movement (same as player movement only inverse, also seen in zelda)
- follow player (move in direction of player)
These are all quite simple. Just make one routine ("getPlayerInput"), recording all input and putting them to vars. Then you can use player input anywhere in your program. For example, the input of 2nd, apha and 2 other keys are stored in one byte variable. The higher 4 bits are the pushed keys in this frame. And the lower 4 bits are the pushed keys in the previous frame. So, if key "2nd" is the 0th (prev frame) and 4th (this frame) bit, you check secondPressed (AND %00010000), secondHold (AND %00010001) and second Released (AND %00000001) very simply, and use them anywhere you like. Also in enemy AI routines of course.

By the way, some people make AI sound much more mysteriously then it actually is. Its just about making a piece of code for which determines for each monster the next action (for example xspeed, yspeed, particle throwing) by checking some input variables (player closeness or somethin') and you'll have very delicate AI for a ti83 game. You dont need any education to be able to write such a thing.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

You dont need any education to be able to write such a thing.
No education at all aye? :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
Duck
Sir Posts-A-Lot
Posts: 231
Joined: Sat 18 Dec, 2004 3:38 am

Post by Duck »

I'm just wondering what all the discussion is all about. Some things are just too obvious. Or is it just me? :?:
coelurus
Calc Wizard
Posts: 585
Joined: Sun 19 Dec, 2004 9:02 pm
Location: Sweden
Contact:

Post by coelurus »

For a TI, AI doesn't have to work much. Duck explained the idea pretty well up there, "enemy picks action on some input parameters", what else could enemies do (and to me, there's more common sense in that than education ;) )? Biggest problem is that people who know a lot about a subject always talk about what they find hard and discussions go heywire when the newcomer doesn't have a clue even where to start (AI-people often go ranting about fuzzy logic, neural networks etc when those are hardly used in the most advanced games today).

The tricky part comes when enemies has to think nearly as much as the player, for instance, the already so much discussed issue of pathfindng. The worst bit is memory space, because the workload could be split up to multiple frames. I had some thoughts about this once in a discussion about an RTS (where pathfinding is dead crucial if you're allowed to build buildings, otherwise a sort of sector+portal-system could solve concave areas), but I never worked seriously on that. I will have to soon though, I'm still programming on the PC and I like keeping mem resources down.
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

Another supporter of Duck raising a hand. On the calc we are constrained to make use of the simplest methods, often hacks. I think the state driven approach is the easiest way to create behaviour that looks complex from the outside. Given that each state can be implemented with a simple enough strategy (for standing still, keeping looking around, patrolling, chasing, attacking, fleeing, calling others etc.), adding more states is a very cheap way of extending the capabilities of NPCs, e. g. adding more degrees of attacks. It is still an interesting question whether orthogonal state variables are a good idea, e. g. maintaining a bit for 'heard something suspicious recently' or 'seen the corpse of a buddy' which contribute to the internal strategy instead of directly affecting the actions (as opposed to the previous 'named states' approach).

Pathfinding is quite a resource eater, especially when combined with swarm movement. Hmmm, creating an RTS would need more thinking anyway...
teoryn
New Member
Posts: 26
Joined: Sat 18 Dec, 2004 4:23 am
Location: Ohio
Contact:

Post by teoryn »

More powerful AI usually isn't put into games because it would take a lot of programming, and probably to much time. However, sometimes more powerful AI's can be really cool. Check out http://www.20q.net for an example of a neural network in use.
You've seen the posts, now see the sites!
http://hiddenuniverse.blogspot.com
http://teoryn.deviantart.com
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Of course a pathways system would help a lot... let's say, if you create a map, you could make important pathways, which the AI could use, this would eat up some more memory, but less cpu speed than another method
Image
User avatar
dysfunction
Calc Master
Posts: 1454
Joined: Wed 22 Dec, 2004 3:07 am
Location: Through the Aura

Post by dysfunction »

Wow... 20Q is pretty damn smart... My object was a computer, and for oguhly hlf of my answers I wasn't sure my answer was the most helpful choice. Yet it took about 10 questions, then it guessed and was correct!
On the subject of AI that's actually possible on-calc, I think the ideas most discussed here work best- they've been used, in varying levels of complexity- in many games. Chrono Trigger, the Metal Gear series, Starcraft, etc.
Image


"You're very clever, young man, but it's turtles all the way down!"
Kozak
Maxcoderz Staff
Posts: 791
Joined: Fri 17 Dec, 2004 5:33 pm
Location: On the dark side of the moon.
Contact:

Post by Kozak »

kv83 wrote:Of course a pathways system would help a lot... let's say, if you create a map, you could make important pathways, which the AI could use, this would eat up some more memory, but less cpu speed than another method
This is the beacon method I proposed, could work in alot of instances, but might be a space eater when you want to register which tile points to which beacon.

I think cool AI shouldn't be a problem on the TI, only the pathfinding aspect will give speed and size problems. States are challenging enough since humans think in the same way. To make it more realistic you could change the strenght of how each external input is registered to the NPC and so adapting NPC behavior to weaknesses of the player.
"They say that sea was created by a man named Maarten Zwartbol, a long time ago...." - Duck, an old Corbin version
the_unknown_one
Calc Master
Posts: 1089
Joined: Fri 17 Dec, 2004 9:53 am

hmm

Post by the_unknown_one »

I think good AI is very hard to do... The best AI i've ever been able to do yet, is in the game Shoot (example game for MLC) and its not even really an AI...
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Just for reference, I started a new thread about the BattleCards AI in the BattleCard forum.
It's called Designing the AI of BattleCards
Image
Toaster
Extreme Poster
Posts: 322
Joined: Tue 15 Feb, 2005 12:08 am
Location: Lost in a land of mysteries.....

Post by Toaster »

Ninja AI

Well I have the game engine pretty much done so I have gone on to AI and I am stuck!

The AI is gona be pretty simple they just move at you and if there close enough to attack they would do so.

How would I make it so the AI would move at you. I have no clue how to do this. Much help would really be appercated!

Thanks
Join me at:
http://nanotech.pcriot.com
or
http://emancipal.co.nr

Coming soon..
Rewrite 3D Level Editor - 55% done!!
Emancipal - The Creator 5% done
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

Comparing coordinates and choosing an action based on the result?
User avatar
VahnRPG
Extreme Poster
Posts: 331
Joined: Mon 20 Dec, 2004 10:44 pm
Location: Earth...currently...
Contact:

Post by VahnRPG »

though it's not entirely related to the subject, my mom is CONVINCED that if you program something like a game where your opponent is the computer, it will cheat. I have no clue WHY she has this mentality, since the only way I could think that'd be possible is to PROGRAM it to cheat (the first I heard of this was when I was working on my Rock Paper Scissors game so very long ago)...<sigh> women...
I'd rather be a nobody remembered by someone than a somebody remembered by noone.

'Boku' can't save the world - Blaze Rennaul
--'Boku' doesn't have to... - Klyne Ryuuno
Blue World - Coming soon
CrimsonCasio
New Member
Posts: 60
Joined: Tue 11 Jan, 2005 1:48 am
Location: The Dark Tower, The Middle of Everywhere

Post by CrimsonCasio »

actually, in some games thats a good solution to a not very bright AI... just have it cheat every now and then ;)
Post Reply