User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: Advance Pathfinding - need advice on approach

  1. #1
    No Products Registered

    Join Date
    Sep 2006
    Location
    Germany
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Advance Pathfinding - need advice on approach

    I'm working on a Malefiz Game and was wondering if anyone else uses adv. pathfinding obj. and maybe have another idea on how to solve this problem.



    Let's say the players current figure is the pink bold dot in the middle, and he rolled a 4. Those pink crosses are the target locations and the smalls dots are possible pathes. How would I do this without wasting too much CPU time?

    I would do a fastloop on all available fields and get the path to that location, marking the fields that are 4 turns away. I would end up with around a hundred loopsteps and also around a hundred target fields (most of them overlapping).

    Any idea to solve this faster, and or with another extension or without any? (an array is availabe already with the mapping)

  2. #2
    Clickteam Clickteam
    Anders's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Århus
    Posts
    3,456
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    I can see that each cell max has 3 neighbors. Try storing the fixed value of the neighboring cells in three different alterable values of the cell. When the player rolls 4, then continue visiting the neighbor cells "recirsively"'ish and place a marker where you can go on the fourth spot. That recursion can be a bit tricky to do in MMF2 maybe. Maybe storing the branches in some list to visit later. You just have to avoid visiting the spots from the direction which you already came.

  3. #3
    No Products Registered

    Join Date
    Sep 2006
    Location
    Germany
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    Do fixed values change on application start? Then I could write those into an array, but only if the do not change. Otherwise I would need a new loop and check the array for neighboring cells.

    I was thinking about a pathless approach by creating a detector one all 4 sides of the figure. Then on overlap condition with a field I would set direction and move the object on a grid by 1 field each time substracting from the number the player has rolled. On a junction I would create additional detectors with the number of steps left and destroy the current detector. Then when the value reaches 0, I create a destination object at the detector so that I have a destination the player can click on. Does that make sense?

    Then I could use the pathfinding object to move the figure from place A to B in a 4-way movement.

  4. #4
    No Products Registered

    Join Date
    Sep 2006
    Location
    Germany
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    I tried for like 3 hours yesterday to find a non pathfinding solution but without any real success. Visiting Cells and all this took a load of events, when I had like 60 event lines I canceled it and deleted those lines.

    So today I got the pathfinding to work. No big deal and it's instant on finding a path, at least on my machine. Now I have another issue which I solved but maybe someone has a better solution.

    What I do on pathfinding is that if the player selects a figure on the board it starts a loop. On this loop I let the extension find the path between the current selected player figure and each of the fields the figure can go to. Then I create markers (active obj) on those spots and set a value which holds the number of steps it took to go to that field. Then I compare the step value of those markers to the current roll the player made before and destroy all objects that are different. Leaving me only with the fields left that you could reach with the current roll.

    Thats fine. But now onto the gameplay. You have barricade blocks on the gamefield which prevents the player from moving over those. Only with a direct roll you can claim the field with your figure and then move the barricade to en empty field anywhere on the gamefield. However for the pathfinding this is a problem.

    I set those Barricade Cells to "NoPath" (which defines a no path field in the extension). There is really no alternative to this, at least what I was thinking of..

    The problem now is that when the player figure is the exact number of steps away from a barricade the extension cannot get a path because that field is an obstacle. Therefore it will not create a marker. You cannot really address the field as if you try and change the loop to support something like "no path is found -> do this" it will address all fields beyond the barricade creating more mess then helping.

    Now what I did is that I changed the gfx of the marker object to overlap top, bottom, left and right by a few pixels so I can detect for overlapping with barricades on neighboring cells.

    I changed the routine to show me only those markers that are lower or equal to my roll, destroying every other marker on the board. And then I compare to the roll - 1 value. So if a rolled 5 would enable my figure to move right on top of a barricade I start a loop on all markers and check those with value 4 (roll -1) for overlapping and if that is true it will create a new marker on top of the barricade.

    There is only one problem when figures get surrounded with multiple barricades my method will eventually fail as I only have one detector...

    Here is a picture that may help understand my babbling

    The green ones are markers, the pink one are new markers with the solution I currently have to detect a barricade.

    So back to the extension, im still on the learning process although I use it in another project for multiple enemies and it works nicely. This extension has so many features, maybe I have overlooked something. So any ideas would be appreciated. Thanks


  5. #5
    No Products Registered

    Join Date
    Jun 2006
    Location
    Land of raging rockets
    Posts
    1,231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    You said you loop through all nodes and check each for a path. Can't you check at that point, if there's a barricade on that node? If so, make the node passable, check for a path to it, then make it unpassable again. This way you only get paths onto barricades if they are the target of the move - then, if a path is found, check that the distance is exactly the what the player rolled. If that is the case, place your marker, if not, destroy it (or don't place it).
    Oh and.. your game is turn-based, so I wouldn't worry about looping too much. You will probably never notice.

    PS: Cool game I played it when I was a little kid!

  6. #6
    No Products Registered

    Join Date
    Sep 2006
    Location
    Germany
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    Well, I thought I could do it without doing each step in a loop checking for a barricade or not but this seems to be the only solution.

    I played this game on a website a few days ago and thought thats a good idea for a quick game to make. Well "quick" ...

    I will try your idea on the afternoon. Thanks!

  7. #7
    No Products Registered

    Join Date
    Sep 2006
    Location
    Germany
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    Sometimes the solution is so simple ...

    I just do the regular find path stuff, but treat barricade as obstacle therefore no path can be found beyond any barricade.

    Then I redraw the pathmap but do not map the barricades as obstacles. Instead I pathfind from the current figure to all barricades on the board and check if the current roll is equal to the steps it takes to each the barricade. If this is true I create the marker on top of the barricade.

    Problem solved

    I feel dumb now ...

  8. #8
    Forum Moderator

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,773
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    maVado, never feel dumb, as we all have questions. Glad you solved your issue.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  9. #9
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    Occam's razor! lol

    But as marvin said, don't feel dumb. I've done things in a really complicated way before only to find out I could have done it extremely easy another way

  10. #10
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Stephen's Avatar
    Join Date
    Aug 2008
    Location
    Montana
    Posts
    4,515
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Advance Pathfinding - need advice on approach

    Quote Originally Posted by Shawn
    But as marvin said, don't feel dumb. I've done things in a really complicated way before only to find out I could have done it extremely easy another way
    I have done this on several occasions. :blush:

    stephen1980
    _____________________________________________
    Nivram's Examples -Need extensions? Send me a PM.-


Page 1 of 2 1 2 LastLast

Similar Threads

  1. Looking for advice on custom pathfinding...
    By ezzypixel in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 9th March 2013, 07:04 PM
  2. Any ideas on how to approach this? Text size
    By Christian_Wheel in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 12th October 2011, 05:07 PM
  3. Best Approach for Universal Binary?
    By BHGames in forum iOS Export Module Version 2.0
    Replies: 5
    Last Post: 15th March 2011, 07:41 PM
  4. Simplest approach for saving game settings?
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 1st June 2008, 10:45 PM
  5. A question on how to approach a project.
    By Jikito in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 15th January 2008, 10:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •