コード例 #1
0
            public void GiveClue(ref HanabiGame game)
            {
                List <HanabiAction> evaluations = new List <HanabiAction>();

                foreach (OGMod8HanabiPlayer player in game.Players.Where(p => p != this))
                {
                    evaluations.Add(player.EvaluateHand(game));
                }
                int cluevalue = PosMod(evaluations.Select(e => e.ToMod8Value()).Sum(), 8);

                for (int i = 0; i < game.PlayerCount; i++)
                {
                    var player = game.Players[i];
                    if (player != this)
                    {
                        (game.Players[i] as OGMod8HanabiPlayer).SetActionFromClue(this, ref game, cluevalue);
                    }
                }
                game.GiveHint();
                this.NextAction = new HanabiAction(HanabiActionType.Hint, null, -1);
            }
コード例 #2
0
            /// <summary>
            /// Called when someone wants to give a clue on their turn.
            /// </summary>
            /// <param name="game"></param>
            public void GiveClue(ref HanabiGame game)
            {
                bool cluegiven = false;
                List <HanabiAction> evaluations = new List <HanabiAction>();

                foreach (Mod8HanabiPlayer player in game.Players.Where(p => p != this).OrderBy(p => p.ID))
                {
                    evaluations.Add(player.EvaluateHand(ref game));
                }

                int cluevalue             = PosMod(evaluations.Select(e => e.ToMod8Value()).Sum(), 8);
                List <HanabiAction> plays = evaluations.Where(a => a.Type == HanabiActionType.Play).ToList();

                if (!IsValidClue(ref game, cluevalue))
                {
                    game.BadClues++;
                    if (Settings.EnsureProperClues)
                    {
                        GeneralLieClue(ref game, game.NextPlayer as Mod8HanabiPlayer, plays, PosMod(cluevalue - (game.NextPlayer as Mod8HanabiPlayer).NextAction.ToMod8Value(), 8));
                        cluegiven = true;
                    }
                }

                List <HanabiCard> playcards = new List <HanabiCard>();

                for (int i = 0; i < game.PlayerCount; i++)
                {
                    var player = game.Players[i];
                    if (player != this)
                    {
                        (game.Players[i] as Mod8HanabiPlayer).SetActionFromClue(this, ref game, cluevalue);
                    }
                }
                hints[cluevalue]++;
                if (Settings.CollisionLying)
                {
                    var cluedplays = evaluations.Where(a => a.Type == HanabiActionType.Play).Select(a => a.Card).ToList();
                    var nextplayer = game.NextPlayer as Mod8HanabiPlayer;
                    if (nextplayer.NextAction.Type == HanabiActionType.Play)
                    {
                        var cluedplay = nextplayer.NextAction.Card;
                        foreach (HanabiCard card in cluedplays)
                        {
                            if (cluedplays.Count(c => c.Color == card.Color && c.Number == card.Number) >= 2 && nextplayer.NextAction.Card.Color == card.Color && nextplayer.NextAction.Card.Number == card.Number)
                            {
                                HanabiAction[] bad = { nextplayer.NextAction };
                                CollisionLieClue(ref game, nextplayer, plays, PosMod(cluevalue - nextplayer.NextAction.ToMod8Value(), 8));
                                cluegiven = true;
                                break;
                            }
                        }
                    }
                }
                if (Settings.PrintMoves && !cluegiven)
                {
                    Console.WriteLine($"Player {ID} gave a hint.");
                }
                //Once the hint has been decided, make sure the game uses up a hint
                game.GiveHint();
                this.NextAction = new HanabiAction(HanabiActionType.Hint, null, -1);
            }