public boolean BFS() throws MyOutOfMemoryException, MyOutOfTimeException {
		stat.nodesCreated = 0;
		stat.totalTime = System.currentTimeMillis();
		
		ArrayDeque<Node> fringe = new ArrayDeque<Node>();
		fringe.add(new Node(board));
		while (!fringe.isEmpty()) {
			Node node = fringe.remove();		//take first element out of queue
		//	System.out.println("Current node:" + node.toString());
			if (node.isSolution()) {
				result = node;
				stat.nodesInMemory = fringe.size();
				stat.totalTime = System.currentTimeMillis() - stat.totalTime;
				return true;
			}
			expand(node, fringe);		//add descendants to the end of a queue
			if (RESTRICTIONS) {
				if ((rt.totalMemory() - rt.freeMemory())/1048576 > MAX_MEMORY) {
					stat.nodesInMemory = fringe.size();
					stat.totalTime = System.currentTimeMillis() - stat.totalTime;
					throw new MyOutOfMemoryException();
				}
				if (System.currentTimeMillis() - stat.totalTime > MAX_TIME) {
					stat.nodesInMemory = fringe.size();
					stat.totalTime = System.currentTimeMillis() - stat.totalTime;
					throw new MyOutOfTimeException();
				}
			}
		}
		stat.nodesInMemory = fringe.size();
		stat.totalTime = System.currentTimeMillis() - stat.totalTime;
		return false;
	}