示例#1
0
 public void setImpassables(BitBoard walls)
 {
     if (walls.width == impassables.width && walls.height == impassables.height)
     {
         impassables = walls;
     }
 }
示例#2
0
 public GameBoardModel(int width, int height, BitBoard walls) : base(width, height)
 {
     if (walls.width == width && walls.height == height)
     {
         impassables = walls;
     }
     else
     {
         impassables = new BitBoard(gridWidth, gridHeight);
     }
 }
示例#3
0
        public static void Main(string[] args)
        {
            var myBoard = new GameBoardModel(5, 5);

            var pathAlg = new AstarSearch(myBoard);

            Location wall1 = new Location(0, 1);
            Location wall2 = new Location(1, 0);

            Stack    myPath  = new Stack();
            BitBoard myWalls = new BitBoard(5, 5);

            myWalls.setBits(true, wall1, wall2);

            Location a = new Location(0, 0);
            Location b = new Location(4, 4);

            Location c = new Location(3, 2);

            myBoard.setLocationWeight(c, 4);
            myBoard.setImpassables(myWalls);

            if (pathAlg.calculatePath(a, b, myPath))
            {
                while (myPath.Count != 0)
                {
                    Location temp = (Location)myPath.Pop();
                    Console.WriteLine(temp.X + ", " + temp.Y);
                }
            }
            else
            {
                Console.WriteLine("No path exists!");
            }

            return;
        }
示例#4
0
 public GameBoardModel(int width, int height) : base(width, height)
 {
     impassables = new BitBoard(gridWidth, gridHeight);
 }