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 / How to make 2D AI

Author
Message
vitinho444
13
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 12th Jul 2011 21:36
Hey guys, i was wondering how can i add to my 2D Game some AI to the CPU Controlled enemies.

When i say AI i mean like random walk, attack and stuff...

PS: I know the DarkAI but it just says 3D AI and the Demo doesnt Work.

Learning C++
VB6 Advanced: 4/5
VB.NET Advanced: 4/5
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 12th Jul 2011 23:46
I've used pseudo AI states for characters ie:



and so on... You can have a state following another controlling state so that if the player finishes moving forward then it will stop and do nothing for a bit before deciding to do something else.

The only limit to what you can do with AI states is your imagination.

Warning! May contain Nuts!
vitinho444
13
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 13th Jul 2011 01:28
ahh
so character.state = random number then it just does something for a certain time and then random again ?

hum i never see things like that xD

Nice nice, thanks a lot, but.. i never learn select case on C++ can u say the full thing or its just


switch (name)
case Me:
dbText (85723847364,39572349, "Vitinho444");

case You:
dbText (85723847364,39572349, "WLGfx");

case Wrapper:
dbText (85723847364,39572349, "DarkGDK");


?

Learning C++
VB6 Advanced: 4/5
VB.NET Advanced: 4/5
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Jul 2011 04:26 Edited at: 13th Jul 2011 04:27
http://en.wikipedia.org/wiki/Switch_statement

It's a very useful part of C/C++ and saves writing a hell of a lot of IF statements.

Warning! May contain Nuts!
Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 13th Jul 2011 10:04
Quote: "It's a very useful part of C/C++ and saves writing a hell of a lot of IF statements."


The main reason why you SHOULD use it, is because it is way better optimized and thus faster.

TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 13th Jul 2011 12:52 Edited at: 13th Jul 2011 13:00
Quote: "When i say AI i mean like random walk, attack and stuff... "


Hi vitinho444,

Looks like you have a solid grip on the Finite State Machine (FSMs) portion of your AI but need a Pathfinder or Waypoint System to navigate your FSM Bots. You can either code A* Pathfinding or implement a 3rd party lib like MicroPather. You could create navigation paths manually by placing waypoints in the level.

I wouldn't encourage using random values to trigger actions. You can create a pretty effective event triggering system using basic collision detection algos to activate state changes in your Bots. Raycasting and bounds collision are often used to give Bots a sense of Vision or Hearing. You can also place Triggers collision shapes in the level to trigger Bots when the player collides with them.

vitinho444
13
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 13th Jul 2011 13:12
@WLGfx and Red Eye
Big thanks to you guys

@Techlord
I dont understand the First Link so i think i will use the second one.

But what exactly does this?

Learning C++
VB6 Advanced: 4/5
VB.NET Advanced: 4/5

Login to post a reply

Server time is: 2024-05-23 09:28:44
Your offset time is: 2024-05-23 09:28:44