Advertisement
charlesg

OptimalPath

Aug 7th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.87 KB | None | 0 0
  1. package com.godlinggame.mapmodel;
  2.  
  3.  
  4. abstract public class OptimalPath
  5. {
  6. protected Map map = null;
  7.  
  8.  
  9.   public OptimalPath( Map map )
  10.   {
  11.     setMap( map );
  12.   }
  13.  
  14.   public void setMap( Map map )
  15.   {
  16.     this.map = map;
  17.   }
  18.  
  19.  
  20.   public double stepCost( MapLocation ml ) { return stepCost( ml, 0 ); }
  21.   public double stepCost( int x, int y, double barrierWeight )
  22.   {
  23.     return stepCost( MapLocation.getLocation( x, y ), barrierWeight );
  24.   }
  25.   abstract public double stepCost( MapLocation ml, double barrierWeight );
  26.  
  27.   abstract public void clearPath();
  28.   abstract public void addGoalPosition( MapLocation add );
  29.   public void addGoalPositions( MapLocation add, int xwidth, int ywidth )
  30.   {
  31.     for (int i=0; i<xwidth; i++)
  32.       for (int j=0; j<ywidth; j++)
  33.         addGoalPosition( add.move( i, j ) );
  34.   }
  35.  
  36.   abstract public void recomputePath();
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement