Thread: Handling pathfinding on different threads

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1 Handling pathfinding on different threads 
    Registered Member
    Join Date
    May 2017
    Posts
    67
    Thanks given
    15
    Thanks received
    28
    Rep Power
    51
    Just want some thoughts on if keeping path searching on a separate thread is smart. I think it's a great idea, and when the path is finalized, there is a callback that is executed:


    Code:
    pathSearchThread.executePath(new Node(3222, 3222, 0), new Node(3220, 3230, 0), (list) -> {
    	if (list.isEmpty()) {
    		player.message("I can't reach that!");
    	} else {
    		println("Oh yah, found my spot");
    	}
    });
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Feb 2019
    Posts
    3
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by Dragonsevery View Post
    Just want some thoughts on if keeping path searching on a separate thread is smart. I think it's a great idea, and when the path is finalized, there is a callback that is executed:


    Code:
    pathSearchThread.executePath(new Node(3222, 3222, 0), new Node(3220, 3230, 0), (list) -> {
    	if (list.isEmpty()) {
    		player.message("I can't reach that!");
    	} else {
    		println("Oh yah, found my spot");
    	}
    });
    Create the path in a different thread/routine, but do the verification before each step.
    Reply With Quote  
     

  3. #3  
    Appellate Moderator



    Join Date
    Jan 2009
    Posts
    5,655
    Thanks given
    1,070
    Thanks received
    3,368
    Rep Power
    5000
    Quote Originally Posted by AbyssRS View Post
    Create the path in a different thread/routine, but do the verification before each step.
    you don't need to verify each step when the server creates the route
    Reply With Quote  
     

  4. #4  




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    25
    Posts
    16,056
    Thanks given
    7,048
    Thanks received
    11,835
    Rep Power
    5000
    Quote Originally Posted by Spooky View Post
    you don't need to verify each step when the server creates the route
    you do when they actually start navigating - the world doesn't necessarily stay the same as when the path was calculated, e.g. doors closing on their path

    [Only registered and activated users can see links. ]
    Reply With Quote  
     


  5. #5  
    Textures developer

    Kris's Avatar
    Join Date
    Jun 2016
    Age
    21
    Posts
    3,435
    Thanks given
    582
    Thanks received
    2,091
    Discord
    Kris#1337
    Rep Power
    3087
    Quote Originally Posted by Spooky View Post
    you don't need to verify each step when the server creates the route
    Unless I'm misunderstanding you here, of course you do.
    The surroundings may very well change by the time the user walks over the tiles. A blocking object - e.g. barricade in castle wars - may have spawned on the predefined path by the time the player reaches it or anything similar.

    I wouldn't bother multithreading pathfinding. It creates more problems than it solves. Pathfinding, if properly optimized is already fast enough to a point where it is a non-issue, unless you're legitimately abusing it.
    If the game is designed to execute on a single thread, passing the consumables which are invoked/executed from another thread may not be all that ideal. You're effectively altering the logic of the player from another thread while the main one may just be processing it, creating problems you shouldn't have to worry over in the first place.
    Spoiler for sig too large:

    [Only registered and activated users can see links. ]

    Discord: Kris#1337
    Reply With Quote  
     


  6. #6  
    Registered Member
    Join Date
    Dec 2013
    Posts
    260
    Thanks given
    91
    Thanks received
    58
    Rep Power
    309
    Quote Originally Posted by Kris View Post
    Unless I'm misunderstanding you here, of course you do.
    The surroundings may very well change by the time the user walks over the tiles. A blocking object - e.g. barricade in castle wars - may have spawned on the predefined path by the time the player reaches it or anything similar.

    I wouldn't bother multithreading pathfinding. It creates more problems than it solves. Pathfinding, if properly optimized is already fast enough to a point where it is a non-issue, unless you're legitimately abusing it.
    If the game is designed to execute on a single thread, passing the consumables which are invoked/executed from another thread may not be all that ideal. You're effectively altering the logic of the player from another thread while the main one may just be processing it, creating problems you shouldn't have to worry over in the first place.
    I personally don't agree with path finding on the main thread and I think that you should be offloading to another thread. Path finding isn't cheap from my previous experiences.
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Jul 2015
    Posts
    667
    Thanks given
    239
    Thanks received
    312
    Discord
    Displee#5183
    Rep Power
    598
    Recently talked about it with some one else. It's not a bad idea.
    link removed
    Reply With Quote  
     

  8. #8  
    Textures developer

    Kris's Avatar
    Join Date
    Jun 2016
    Age
    21
    Posts
    3,435
    Thanks given
    582
    Thanks received
    2,091
    Discord
    Kris#1337
    Rep Power
    3087
    Quote Originally Posted by Kiissmyswagb View Post
    I personally don't agree with path finding on the main thread and I think that you should be offloading to another thread. Path finding isn't cheap from my previous experiences.
    It is not the cheapest process, but the problem is - 9/10 cases where you actually use intelligent pathfinding, you require the path to be available immediately. There is no point in passing calculations to another thread if you have to block this thread, waiting for the operation to complete.
    The only case where you could and realistically should execute it on another thread is within the MoveGameClick packet(walk packet basically, as people call). When receiving the packet, I immediately perform the calculations within the same netty thread and pass the result off to the main game thread when it's ready.
    The remaining cases are within combat or similar circumstances and those require you to know the path immediately.
    Spoiler for sig too large:

    [Only registered and activated users can see links. ]

    Discord: Kris#1337
    Reply With Quote  
     


  9. #9  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    22
    Posts
    1,341
    Thanks given
    2,649
    Thanks received
    585
    Discord
    Hc747#3886
    Rep Power
    604
    Quote Originally Posted by Dragonsevery View Post
    Just want some thoughts on if keeping path searching on a separate thread is smart. I think it's a great idea, and when the path is finalized, there is a callback that is executed:


    Code:
    pathSearchThread.executePath(new Node(3222, 3222, 0), new Node(3220, 3230, 0), (list) -> {
        if (list.isEmpty()) {
            player.message("I can't reach that!");
        } else {
            println("Oh yah, found my spot");
        }
    });
    Enjoy your data races :~/
    Spoiler for sig too large:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  10. Thankful users:


  11. #10  
    Registered Member
    Join Date
    May 2017
    Posts
    67
    Thanks given
    15
    Thanks received
    28
    Rep Power
    51
    Quote Originally Posted by Kris View Post
    Unless I'm misunderstanding you here, of course you do.
    The surroundings may very well change by the time the user walks over the tiles. A blocking object - e.g. barricade in castle wars - may have spawned on the predefined path by the time the player reaches it or anything similar.

    I wouldn't bother multithreading pathfinding. It creates more problems than it solves. Pathfinding, if properly optimized is already fast enough to a point where it is a non-issue, unless you're legitimately abusing it.
    If the game is designed to execute on a single thread, passing the consumables which are invoked/executed from another thread may not be all that ideal. You're effectively altering the logic of the player from another thread while the main one may just be processing it, creating problems you shouldn't have to worry over in the first place.

    The reason I've asked about this, is because finding a path from (x=3222, y=3222) to (x=3222, y=3230) sometimes takes between 15-17ms and more the longer the path. That's quite a bit if one hundred people are clicking at the same time, then the main thread is stalled by that amount of time until the path is found. If you're using it on your 'network thread', then the network thread is stalled by that time, and then you also have lag there.

    Quote Originally Posted by hc747 View Post
    Enjoy your data races :~/
    Well, of course I would have a lock for it. Lock and Semaphore. There's plenty of ways to synchronize things like this, so that isn't a problem
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Deleting objects on different heights
    By Oxygen in forum Help
    Replies: 0
    Last Post: 05-12-2009, 10:48 PM
  2. Items on 525 Thread Deleted?
    By Kok in forum Show-off
    Replies: 3
    Last Post: 04-22-2009, 05:29 PM
  3. Handling timer on the most efficient way
    By Meanz in forum RS2 Server
    Replies: 14
    Last Post: 02-07-2009, 07:39 PM
  4. Replies: 5
    Last Post: 01-27-2009, 03:01 AM
  5. DuhPK 7000+ downloads on different sites
    By Nickg23 in forum Downloads
    Replies: 12
    Last Post: 02-14-2008, 12:50 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •