private bool EvalBoard_rec(LegacyPegMove move, List <HistoricalMove> pastMoves) { board.MakeAMove(move); HistoricalMove hist = null; if (pastMoves.Count == 0) { hist = new HistoricalMove(0, move); } else { hist = new HistoricalMove(pastMoves.Last().order + 1, move); } pastMoves.Add(hist); if (board.PegsLeft == 1) { return(true); } foreach (LegacyPegMove newMove in GetMovesOnBoard()) { if (EvalBoard_rec(newMove, pastMoves)) { return(true); } } pastMoves.Remove(hist); board.UndoAMove(move); return(false); }
private void _AddJumpToLocation(LegacyPegLocation loc, int toRow, int toCol) { if (loc.location.row == 2 && loc.location.col == 2 && toRow == 4 && toCol == 0) { return; } if (loc.location.row == 4 && loc.location.col == 0 && toRow == 2 && toCol == 2) { return; } if (loc.location.row == toRow && loc.location.col == toCol) { return; } LegacyPegMove move = new LegacyPegMove(); move.fromLocation = loc; move.toLocation = boardArray[toRow, toCol]; LegacyPegHole temp = move.CalcMiddle(); move.middleLocation = boardArray[temp.row, temp.col]; loc.places_can_jump_to.Add(move); }
public HistoricalMove(int count, LegacyPegMove m) { order = count; move = m; }
public void UndoAMove(LegacyPegMove move) { move.fromLocation.filled = true; move.middleLocation.filled = true; move.toLocation.filled = false; }