//Other functions that could be useful tplayers in general.
public class PLF
{
	public static int[] fillFeatures(boolean[][][] goodPos, boolean[][][] evilPos)
	{
		int[] features = new int[6];
		int count1;
		int count2;
		int count3;
		//First half
		for(int i = 0; i < 5; i ++)
		{
			for(int j = 0; j < 5; j++)
			{
				count1 = 0;
				count2 = 0;
				count3 = 0;
				for (int k = 0; k < 5; k++)
				{
					if (goodPos[i][j][k])
						count1 = count1 + 1;
					if (goodPos[i][k][j])
						count2 = count2 + 1;
					if (goodPos[k][i][j])
						count3 = count3 + 1;
				}
				if(count1 >= 3)
					features[count1 - 3]++;
				if(count2 >= 3)
					features[count2 - 3]++;
				if(count3 >= 3)
					features[count3 - 3]++;
			}
		}

		//Second half
		for(int i = 0; i < 5; i ++)
		{
			for(int j = 0; j < 5; j++)
			{
				count1 = 0;
				count2 = 0;
				count3 = 0;
				for (int k = 0; k < 5; k++)
				{
					if (evilPos[i][j][k])
						count1 = count1 + 1;
					if (evilPos[i][k][j])
						count2 = count2 + 1;
					if (evilPos[k][i][j])
						count3 = count3 + 1;
				}
				if(count1 >= 3)
					features[count1 - 3]++;
				if(count2 >= 3)
					features[count2 - 3]++;
				if(count3 >= 3)
					features[count3 - 3]++;
			}
		}
		return features;
	}

    public static int[] treeSearch(player person, boolean[][][] goodPos, boolean[][][] evilPos, int depth)
	{
		boolean foundPos = false;
		int[] bestMove = new int[3];
		boolean[][][] tempGoodPos = new boolean[5][5][5];
		double maxUtil = -10000;
		double tempUtil;

		for(int i = 0; i < 5; i++)
			for(int j = 0; j < 5; j++)
				for(int k = 0; k < 5; k++)
				{
					if (!(goodPos[i][j][k] || evilPos[i][j][k]))
					{
						copyBoard(tempGoodPos, goodPos);
						tempGoodPos[i][j][k] = true;
						if(!foundPos)
						{
							foundPos = true;
							maxUtil = person.getUtility(tempGoodPos, evilPos);
							bestMove[0] = i;
							bestMove[1] = j;
							bestMove[2] = k;
						}
						else
						{
							tempUtil = person.getUtility(tempGoodPos, evilPos);
							if (tempUtil > maxUtil)
							{
								maxUtil = tempUtil;
								bestMove[0] = i;
								bestMove[1] = j;
								bestMove[2] = k;
							}
						}
					}
				}
		return bestMove;
	}

	public static void copyBoard(boolean[][][] newB, boolean[][][] oldB)
	{
		for(int i = 0; i < 5; i++)
			for(int j = 0; j < 5; j++)
				for(int k = 0; k < 5; k++)
				{
					newB[i][j][k] = oldB[i][j][k];
				}
	}
}//end PLF
