public GameState getNextState(bool preserve, Card played, bool playRandom) { GameState newState = new GameState(players, turnIndex, trick, leadSuit, cardsPlayedInTrick); if (preserve) { if (played == null) { newState.getNextState(playRandom); } else { newState.getNextState(played); } } return(newState); }
private static bool playout(GameState state, int pIndex) { GameState playState = state.getNextState(true, null, true); while (!playState.gameOver()) { playState = playState.getNextState(true, null, true); } int bestScore = state.getBestScore(); return bestScore == pIndex; }
static void Main(string[] args) { GameState state = new GameState(); for (int i = 0; i < 52; i++) { state = state.getNextState(true, null, false); } state.printScores(); Console.ReadLine(); }
private static bool playout(GameState state, int pIndex) { GameState playState = state.getNextState(true, null, true); while (!playState.gameOver()) { playState = playState.getNextState(true, null, true); } int bestScore = state.getBestScore(); return(bestScore == pIndex); }
private static int getPlayouts(GameState state, Card card, int pIndex) { int wins = 0; if (state.gameOver()) return 0; GameState playState = state.getNextState(true, card, true); for (int i = 0; i < NUM_PLAYOUTS; i++) { if (playout(playState, pIndex)) wins++; } return wins; }
private static int getPlayouts(GameState state, Card card, int pIndex) { int wins = 0; if (state.gameOver()) { return(0); } GameState playState = state.getNextState(true, card, true); for (int i = 0; i < NUM_PLAYOUTS; i++) { if (playout(playState, pIndex)) { wins++; } } return(wins); }
public GameState getNextState(bool preserve, Card played, bool playRandom) { GameState newState = new GameState(players, turnIndex, trick, leadSuit, cardsPlayedInTrick); if (preserve) { if (played == null) { newState.getNextState(playRandom); } else { newState.getNextState(played); } } return newState; }