/// <summary> /// A wrapper to launch a version of Hanabi where all players are of type 'Mod8HanabiPlayer' and use advanced logic to make plays in the game. /// </summary> /// <param name="deck"></param> /// <param name="printMoves"></param> /// <param name="printGameStatus"></param> /// <param name="players"></param> /// <returns></returns> public static HanabiGame Mod8Strategy(Mod8Settings settings, List <HanabiCard> deck = null, int players = 4, bool printGameStatus = false) { HanabiGame game = new HanabiGame(); game.Players = new List <HanabiPlayer>(); for (int i = 0; i < players; i++) { game.Players.Add(new Mod8HanabiPlayer(i) { Settings = settings }); } if (deck == null) { game.CreateDeck(); game.ShuffleDeck(); } else { game.SetDeck(deck); } game.DealCards(); while (!game.Ended) { (game.CurrentPlayer as Mod8HanabiPlayer).DoTurn(ref game); game.NextTurn(); if (printGameStatus) { Console.WriteLine(game); } } return(game); }
public static HanabiGame OGMod8Strategy(List <HanabiCard> deck = null, bool printMoves = false) { HanabiGame game = new HanabiGame(); for (int i = 0; i < game.PlayerCount; i++) { game.Players[i] = new OGMod8HanabiPlayer(i) { ShowPlays = printMoves }; } if (deck == null) { game.CreateDeck(); game.ShuffleDeck(); } else { game.Deck = deck.ToList(); } game.DealCards(); while (!game.Ended) { (game.CurrentPlayer as OGMod8HanabiPlayer).DoTurn(ref game); game.NextTurn(); if (printMoves) { Console.WriteLine(game); } } return(game); }
private static HanabiGame SetupGame(List <HanabiCard> deck) { HanabiGame game = new HanabiGame() { Deck = deck }; if (deck == null) { game.CreateDeck(); game.ShuffleDeck(); } game.DealCards(); return(game); }
public static HanabiGame RandomStrategy(List <HanabiCard> deck = null) { HanabiGame game = new HanabiGame() { Deck = deck }; if (deck == null) { game.CreateDeck(); game.ShuffleDeck(); } game.DealCards(); Random rng = new Random(); while (!game.Ended) { var player = game.CurrentPlayer; var playcard = player.Hand[rng.Next() % player.Hand.Count]; game.PlayCard(player, player.Hand.LastIndexOf(playcard)); } return(game); }
public static HanabiGame BasicCheatingStrategy(List <HanabiCard> deck = null) { HanabiGame game = new HanabiGame() { Deck = deck }; if (deck == null) { game.CreateDeck(); game.ShuffleDeck(); } game.DealCards(); while (!game.Ended) { var play = Logic.PreferredPlay(game, game.CurrentPlayer); if (play != null) { game.PlayCard(game.CurrentPlayer, game.CurrentPlayer.Hand.IndexOf(play)); } else { var discard = Logic.PreferredDiscard(game, game.CurrentPlayer); (HanabiCard c1, HanabiCard c2) = (new HanabiCard(discard.Number - 1, discard.Color), new HanabiCard(discard.Number - 2, discard.Color)); if (game.Players.Select(p => p.Hand).Count(h => h.ContainsCard(c1) || h.ContainsCard(c2)) >= 1 && game.HintsRemaining > 0) //If the cards necessary to play this one are in people's hands already. { game.HintsRemaining--; } else { game.DiscardCard(game.CurrentPlayer, game.CurrentPlayer.Hand.IndexOf(discard)); } } game.NextTurn(); } return(game); }