Beispiel #1
0
		public void removeQueenFrom(XYLocation l) 
		{

			if (board[l.getXCoOrdinate(),l.getYCoOrdinate()] == 1) 
			{
				board[l.getXCoOrdinate(),l.getYCoOrdinate()] = 0;
			}
		}
Beispiel #2
0
        public override bool Equals(Object o)
        {
            XYLocation anotherLoc = (XYLocation)o;

            return((anotherLoc.getXCoOrdinate() == xCoOrdinate) && (anotherLoc
                                                                    .getYCoOrdinate() == yCoOrdinate));
        }
Beispiel #3
0
		public static int calculateSquareOfDistanceBetweenLocations(
			XYLocation loc1, XYLocation loc2) 
		{
			int xdifference = loc1.getXCoOrdinate() - loc2.getXCoOrdinate();
			int ydifference = loc1.getYCoOrdinate() - loc2.getYCoOrdinate();
			return (xdifference * xdifference) + (ydifference * ydifference);

		}
		public int evaluateManhattanDistanceOf(int i, XYLocation loc) 
		{
			int retVal = -1;
			int xpos = loc.getXCoOrdinate();
			int ypos = loc.getYCoOrdinate();
			switch (i) 
			{

				case 1:
					retVal = Math.Abs(xpos - 0) + Math.Abs(ypos - 1);
					break;
				case 2:
					retVal = Math.Abs(xpos - 0) + Math.Abs(ypos - 2);
					break;
				case 3:
					retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 0);
					break;
				case 4:
					retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 1);
					break;
				case 5:
					retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 2);
					break;
				case 6:
					retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 0);
					break;
				case 7:
					retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 1);
					break;
				case 8:
					retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 2);
					break;

			}
			return retVal;
		}
Beispiel #5
0
		private string whichPlayer(XYLocation loc)
		{
			string[] _whichRow = whichRow(loc.getYCoOrdinate());

			return (_whichRow[loc.getXCoOrdinate()]);
		}
Beispiel #6
0
		private bool isPlayer(string whichPlayer, XYLocation loc) 
		{
			string[] _whichRow = whichRow(loc.getYCoOrdinate());

			return (_whichRow[loc.getXCoOrdinate()].Equals(whichPlayer));
		}
Beispiel #7
0
		private bool isEmpty(XYLocation loc)
		{
			string[] _whichRow = whichRow(loc.getYCoOrdinate());

			return (_whichRow[loc.getXCoOrdinate()] == " ");
		}
Beispiel #8
0
		private bool isLegalPlace(XYLocation forPlace) 
		{
			if (forPlace.getXCoOrdinate() >= 0 && forPlace.getXCoOrdinate() < this.boardSize && forPlace.getYCoOrdinate() >= 0 && forPlace.getYCoOrdinate() < this.boardSize)
				return true;
			else return false;
		}
Beispiel #9
0
		public void mark(XYLocation loc, string symbol) 
		{
			string[] _whichRow = null;
			_whichRow = whichRow(loc.getYCoOrdinate());

			_whichRow[loc.getXCoOrdinate()] = symbol;
		}
Beispiel #10
0
		public int getValueAt(XYLocation loc) 
		{
			return getValueAt(loc.getXCoOrdinate(), loc.getYCoOrdinate());
		}
Beispiel #11
0
		public bool queenExistsAt(XYLocation l) 
		{

			return (queenExistsAt(l.getXCoOrdinate(), l.getYCoOrdinate()));
		}
Beispiel #12
0
		public void addQueenAt(XYLocation l) 
		{

			if (!(queenExistsAt(l)))
				board[l.getXCoOrdinate(),l.getYCoOrdinate()] = 1;
		}
Beispiel #13
0
		public int getNumberOfAttacksOn(XYLocation l) 
		{

			int x = l.getXCoOrdinate();
			int y = l.getYCoOrdinate();
			return numberOfHorizontalAttacksOn(x, y)
				+ numberOfVerticalAttacksOn(x, y)
				+ numberOfDiagonalAttacksOn(x, y);
		}
Beispiel #14
0
		public bool isSquareUnderAttack(XYLocation l) 
		{

			int x = l.getXCoOrdinate();
			int y = l.getYCoOrdinate();
			return (isSquareHorizontallyAttacked(x, y)
				|| isSquareVerticallyAttacked(x, y) || isSquareDiagonallyAttacked(
				x, y));
		}