Advertisement
contr0l

Different Method of Pathfinding

Oct 8th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.51 KB | None | 0 0
  1. alias alph { if $1 isalpha { return $calc($asc($1) - 96) } | if $1 isnum { return $chr($calc($1 + 96)) } }
  2. alias a-path {
  3.   ; $1 needs to be current position, and $2 needs to be target destination.
  4.   var %a-curpos $1, %a-finalcount, %a-done
  5.  
  6.   if $1 && $2 && $1 != $2 {
  7.     goto varsetting
  8.  
  9.     :varsetting
  10.     ; number for the Letter Row for $1
  11.     var %a-1 $alph($left(%a-curpos,1))
  12.  
  13.     ; number for the Letter Row for $2
  14.     var %a-2 $alph($left($2,1))
  15.  
  16.     ; actual Number Row of $1
  17.     var %a-3 $remove(%a-curpos,$left(%a-curpos,1))
  18.  
  19.     ; actual Number Row of $2
  20.     var %a-4 $remove($2,$left($2,1))
  21.  
  22.  
  23.     if %a-1 < %a-2 {
  24.       var %a-direction-leftright right
  25.       if %a-3 > %a-4 { var %a-direction-updown up }
  26.       if %a-3 < %a-4 { var %a-direction-updown down }
  27.       if %a-3 == %a-4 { var %a-direction-updown none }
  28.     }
  29.     if %a-1 > %a-2 {  
  30.       var %a-direction-leftright left
  31.       if %a-3 > %a-4 { var %a-direction-updown up }
  32.       if %a-3 < %a-4 { var %a-direction-updown down }
  33.       if %a-3 == %a-4 { var %a-direction-updown none }
  34.     }
  35.     if %a-1 == %a-2 {
  36.       var %a-direction-leftright none
  37.       if %a-3 > %a-4 { var %a-direction-updown up }
  38.       if %a-3 < %a-4 { var %a-direction-updown down }
  39.     }
  40.  
  41.     ; Find sorrounding cells
  42.     var %a-cell-above $+($left(%a-curpos,1),$calc($remove(%a-curpos,$left(%a-curpos,1)) - 1))
  43.     var %a-cell-below $+($left(%a-curpos,1),$calc($remove(%a-curpos,$left(%a-curpos,1)) + 1))
  44.     var %a-cell-left $alph($calc($alph($left(%a-curpos,1)) - 1))
  45.     var %a-cell-right $alph($calc($alph($left(%a-curpos,1)) + 1))
  46.  
  47.  
  48.     ; cell check - if not land or restricted (no obstacle)
  49.  
  50.     ; **** This is where I'm confused, how to determine which way to go ****
  51.  
  52.     if $EPirate.Cell.Restricted(%a-cell-above) == $false {
  53.       if %a-direction-updown == up {
  54.         ; Now the general direction is up and the cell above isnt restricted. I should move to this cell, but...
  55.         ; what if the cell to the right is a shorter path and not restricted, and leftright direction variable is set to right,
  56.         ; then which way should I go. Up or Right?
  57.  
  58.         ; how do I figure which way to go
  59.         ; I may need to count the number of moves each way, but havent thought about this yet.
  60.       }
  61.     }
  62.  
  63.     ; put a 'goto varsetting' after I figure which is next cell to move to, to find next move.
  64.     ; BUT set %a-curpos to the next cell before goto varsetting
  65.  
  66.   }
  67.  
  68.   ; Once completely done, unset variables
  69.   :done
  70.   unset %a-*
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement