public void PrintBoard(TileBoard b) { //Print the board state out Console.WriteLine("Board State:"); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { Console.Write(b.getBoard()[i, j].getValue() + " "); } Console.Write("\n"); } }
public List <TileBoard> getNeighbors(TileBoard board) { List <TileBoard> neighbors = new List <TileBoard>(); string lastMove = board.getLastMove();//prevent moving back and forth if (lastMove != "U" & board.xPosition[0] != 4) { neighbors.Add(board.moveTile("D")); } if (lastMove != "L" & board.xPosition[1] != 4) { neighbors.Add(board.moveTile("R")); } int posx = board.xPosition[1]; int posy = board.xPosition[0]; if (lastMove != "D" & board.xPosition[0] != 0) { TileNode node = board.getBoard()[posx, posy - 1]; if (!node.isLocked()) { neighbors.Add(board.moveTile("U")); } } if (lastMove != "R" & board.xPosition[1] != 0) { TileNode node = board.getBoard()[posx - 1, posy]; if (!node.isLocked()) { neighbors.Add(board.moveTile("L")); } } return(neighbors); }
public bool compareBoards(TileBoard a, TileBoard b) { //could use a search algorithm here to speed it up? bool match = true; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (a.getBoard()[i, j].getValue() != b.getBoard()[i, j].getValue()) { match = false; break; } } if (!match) { break; } } return(match); }