Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

maxx2310

@maxx2310
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Shortest Path on Unweighted Edges
    M maxx2310

    Sorry Luc, your right I should have just explained what I was trying to do with the algorithm instead of the code. I am pretty much doing what your saying except for the keeping track of distance. Algorithm goes like this: 1. Place Start and End rooms into a start queue and end queue. 2. Enter a while loop with a condition not to leave while there is at least a Start or End Room loaded or that the destination is found. 3. I dequeue the room and iterate through each exit the room has and mark it as visited and load that room into the queue. 4. Repeat step 3 until I reach my destination or run out of rooms.

    Algorithms algorithms game-dev data-structures help question

  • Shortest Path on Unweighted Edges
    M maxx2310

    I am trying to develop a dynamic pathing algorithm for a game (all text) and running into an issue of finding the shortest path when all the edges(connectors) are the same cost or weight. The algorithm below will capture all the rooms from start to finish, but the issue is sorting it out to find the shortest distance to the finish, perhaps new algorithm is needed? Thanks in advance for any assistance.

    public void findRoute(ROOM_INFO startRoom, ROOM_INFO destinationRoom)
    {

            Dictionary visitedStartRooms = new Dictionary();
            Dictionary visitedStopRooms = new Dictionary();
    
            List directions = new List();
    
    
            startQueue.Enqueue(startRoom); // Queue up the initial room
            destinationQueue.Enqueue(destinationRoom);
    
            visitedStartRooms.Add(startRoom, true);// say we have been there, done that
            visitedStopRooms.Add(destinationRoom, true);
    
            string direction = "";
            bool foundRoom = false;
    
            while (startQueue.Count != 0 || destinationQueue.Count != 0)
            {
    
                ROOM\_INFO currentStartRoom = startQueue.Dequeue(); // remove room from queue to check out.
                ROOM\_INFO currentDestinationRoom = destinationQueue.Dequeue();
    
                ROOM\_INFO startNextRoom = new ROOM\_INFO();
                ROOM\_INFO stopNextRoom = new ROOM\_INFO();
    
                if (currentStartRoom.Equals(destinationRoom))
                {
                    foundRoom = true;
                    break;
                }
                else
                {
                    // Start from destination and work to Start Point.
                    foreach (string exit in currentDestinationRoom.exitData)
                    {
    
                        stopNextRoom = extractMapRoom(exit); // get adjacent room
                        if (stopNextRoom.Equals(startRoom))
                        {
                            visitedStopRooms.Add(stopNextRoom, true);
                            foundRoom = true;
                            break;
                        }
    
                        if (stopNextRoom.mapNumber != 0 && stopNextRoom.roomNumber != 0)
                        {
                            if (!visitedStopRooms.ContainsKey(stopNextRoom))
                            {
                                if (visitedStartRooms.Contai
    
    Algorithms algorithms game-dev data-structures help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups