private void AI(Unit u)
    {
	if (u.getAware() == true && u.getKilled() == false)
	{
	    
	    if (Model.getInstance().findUnitByID(LocalModel.getInstance().getMyPlayerID(), LocalModel.getInstance().getUnitTypeDeclaration()).getRoomX() == u.getRoomX() && Model.getInstance().findUnitByID(LocalModel.getInstance().getMyPlayerID(), LocalModel.getInstance().getUnitTypeDeclaration()).getRoomY() == u.getRoomY())
	    {
		int diffX = Model.getInstance().findUnitByID(LocalModel.getInstance().getMyPlayerID(), LocalModel.getInstance().getUnitTypeDeclaration()).getX() - u.getX();
		int diffY = Model.getInstance().findUnitByID(LocalModel.getInstance().getMyPlayerID(), LocalModel.getInstance().getUnitTypeDeclaration()).getY() - u.getY();
		
		double magnitude = Math.sqrt(diffX * diffX + diffY * diffY);
		
		if (u.getKeyheld() == false && u.getDefend() == true)
		{ // STOP DEFENDING???
		    int chance = generator.nextInt(10);
		    
		    if (chance < 3)
		    {
			u.setDefend(false);
			u.setPreventMovement(false);
			u.setKeyheld(true);
		    }
		}
		
		if (Math.abs(diffX) < 23 && Math.abs(diffY) < 23)
		{ // ATTACK OR DEFEND
		    int chance = generator.nextInt(10);
		    if (chance < 4 && u.getDefend() == false)
		    {
			
			u.setKeyheld(false);
			u.setAttack(true);
			u.setPreventMovement(true);
		    }
		    else
		    {
			u.setKeyheld(false);
			u.setDefend(true);
			u.setPreventMovement(true);
		    }
		    u.setXVel(0);
		    u.setYVel(0);
		}
		else
		{
		    if (u.getAttack() == true)
		    { // STOP ATTACK WHEN OUT OF RANGE
		    
			u.setAttack(false);
			u.setPreventMovement(false);
			u.setKeyheld(true);
		    }
		    if (u.getDefend() == true)
		    { // STOP DEFEND WHEN OUT OF RANGE
			u.setDefend(false);
			u.setPreventMovement(false);
			u.setKeyheld(true);
		    }
		    
		    if (u.getPreventMovement() == true)
		    {
			u.setXVel(0);
			u.setYVel(0);
		    }
		    else
		    {
			u.setXVel((int) ((diffX / magnitude) * (u.getSpeed() + 1.5)));
			u.setYVel((int) ((diffY / magnitude) * (u.getSpeed() + 1.5)));
		    }
		}
		
		if (u.getXVel() == 0 && u.getYVel() == 0)
		{
		    u.setKeyheld(false);
		    if (Math.abs(diffX) > Math.abs(diffY))
		    {
			if (diffX > 0)
			{
			    u.setDirection("R");
			}
			else
			{
			    u.setDirection("L");
			}
		    }
		    else
		    {
			u.setKeyheld(true);
			if (diffY > 0)
			{
			    u.setDirection("D");
			}
			else
			{
			    u.setDirection("U");
			}
		    }
		}
		else
		{
		    if (u.getXVel() > 0)
		    {
			u.setDirection("R");
		    }
		    else
		    {
			u.setDirection("L");
		    }
		    
		    if (u.getXVel() == 0)
		    {
			if (u.getYVel() > 0)
			{
			    u.setDirection("D");
			}
			else
			{
			    u.setDirection("U");
			}
		    }
		}
		
	    }
	    
	}
	else
	{ // PATROL AROUND
	
	    u.setDefend(false);
	    u.setAttack(false);
	    u.setPreventMovement(false);
	    
	    if (u.getX() < 157)
	    {
		u.setDirection("R");
	    }
	    if (u.getX() > 483)
	    {
		u.setDirection("L");
	    }
	    if (u.getY() < 270)
	    {
		u.setDirection("D");
	    }
	    if (u.getY() > 450)
	    {
		u.setDirection("U");
	    }
	    
	    int chance;
	    
	    if (u.getKeyheld() == false)
	    {
		chance = generator.nextInt(50);
	    }
	    else
	    {
		chance = generator.nextInt(1000);
	    }
	    
	    if (chance < 980)
	    {
		continueWalking(u);
		
	    }
	    else
	    {
		changeDirection(u);
	    }

	    if (u.getKilled() == false)
	    {
		checkForPlayer(u);
	    }
	}
	
	u.walk();
	u.setX(u.getX() + u.getXVel());
	u.setY(u.getY() + u.getYVel());
	
    }