コード例 #1
0
 public void removeQueenFrom(XYLocation l)
 {
     if (squares[l.GetXCoOrdinate(), l.GetYCoOrdinate()] == 1)
     {
         squares[l.GetXCoOrdinate(), l.GetYCoOrdinate()] = 0;
     }
 }
コード例 #2
0
 /**
  * Moves the queen in the specified column (x-value of <code>l</code>) to
  * the specified row (y-value of <code>l</code>). The action assumes a
  * complete-state formulation of the n-queens problem.
  */
 public void moveQueenTo(XYLocation l)
 {
     for (int i = 0; i < getSize(); ++i)
     {
         squares[l.GetXCoOrdinate(), i] = 0;
     }
     squares[l.GetXCoOrdinate(), l.GetYCoOrdinate()] = 1;
 }
コード例 #3
0
ファイル: XYEnvironment.cs プロジェクト: bclgenki/tvn-cosine
        //
        // PRIVATE METHODS
        //
        private bool withinRadius(int radius, XYLocation agentLocation, XYLocation objectLocation)
        {
            int xdifference = agentLocation.GetXCoOrdinate() - objectLocation.GetXCoOrdinate();
            int ydifference = agentLocation.GetYCoOrdinate() - objectLocation.GetYCoOrdinate();

            return(System.Math.Sqrt((xdifference * xdifference) + (ydifference * ydifference)) <= radius);
        }
コード例 #4
0
        public int getNumberOfAttacksOn(XYLocation l)
        {
            int x = l.GetXCoOrdinate();
            int y = l.GetYCoOrdinate();

            return(numberOfHorizontalAttacksOn(x, y) + numberOfVerticalAttacksOn(x, y) + numberOfDiagonalAttacksOn(x, y));
        }
コード例 #5
0
 /** Column and row indices start with 0! */
 public void addQueenAt(XYLocation l)
 {
     if (!(queenExistsAt(l)))
     {
         squares[l.GetXCoOrdinate(), l.GetYCoOrdinate()] = 1;
     }
 }
コード例 #6
0
ファイル: XYLocationTest.cs プロジェクト: tvn-cosine/aima.net
        public void testXYLocationAtributeSettingOnConstruction()
        {
            XYLocation loc = new XYLocation(3, 4);

            Assert.AreEqual(3, loc.GetXCoOrdinate());
            Assert.AreEqual(4, loc.GetYCoOrdinate());
        }
コード例 #7
0
        public bool isSquareUnderAttack(XYLocation l)
        {
            int x = l.GetXCoOrdinate();
            int y = l.GetYCoOrdinate();

            return(isSquareHorizontallyAttacked(x, y) || isSquareVerticallyAttacked(x, y) ||
                   isSquareDiagonallyAttacked(x, y));
        }
コード例 #8
0
        public void setBoard(ICollection <XYLocation> locs)
        {
            int count = 0;

            for (int i = 0; i < locs.Size(); i++)
            {
                XYLocation loc = locs.Get(i);
                this.setValue(loc.GetXCoOrdinate(), loc.GetYCoOrdinate(), count);
                count = count + 1;
            }
        }
コード例 #9
0
            private int evaluateManhattanDistanceOf(int i, XYLocation loc)
            {
                int retVal = -1;
                int xpos   = loc.GetXCoOrdinate();
                int ypos   = loc.GetYCoOrdinate();

                switch (i)
                {
                case 1:
                    retVal = System.Math.Abs(xpos - 0) + System.Math.Abs(ypos - 1);
                    break;

                case 2:
                    retVal = System.Math.Abs(xpos - 0) + System.Math.Abs(ypos - 2);
                    break;

                case 3:
                    retVal = System.Math.Abs(xpos - 1) + System.Math.Abs(ypos - 0);
                    break;

                case 4:
                    retVal = System.Math.Abs(xpos - 1) + System.Math.Abs(ypos - 1);
                    break;

                case 5:
                    retVal = System.Math.Abs(xpos - 1) + System.Math.Abs(ypos - 2);
                    break;

                case 6:
                    retVal = System.Math.Abs(xpos - 2) + System.Math.Abs(ypos - 0);
                    break;

                case 7:
                    retVal = System.Math.Abs(xpos - 2) + System.Math.Abs(ypos - 1);
                    break;

                case 8:
                    retVal = System.Math.Abs(xpos - 2) + System.Math.Abs(ypos - 2);
                    break;
                }
                return(retVal);
            }
コード例 #10
0
ファイル: TicTacToeState.cs プロジェクト: bclgenki/tvn-cosine
 public void mark(XYLocation action)
 {
     mark(action.GetXCoOrdinate(), action.GetYCoOrdinate());
 }
コード例 #11
0
 public bool queenExistsAt(XYLocation l)
 {
     return(queenExistsAt(l.GetXCoOrdinate(), l.GetYCoOrdinate()));
 }
コード例 #12
0
 public int getValueAt(XYLocation loc)
 {
     return(getValueAt(loc.GetXCoOrdinate(), loc.GetYCoOrdinate()));
 }