Пример #1
0
        public Snake(Snake parent, int newHeadPosition, bool incDim)
        {
            this.head  = newHeadPosition;
            this.world = parent.world;
            if (incDim)
            {
                if (parent.visitedDim == world.Dimentions)
                {
                    this.visitedDim = world.Dimentions;
                }
                else
                {
                    this.visitedDim = parent.visitedDim + 1;
                }
            }
            else
            {
                this.visitedDim = parent.visitedDim;
            }
            if (!world.ValidPosition(head))
            {
                throw new ArgumentException("Snake position is invalid");
            }
            this.tail = new int[parent.tail.Length + 1];
            for (int i = 0; i < parent.tail.Length; i++)
            {
                this.tail[i] = parent.tail[i];
            }
            this.tail[tail.Length - 1] = head;
//            this.Parent = parent;
            this.heuristicFunction = parent.heuristicFunction;
            this.hValue            = heuristicFunction.calc_h(this);
        }
Пример #2
0
 public Box(World world, int[] snakesStartLocations, IBoxHeuristic heuristicFunction,
            ISnakeHeuristic heuristicForSnakes)
 {
     this.world = world;
     snakes     = new Snake[snakesStartLocations.Length];
     for (int i = 0; i < snakesStartLocations.Length; i++)
     {
         snakes[i] = new Snake(world, snakesStartLocations[i], heuristicForSnakes, i == 0); //TODO: do we used imprune on one snake???
     }
     this.heuristicFunction = heuristicFunction;
     hValue = this.heuristicFunction.calc_h(this);
     calculateGValue();
 }
Пример #3
0
//        private LinkedList<INode> children;

        public Snake(World world, int head, ISnakeHeuristic heuristicFunction, bool useDim = true)
        {
            this.head       = head;
            this.world      = world;
            this.visitedDim = (useDim ?  0 : world.Dimentions);
            if (!world.ValidPosition(head))
            {
                throw new ArgumentException("Snake position is invalid");
            }
            this.tail = new int[1];
            this.tail[this.tail.Length - 1] = head;
//            this.Parent = null;
            this.heuristicFunction = heuristicFunction;
            this.hValue            = heuristicFunction.calc_h(this);
        }
Пример #4
0
 public BoxVirtualNode(World world, int numOfSnakes, IBoxHeuristic heuristicFunction,
                       ISnakeHeuristic heuristicForSnakes)
 {
     if (typeof(T) != typeof(BoxOD) && typeof(T) != typeof(BoxCartesian))
     {
         throw new ArgumentException("Bad type for BoxVirtualNode");
     }
     this.world              = world;
     f                       = 0;
     h                       = Int32.MinValue;
     g                       = 0;
     numberOfSnakes          = numOfSnakes;
     this.heuristicFunction  = heuristicFunction;
     this.heuristicForSnakes = heuristicForSnakes;
 }
Пример #5
0
 public void TestInitialize()
 {
     world         = new World(4, 2);
     heuristicFunc = new SnakeNoneHeuristic();
 }
Пример #6
0
 public BoxOD(World world, int[] snakesStartLocations, IBoxHeuristic heuristicFunction,
              ISnakeHeuristic heuristicForSnakes) : base(world, snakesStartLocations, heuristicFunction, heuristicForSnakes)
 {
     operatorIndex = 0;
 }
Пример #7
0
 public void TestInitialize()
 {
     world = new World(7, 2, 3);
     heuristicForSnakes = new SnakeNoneHeuristic();
     heuristicForBox    = new BoxNoneHeuristic();
 }
Пример #8
0
 public BoxCartesian(World world, int[] snakesStartLocations, IBoxHeuristic heuristicFunction,
                     ISnakeHeuristic heuristicForSnakes) : base(world, snakesStartLocations, heuristicFunction, heuristicForSnakes)
 {
 }