public void DoTurn(ref HanabiGame game) { if (NextAction.Type == HanabiActionType.Play) { game.PlayCard(this, NextAction.CardIndex); NextAction.Type = HanabiActionType.Hint; NextAction.Card = null; NextAction.CardIndex = -1; CardPlayed(ref game); } else if ((NextAction.Type == HanabiActionType.Discard || NextAction.Type == HanabiActionType.Hint) && game.HintsRemaining > 0) { GiveClue(ref game); } else if (NextAction.Type == HanabiActionType.Discard && game.HintsRemaining == 0) { game.DiscardCard(this, NextAction.CardIndex); NextAction.Type = HanabiActionType.Hint; NextAction.Card = null; NextAction.CardIndex = -1; } else { game.DiscardCard(this, 0); NextAction.Type = HanabiActionType.Hint; NextAction.Card = null; NextAction.CardIndex = -1; } }
public void DoTurn(ref HanabiGame game) { if (this.NextAction.Type == HanabiActionType.Hint) { if (game.HintsRemaining == 0) { var discard = Hand[0]; game.DiscardCard(this, 0); if (game.IsDangerCard(discard)) { DangerCardDiscarded(ref game); } } else { GiveClue(ref game); } } else if (NextAction.Type == HanabiActionType.Play) { if (SeesCollision(ref game) && game.HintsRemaining > 0 && game.BombsUsed >= 2) { GiveClue(ref game); } else { game.PlayCard(this, NextAction.CardIndex); NextAction.Type = HanabiActionType.Hint; NextAction.Card = null; NextAction.CardIndex = -1; } } else // Must be discard { if (PlaysSeen(ref game) >= 2 && game.HintsRemaining > 0) { GiveClue(ref game); } else if (SeesCollision(ref game) && game.HintsRemaining > 0) { GiveClue(ref game); } else { game.DiscardCard(this, NextAction.CardIndex); if (game.IsDangerCard(NextAction.Card)) { DangerCardDiscarded(ref game); } NextAction.Type = HanabiActionType.Hint; NextAction.Card = null; NextAction.CardIndex = -1; } } }
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); }