The Daily Click ::. Forums ::. Klik Coding Help ::. Pathfinding by the numbers
 

Post Reply  Post Oekaki 
 

Posted By Message

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
7th April, 2014 at 07/04/2014 17:30:19 -

Maybe I'm not thinking critically enough on this, but anyways, I have a level set up with certain rooms, the game only loads and displays the room that the player is currently in, each room has a corresponding number.

The AI is already capable of moving between rooms and it tracks their movement despite them not being on screen. However, I want one of the tasks for the AI to be able to think of a room they want to go to, and travel specifically to that room, taking the correct exits based on the rooms number.
For example, the layout goes something like this:
Image
EDIT: Dear photo, work damn you.

Edited by Chloe Sagal

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
8th April, 2014 at 08/04/2014 04:03:08 -

Well consider this. The rooms have 1-3 doors each, so there are a limited number of choices in each room. Simply assign numbers to each door in each room that would bring the player closer to the room with that number.

So for room 5 the door on the left could have the following numbers:
0,1,2,3,4,7
And the door at the top
6,9,8,10

Makes sense?

So if the AI is in room 5 and it wants to go to 8 then it would take the door at the top, and repeat these checks in each room.
You'll have to create a number list for each door in each room, but it should be pretty simple.

This is the easiest way I could think of based on what you've shown about the engine so far.

EDIT: You haven't told us why the AI needs to be able to find a specific room. Does the gameplay rely on it, or is it just there to make the AI appear to know where it's going? To give the same effect you could also just make the AI's movements random and have them select a random door, and never go back through a door they've just came from unless it's the only door in the room.

Edited by UrbanMonk

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
8th April, 2014 at 08/04/2014 18:41:55 -

Well, the randomized door method while not going back through the same room is an okay idea, but I can foresee that leading to the AI literally just going from end room to end room. The GOTO room method I want to employ not only has the use of having the AI have a specific goal in mind (including the remembering of specific items in said room), the game is also heavily based on light and sound as well, so if the AI hears a sound or can see light emitting from a certain room, the AI can move to or avoid that room.

I get your example, though it is a very hard coded way of doing things. I can think of a creative way to implement it, but it would also add an extra easily breakable element to the customization and production process, the way the levels are built, even the entire game is built, it would make things very clunky. I guess I could settle for it if I can't figure out how to implement something along the lines of an A* method (which everyone else is telling me about), I've just never done it and I can't seem to wrap my head around it.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
8th April, 2014 at 08/04/2014 22:18:18 -

In any case you're going to need a way to reference which rooms connect to which.
Here is another idea: nested loops.

The AI objects will need some values:
ID
CurrentRoomID
NewRoomID
And a string: (for storing a delimited list of the calculated movement path)
MoveQueue

And you'll need an object to store addition engine values:
AI_ID

Then do this:

if AI("CurrentRoomID") <> AI("NewRoomID") then
-
-Start loop "RoomCheck" (number of doors) times

On loop "RoomCheck"
AND
AI("ID")


Nevermind this'll take too long to type out. You should prolly do more research on pathfinding algorithms. The hard part will be translating it into MMF code. Or you could use my hardcoded method which accomplishes the same thing as a complex algorithm, but everything is recalculated instead.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click