private void AI()
	{
		if(aware == true && DungeonGame.mainPanel.panel.player.killed == false && killed == false)
		{

			if(player != null && DungeonGame.mainPanel.panel.room.roomX == roomX &&  DungeonGame.mainPanel.panel.room.roomY == roomY)
			{
				int diffX = DungeonGame.mainPanel.panel.player.getX() - x;
				int diffY = DungeonGame.mainPanel.panel.player.getY() - y;
	
				double magnitude = Math.sqrt(diffX * diffX + diffY * diffY);
	
				if(keyheld == false && defend == true)
				{ //STOP DEFENDING???
					int chance = generator.nextInt(10);
	
					if(chance < 3)
					{
						defend = false;
						preventMovement = false;
						keyheld = true;
					}
				}
	
	
					if(Math.abs(diffX) < 23 && Math.abs(diffY) < 23)
					{ //ATTACK OR DEFEND
						int chance = generator.nextInt(10);
						if(chance < 4 && defend == false)
						{
							keyheld = false;
							attack = true;
							preventMovement = true;
						}
						else
						{
							keyheld = false;
							defend = true;
							preventMovement = true;
						}
						xVel = 0;
						yVel = 0;
					}
					else
					{
						if(attack == true)
						{ //STOP ATTACK WHEN OUT OF RANGE
							attack = false;
							preventMovement = false;
							keyheld = true;
						}
						if(defend == true)
						{ //STOP DEFEND WHEN OUT OF RANGE
							defend = false;
							preventMovement = false;
							keyheld = true;
						}
	
						if(preventMovement == true)
						{
							xVel = 0;
							yVel = 0;
						}
						else
						{
							xVel = (int)((diffX/magnitude) * (speed + 1.5));
							yVel = (int)((diffY/magnitude) * (speed + 1.5));
						}
					}
	
	
	
	
				if(xVel == 0 && yVel == 0)
				{
					keyheld = false;
					if(Math.abs(diffX) > Math.abs(diffY))
					{
						if(diffX > 0)
						{
							direction = "R";
						}
						else
						{
							direction = "L";
						}
					}
					else
					{
						keyheld = true;
						if(diffY > 0)
						{
							direction = "D";
						}
						else
						{
							direction = "U";
						}
					}
				}
				else
				{
					if(xVel > 0)
					{
						direction = "R";
					}
					else
					{
						direction = "L";
					}
	
					if(xVel == 0)
					{
						if(yVel > 0)
						{
							direction = "D";
						}
						else
						{
							direction = "U";
						}
					}
				}

			}



		}
		else
		{ // PATROL AROUND

			defend = false;
			attack = false;
			preventMovement = false;


			if(x < 157)
			{
				direction = "R";
			}
			if(x > 483)
			{
				direction = "L";
			}
			if(y < 270)
			{
				direction = "D";
			}
			if(y > 450)
			{
				direction = "U";
			}

			int chance;
			if(keyheld == false)
			{
				chance = generator.nextInt(50);
			}
			else
			{
				chance = generator.nextInt(1000);
			}


			if(chance < 980)
			{
				continueWalking();

			}
			else
			{
				changeDirection();
			}


			if(chance / 2 < 24)
			{
				xVel = 0;
				yVel = 0;
			}

			if(killed == false)
			{
				checkForPlayer();
			}
		}
	}