public Square getMove(GameState currentState, Date deadline) {
		try {
			if (deadline == null) {
				deadline = getDefaultTime();
			}

		} catch (NullPointerException e) {
			deadline = getDefaultTime();
		}
		
		if(tree == null)
			tree = new MiniMax(new MiniMaxNode(currentState, currentState.getScore(currentState.getCurrentPlayer())));
		else
		{
			try{
				//BufferedWriter out = new BufferedWriter(new FileWriter("output.txt", true));
				
				//out.write("\n---------------------------------------------------------------");
				//out.write("\ncount before setting a new head: " + tree.Count());
				
				try{
					tree.SetNewHead(new MiniMaxNode(currentState, 0));
				}
				catch(Exception e)
				{
					tree = new MiniMax(new MiniMaxNode(currentState, currentState.getScore(currentState.getCurrentPlayer())));
					//out.write("\n\nFailed to update head to: " + currentState.toString());
				}

				//out.write("\ncount after setting a new head: " + tree.Count());
				
				//out.close();
			} catch (Exception e)
			{
				System.out.println("CAUGHT ERROR: " + e.getMessage());
			}
		}

		Square nextMove = null;
		MiniMaxNode node = null;
		GameState bestBoard = null;
		
		//NEED TO FIND A BETTER WAY TO DO THIS!
		while(this.howMuchTimesLeft(deadline) > 500 && tree.GetEmptyParents().size() > 0)
		{
			node = tree.GetEmptyParents().get(0);
			
			AbstractSet<GameState> successors = ((GameState)node.GetObject()).getSuccessors();
			List<MiniMaxNode> children = new ArrayList<MiniMaxNode>();
			
			for(GameState state : successors)
			{
				children.add(new MiniMaxNode(state, heuristic(state, currentState)));
			}
			
			tree.SetChildren(node, children);

			bestBoard = ((GameState)tree.AlphaBetaSearch().GetObject());
			nextMove = bestBoard.getPreviousMove();
			//log("setting current best move: " + nextMove.toString());
			//log("time left: " + this.howMuchTimesLeft());
			this.registerCurrentBestMove(nextMove);
		}
		
		/* return the move that we have chosen */
		//log("Steve's player is moving to " + nextMove + " with a cost of: " + heuristic(bestBoard, bestBoard));
		log("Steve's player is moving to " + nextMove);
		return nextMove;
	}