Artificial Intelligence...

VbNerd96
07-16-2010, 06:12 PM
I have been working on an Artifficial Intelligence project and have incountered a bug... which I not sure how to fix.

First off a little backstory (if you will).------------------------------
The program has multiple types of AI with different characteristics...
One of which is just a plain ol' averge being.

Now, this AI during it's main loop will "search for danger" just to make sure that there is not any kind of hazard that it will need to avoid, or something it needs to investigate.

One thing it searches for are dead bodys.
And, if it finds one it will procede to investigate said body...
after investigating the body and looping through some random things (check cause of death, alert nearby peeps, call athoritys) it will procede to move away from the corpse..

at which point it will *again* recognise the body and go through the same loop over and over again as though it had never seen the body before.

----------------------------------------------------

Sorry for the long intro...

Anyway, My question is : is there some way I can make it so that the next time the AI encounters it it will know that it has seen it before and will leave it alone?

Thanks in advance...

vb5prgrmr
07-16-2010, 10:32 PM
Well that really depends upon what and how you keep track of the environment. Do you have fog of war tracking AKA terrain discovery? How do you track the placement and movement of other obsticals/characters within the environment? Do you have some sort of bitmap or indicator array? If so, could you not flip a bit somewhere to indicate discovered and searched?



Good Luck

VbNerd96
07-17-2010, 10:29 AM
Well, right now there actually is no method of keeping up with the envirorment...

I do not have the envirorment gridded, so every thing is free-roam... How would one go about setting up an indicator array or something with a free-roam envirorment??

vb5prgrmr
07-17-2010, 09:28 PM
In any way that works for you... However, I have seen bit maps (*.bmp) like fiiles in several formats. A monochrome, greyscale, true color, and with an alpha value (ARGB or is that ABGR), meaning...

11111111
10000001
10011001
10011001
10011001
10011001
10000001
11111111

in a monochrome bitmap style, each bit, either a zero or a one, denotes where a player can walk/move, or it could mean something else...

Same can be said for a 256 greyscale image where each byte, pixel, contains some sort of meaning as each byte can be a value from 0 to 255. So this could be a height map or a movement cost map, or... well let your imagination run wild with that...

Then of course, the bitmap type of file we may be more used to where each pixel has an RGB value and each byte (r,g,b) for each pixel can mean something.

Of course after that, there is the alpha channel with each pixel.

Now, these don't actually have to be *.bmp files (or *.jpg, *.png), but if you are going to let your users define game envionments, terrain, obstacles, etc. it is one way to do so. Another way, like the game of Decent, an older game, which was in 3d. They used a common 3d environment formated file that I believe most users used Autocad to design levels with.

Now, these file formats can be of your own design, or you can use an established file format and just used it for your own purposes...



Good Luck

VbNerd96
07-17-2010, 11:41 PM
Woah... I'm sorry but I've gotten a bit confused....

The example made me think Multi-demisional Array... but your talking about bitmaps... how would I incorperate a bitmap into this?

vb5prgrmr
07-18-2010, 06:04 AM
Well think about the example I gave you and an image. Each have a width and a height, and cannot these be tracked by a multidimensional array? Via X and Y values? It is pretty much the same to say...

MyLongValue = MyLongArray(x, y)
'or
MyLongValue = GetPixel(PicBox.hdc, x, y) 'GetPixel is an API BTW



The only difference is, if you are somewhere on this terrain and you want to know what is around you, based on vision, fog of war, etc. With an array, you have to figure it out, but with a bitmap, they make API's for such things...

http://www.tek-tips.com/viewthread.cfm?qid=849985
http://www.tek-tips.com/viewthread.cfm?qid=626738
http://www.tek-tips.com/viewthread.cfm?qid=334861

http://www.tek-tips.com/viewthread.cfm?qid=270540



Good Luck

VbNerd96
07-18-2010, 11:57 AM
Wow, that was much simpler than I thought it would be. lol

But I finnally understand... lol...

Anyway, thanks a mill' for the assistance... much appreiciated.

Banjo
11-22-2010, 11:04 AM
How is your AI realising that there is something there to search? I'm assuming you have a set of "objects", each of which has various properties such as position, vector, sprite and so on. I would have thought you'd just want to add a new property called for "searched".

surfR2911
12-05-2010, 07:42 PM
Reading through your first post that talks about: "searching", "investigating", "encountering", and "moving away from", I have a feeling you are eventually going to want to investigate some computer algorithms involved in pathfinding:
http://en.wikipedia.org/wiki/Pathfinding

Some good pathfinding algorithm search terms are:
A* (or just in case the forum's stupid search engine still can't deal with two letter search terms - "A-star" or "Astar")
Dijkstra
Best First
Floyd-Warshall

Here's some links to get your started..

Good starting tutorial:
http://www.policyalmanac.org/games/aStarTutorial.htm
Amit's Game Programming, Shortest Path links:
http://www-cs-students.stanford.edu/~amitp/gameprog.html#paths
Tek Tips page with a bunch of links (scroll down a bit):
http://www.tek-tips.com/viewthread.cfm?qid=1517633&page=1

A* Pathfinder in Visual Basic (pdf) (http://digilander.libero.it/foxes/Plot/Pathfinder_%20Astar.pdf)

XVBT forum thread links:
http://www.xtremevbtalk.com/showthread.php?t=183211
http://www.xtremevbtalk.com/showpost.php?p=839768
http://www.xtremevbtalk.com/showpost.php?p=412620
http://www.xtremevbtalk.com/showpost.php?p=951057

Links to off site VB examples:
LaVolpe Non-Tiled Pathfindng (http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=61062&lngWId=1)
http://www.amanitamuscaria.net/page/compsci/vb-pathfinding
Various Pathfinding Implementations (A*, Dijkstra & BFS) (http://www.vbforums.com/showthread.php?t=452200)
http://members.shaw.ca/optikal/MazeTracer/MazeTracer.zip
http://www.rookscape.com/vbgaming/tutAO.php
http://directx4vb.vbgamer.com/DirectX4VB/Tutorials/GeneralVB/GM_Dijkstra.asp

In interesting article on "Motion Planning using Potential Fields" (which unfortunately has no VB source code):
http://www.gamedev.net/reference/programming/features/motionplanning/

One of the above forum links refers to a some old VB Dijkstra-related code on a Geocities site.
Of course this site no longer exists, but to save it from oblivion on this, the longest lasting of LegacyVB forums, (and because it looks like the original author Alex Popov did a bit of work on it) I'll attach it.

Leade
12-29-2010, 05:21 AM
1] A little cheat you can do if you have only a few bodies on screen each time is create a hidden list of bodies it will work down and till it is complete, this is a good idea if you have a small amount but can slow system down the larger the list, it also means if new bodies appear, which they inevitable will, these won't be added/scanned till the list is completed. You also stand the chance of confusing the newly added bodies to the already scanned bodies and be right back where you started.

2] A simpler way of doing it is to create a single byte flag which is either 1 when scanned or 0 when not, that way if the computer should stumble over it again it should see its already scanned it and should move on.

3] Another thing you could do is if the computer scans the bodies and is finished why not just delete the body and free up resources or if you programming skills is advanced enough merge the body mesh to the scenery mesh (it is possible, and quite easy to do... well for me anyway)

You'll still see the object but won't be able to interact with it again. I should also point out that once meshes are merged its quite difficult to separate them again, and believe me i've tried.

In your case i'd go with number two it would suit your program and would be very easy to utilise.

VbNerd96
01-08-2011, 04:41 PM
Whoops, haven't logged-in in a few months so I've only just now seen the other posts.

@Banjo Quite simple, though maybe unoptimized. Every AI in the world is contained within an Array. When any particular AI is searching for something it'll loop through said Array and check for certain red-flags as to where danger is. I.E.

For i = 0 to ubound(AI)
If AI(i).Alive = false then
Investigate
'Yadda Yadda... FooBar
End if
Next i


@VB6Oldguy Thank you so much. This are sure to help... a LOT. lol.

@Leade I think vb5prgrmr already suggested #2, but thanks for the other ideas.

Banjo
01-09-2011, 07:05 AM
Then surely you just need another flag which Investigate sets to true:
For i = 0 to ubound(AI)
If AI(i).Alive = false and AI(i).Searched = False then
Investigate
'Yadda Yadda... FooBar
End if
Next i

VbNerd96
01-09-2011, 05:43 PM
Ah, I see what you mean. o.O Hasn't vb5prgrmr already suggested that though?

Leade
01-10-2011, 12:15 PM
just use my numer three its better forget everyone else 3 3 3 3 3 3 3 3 3 3............ you know what never mind see if i care, but remember this a dog is not just for christmas, it also makes a very impressive meal.

Banjo
01-10-2011, 07:00 PM
Ah, I see what you mean. o.O Hasn't vb5prgrmr already suggested that though?

He did, but your reply to him seemed to indicate that you were confused by the concept.

VbNerd96
01-11-2011, 06:02 PM
Gotcha'. Cool, thanks anyway.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum