Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / AI in DarkGDK, From 0 to Z , pls help.

Author
Message
haliop
User Banned
Posted: 30th Dec 2008 17:20
hello , i'm building a 2d project where
you see Good vs Bad from a top -down view.

i want to make each Ai as an induvidual he recives data from the spechific LEVEL , i'm using Tile System, and act acorrding to it.

now i can do it, i know its tough and not so easy.. but if i put my mind extra hard to it i will achieve it!

but.
theres one thing i just cant put my finger on .
the AI SIGHT.
i can do the "WHAT AI SEE" but i can't do the "HOW AI SEE"

i want the AI to have "EYES" i tried puting a long Sprite infront of it and what ever touch "Collision" that sprite is loaded into players array vars and he act according to that..

but i want to make something better then that.. maybe one of you have a nice idea about it?

whatever your response is, there is one thing i don't want to use
that is a Path routine.. i don't want that.. i want to ai to move according to level while looping it's Brain COMMANDS ..

maybe one of you can help me .. ty
ty for your time.
haliop.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Dec 2008 20:18
Make each tile's ID effect site.... like a form of collision for the 2d. Finding best path will be tricky without pathfinding - but you might consider DarkAI though - as it does alot of this out of the box kinda
--Jason

haliop
User Banned
Posted: 30th Dec 2008 21:30
yeah but thats excatly what i wanted to avoid..
using other library other then mine, thats not my way of coding..
now i know i'm talking big , as AI is mostly CODE and CODE and CODE

the tile idea is good.. is very good for me ty for that..
my thought about the Tile Base idea is:

if i make an Array such as

int Sight[5][5]
{
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
};

now a Zero will be the place that AI can't see
and a One where AI can see.
the positions of this array will rotate same as sprite in a
float Ai_Rotate kind of way.
so :

Sight[5][5]
{
0,0,0,0,1,
0,0,0,1,1,
0,0,1,1,1 P <<--AI position looking left
0,0,0,1,1,
0,0,0,0,1,
};

this way Ai actually look left, so the Sight Array will get information data , for where the Ai stands and where he looks.
think of an X Y about Sight. [Y][X] just actually the Tile Method.

now my thought is , how do i rotate it in a simple and fast way rother then CODE and Code and Code..

ty for your time..
i'm writing here .. so i won't forget it .. easily forgoten

p.s if you have a good way of how to rotate it pls
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Dec 2008 21:50 Edited at: 30th Dec 2008 21:55
You're Welcome

Rotating it? Nope. No Idea... but I'm not the math guru here - I do code really well and can write entire applications around a single formula - even if I don't understand the formula LOL.

Though the tiling idea is right on what I was thinking for your scenario. Not wanting DarkAI - I understand. It's a great product but it's also pretty involved to get going and writing it yourself will make you a master at your own AI - because you'll know every nook and cranny - all those "Don't rewrite the Wheel" nay sayers can fall off the planet - I learn more from studying others code then totally scrapping that and trying it myself - It might take me a bit longer - but in the end I'm much better off: I can spot trouble and fix quickly, I'm quick to be able to implement new ideas, I gain knowledge that I would have just passed by if I didn't do it myself

(Watch - someone will call me crazy LOL... won't be the first time)

Now - I'm not against using the right tool for the job - and I'm not against using the wrong tool for the job because it got me through something really easy compared to the alternatives LOL - that said...

One approach MIGHT be the 8 position sort of analysis... where you look North, South, East, West, North East, etc etc.... 8 directions - straight or diagonal... but if you want smoother (full 360 degree) AI... that isn't so PAC-MAN in moving... then I think our fixed tile approach is still a good base but the looking around bit requires floating point scalers. what comes to mind before you too think I'm crazy is ANTI-ALIASING. Yup - ANTI-ALIASING. Why? Think about how a 2-D line routine works. Think about how you can give two pairs of X,Y coordinates and a 2D line function will plot a line - regardless of where the two coordinates are - even off screen. Now think about Anti-Alias which is a way of addressing two points that are adjacent to where a prospective DOT wants to be but can't.. the dot is "fractioned" out - or rather - some of its "strength" is painted in one pixel, and the rest in the other... how do they know how much to colot ro blend of each? Floating point numbers... Math - Interpolation...

But that might be to exact and confusing - but worth a mention - I think in this case - the principle of a 2D Line Ploting function coupled with the math one would use in a 2D program to create a circle - would be the heart of what you're trying to do. Your "circle" center would be where you'r AI dude is, the "circle math" could be used to plot "vision" around your AI dude - and while examining each "DEGREE" (or possibly - more accurately - checking more than 360 degrees if the area being covered is very large) and you'd use the principle of the 2D Line Drawing to act as a ray trace... and if during the ray trace - the "tile" (our imaginary pixel in this case) has a player dude in it - before you run into a non-visual tile (a wall) then AHH HAAAA - KILL KILL KILL LOL

I know I'm a bit wordy at times - but does this spark some ideas for you?

--JAson

[edit] Also checking less than 360 degrees might be wise for performance reason. I'm vauge on the 2D Line Drawing stuff because some googles - shoot code snippets on this board discuss 2d line drawing... and the real trick - I used to know the forumula for but forget involves sine and cosine in a loop to plot the X,Ys for a circle. It wasn't all that hard but I'd have to experiment awhile to reconstitute it... and I know there has to be somewhere you can google a formula to plot a circle in 2d without a circle function doing it for you. Beside - we aren't actually drawing a circle or plotting a line - we are using the same principle so we can scan the tiles you laid out in a manner that replicates a baddy scanning his domain with digital eyes
[/edit]

haliop
User Banned
Posted: 30th Dec 2008 21:53
just wanted to fix something

Sight[5][5]
{
0,0,0,1,1,
0,0,1,1,1,
2,1,1,1,1 2<<--AI position ;looking RIGHT.
0,0,1,1,1,
0,0,0,1,1,
};


so i made a mistake before.. now its good.
still don't know how to rotate it in a good way.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Dec 2008 21:55
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Dec 2008 22:05
Oh - and you might want to add logic (not sure if it will make a difference or not) to avoid even looking in "tiles" already scanned but it might take just as long for that test as it would just checking the plotted line tiles just like mentioned above without trying to be efficient at it.

--JAson

haliop
User Banned
Posted: 30th Dec 2008 22:06
well thats an intersting approach about Anti Alising..
besides that it could actually be a very accurate method to find that float sight i'm looking for it might be just a bit too much for me as a noob programmer and it might be too much on CPU as Anti Alising takes alot of GPU /CPU time..
my thought now is:


build a Sight Array as before..
but, making it big like a circle here i'll show you:


int Sight [11][11]
{
0,0,0,0,0,1,0,0,0,0,0
0,0,0,0,1,1,1,0,0,0,0
0,0,0,1,1,1,1,1,0,0,0
0,0,1,1,1,1,1,1,1,0,0
0,1,1,1,1,1,1,1,1,1,0
1,1,1,1,1,P,1,1,1,1,1
0,1,1,1,1,1,1,1,1,1,0
0,0,1,1,1,1,1,1,1,0,0
0,0,0,1,1,1,1,1,0,0,0
0,0,0,0,1,1,1,0,0,0,0
0,0,0,0,0,1,0,0,0,0,0
}

so the P is the Player position inside the Grid
depending on its Rotation Angle still don't know how to do that good....
but depending on its Rotation Angle a 1 or a 0 will be in the Array[y][x]

so if it look right , the left side will be 0 0 0 0 0 0
now i still don't know of a way to rorate it currectly..
but thats where i am now.

jason if you have MSN my name nadavros1@gmail.com
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Dec 2008 22:11
Don't use MSN much, but your approach is sound and probably would be faster than my way but it doesn't solve the obstruction thing to well - as you'd be scanning things on both sides of a wall with that approach.

I truly think a 2d line plot coupled with a circle plotting formula would give you the closest representation of "eyes" scanning the horizon.

But - there are many ways to skin a cat... and who is this person who skins cats - and why is that a saying? LOL

--Jason

haliop
User Banned
Posted: 30th Dec 2008 22:30
well can you explain more the CIRCLE method, it sounds like a
RADAR, where AI position is the Axis and as he rotates a LINE will SCAN from certin degree to another.. now acordding to what the LINE "hits" a Tile Data is given to the Ai to Calculate and if hits a wall then the line ends there..

thats pretty good actually.. but i'm not the Math man..
haliop
User Banned
Posted: 30th Dec 2008 22:34
ok i'm uploading a picture file
that will explain as i see it
pls don't take the Array VARS as how it would be just an exaple
its pretty borring to do 0,1,01,10,10


well
i hope this can explain..
still no idea in the method on how to rotate it in a good way

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Dec 2008 22:59
LOL - Well - your pic describes what we're talking about. The circle and 2d Line plotting I think I will sign off and ask you to hunt that down.

I know for a fact there are code snippets in the code snippet forum that cover 2d plotting of lines, and I know the circle formula MUST be available somehwere... I mean its the fundamental example people give often on how you can use sin and cosine to help ya out.

The circle routine you'd call to get your next x,y point - just like you said.... LIKe RADAR LOL ... and you'd use the 2d plot line code to draw a line from player dude to the coordinates the circle routine hands ya.

Now rotating... if you want to rotate the player to a "hit" where it saw something it should turn to... just use the current circle "degree" value you just scanned compared to the player's direction degree. Take into account that greater than and less than is not enough - because of the wraparound that happens at due north... 360 = 0 degress... but ... You should be able to write some logic that can tell your player to turn left or right based on that degree info.

I'm not tryig to leave ya hanging but I have work I'm involved in here as well.

--Jason

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 30th Dec 2008 23:36
Here's a simple idea:

- Check distance from the AI to what they need to see

If distance is within reason (AI shouldn't be able to see unrealistically far away ) then:
- Determine the angle from the AI to what they need to see.
(dbAtanFull(Target.X - AI.X, Target.Y - AI.Y))

- Check if this angle is within the AI's "line of sight" arc. (usually defined by a certain amount of degrees from the direction the AI is facing)

- If the angle to the target is within the "line of sight" arc, then the AI can see it.


The one and only,


Login to post a reply

Server time is: 2024-09-30 13:32:23
Your offset time is: 2024-09-30 13:32:23