Exemplo n.º 1
0
        public void ProcessComms(CommsEvent comm, bool isReprocess)
        {
            if (comm.Speaker == Me)
            {
                return;
            }
            // start mistrusting at suspicion > 0.5
            var trust = TrustThisTurn(comm.Speaker.Id);

            var whom = comm.Whom;

            var where = comm.Where;
            var subject = comm.Speaker;

            switch (comm.EventType)
            {
            case CommsTypeEnum.IWasBitten:
                // first, process public effect
                if (Me.IsInJail)
                {
                    SuspicionAgainstMeThisTurn -= trust * .5;                             // assume others have similar mistrust
                }

                // next process private conclusions


                if (LastNightAction.Whom == comm.Speaker.Id && LastNightAction.Action == NightActionEnum.Bite)
                {
                    // (irrelevant if we did the biting!  except maybe lie about it)
                    // don't try and accuse if we're already more under suspicion than the bite-ee
                    bool theyTrustMe = Relation(comm.Speaker.Id).DarkSideSuspicion + r.NextDouble() * 2 - r.NextDouble() * 3 > SuspicionAgainstMe;

                    // don't try and accuse if there was another observer who'd know that we can't possibly know
                    if (!isReprocess && theyTrustMe && !LastNightMet.Any() && r.NextDouble() > .5)
                    {
                        if (Me.Strategy == StrategyEnum.AI)
                        {
                            var falseAccuse = new CommsEvent(Me, CommsTypeEnum.LiedAboutBeingBitten, true, subject);
                            Me.Game.Hub.AnnounceComms(Me.Game, falseAccuse, true, comm.Whom.NameSpan + " lied! No possible suspects!");
                        }
                    }
                    return;
                }

                var worstSuspect = ProcessBiteInfo(comm.Speaker.Id, trust, comm);
                Trace(true, "Worst suspect divisor: " + worstSuspect.ToString("0.00"));
                // no more cryWolf at approx worst suspect = .7

                var cryWolfSusp = 3 / (worstSuspect + .8) - 2;
                if (cryWolfSusp < -.2)
                {
                    cryWolfSusp = -.2;
                }
                Relation(comm.Speaker.Id).DarkSideSuspicion += cryWolfSusp;
                Trace(true, "Cry-wolf addSusp: " + cryWolfSusp.ToString("0.00"));

                break;

            case CommsTypeEnum.Slept:
                if (LastNightMet != null && LastNightMet.Contains(comm.Whom.Id))
                {
                    ProcessLie(comm.Speaker.Id, CommsTypeEnum.GenericLie, comm.Whom + " went out!", comm);
                }
                else if (comm.Whom.Id != Me.Id)
                {
                    Relation(comm.Speaker.Id).SuspicionThisTurn -= .1;                             // trust for not-contradicted information

                    Relation(comm.Whom.Id).SuspicionThisTurn -= trust * .2;
                }
                else if (comm.Whom.Id == Me.Id)
                {
                    if (LastNightAction.Action != NightActionEnum.Sleep)
                    {
                        ProcessLie(comm.Speaker.Id, CommsTypeEnum.GenericLie, "I slept last night", comm);
                        // todo: one-per-turn negative enmity
                    }
                    else
                    {
                        Relation(subject.Id).SuspicionThisTurn -= .15;                                 // trust for correct information
                    }
                }
                else if (LastNightKnownSlept.Contains(comm.Whom.Id))
                {
                    ProcessTruth(comm);
                }
                break;

            case CommsTypeEnum.WentOut:
                if (comm.Whom.Id != Me.Id)
                {
                    // if contrary evidence, don't trust the report

                    var trustThisReport = trust;                             // ????  - MIstrustToMult(0 - LastNightWentOutProbability[comm.Speaker.Id]) + .5;
                    if (LastNightKnownSlept.Contains(comm.Whom.Id))
                    {
                        ProcessLie(comm.Speaker.Id, CommsTypeEnum.GenericLie, comm.Whom.NameSpan + " slept all night!", comm);
                    }
                    else if (LastNightMet.Contains(whom.Id) && where != null)
                    {
                        // we have hard evidence
                        if (LastNightAction.Whom == where.Id)
                        {
                            // truth
                            ProcessTruth(comm);
                        }
                        else
                        {
                            // lie
                            ProcessLie(subject.Id, CommsTypeEnum.GenericLie, subject.NameSpan + " lied! " + whom.NameSpan + " was at " + where.NameSpan + "'s", comm);
                        }
                    }
                    else if (LastNightAnnouncedSleep.Contains(whom.Id))
                    {
                        var accusedTrust = MIstrustToMult(Relation(whom.Id).DarkSideSuspicion);
                        // this is insetad of using CommsTypeEnum.LiedAboutSleeping:
                        LastNightWentOutProbability[whom.Id] += MIstrustToMult(Relation(subject.Id).DarkSideSuspicion - Relation(whom.Id).DarkSideSuspicion * .5) * .5;
                        Relation(whom.Id).SuspicionThisTurn  += trustThisReport - .1;
                        var accuserAddSusp = accusedTrust * .75 * (MIstrustToMult(LastNightWentOutProbability[whom.Id]));
                        Relation(subject.Id).SuspicionThisTurn += accuserAddSusp;
                        Trace(true, "Accused of sleep/went-out lying addSusp:" + (trustThisReport - .1).ToString("0.00"));
                        Trace(true, "Accuser of sleep/went-out lying addSusp:" + accuserAddSusp.ToString("0.00"));
                    }
                    else
                    {
                        Relation(subject.Id).SuspicionThisTurn -= .1;                                 // trust for not-yet-contradicted information
                        LastNightWentOutProbability[whom.Id]   += trust * .5;
                        var whomAddSusp = trustThisReport * .2;
                        Relation(whom.Id).SuspicionThisTurn += whomAddSusp;
                        Trace(true, "Heard went-out addSusp:" + whomAddSusp.ToString("0.00"));
                    }
                }
                else
                {
                    // claimed that I went out
                    if (LastNightAction.Action == NightActionEnum.Sleep)
                    {
                        ProcessLie(subject.Id, CommsTypeEnum.GenericLie, "I slept all night!", comm);
                    }
                    else
                    {
                        Relation(subject.Id).SuspicionThisTurn -= .15;                                 // trust for correct information
                    }
                }
                break;

            case CommsTypeEnum.WillSleep:
                Relation(subject.Id).SuspicionThisTurn -= .1;                         // trust for not-yet-contracted information
                LastNightAnnouncedSleep.Add(subject.Id);
                break;

            case CommsTypeEnum.LiedAboutSleeping:
                // processed elsewhere
                break;

            case CommsTypeEnum.LiedAboutBeingBitten:
                ProcessAccusation(subject.Id, whom.Id);
                break;

            case CommsTypeEnum.GenericLie:
                ProcessAccusation(subject.Id, whom.Id);
                break;
            }
        }
Exemplo n.º 2
0
        public NightFormModel GetNightInstruction(List <string> ids, int turnId)
        {
            var otherIds = ids.Where(x => x != Me.Id).ToList();

            // if it's the first night, ensure we have a relation object for each other player
            foreach (var id in otherIds)
            {
                var dummy = Relation(id);
            }

            var d = new NightFormModel()
            {
                ActorId = Me.Id
            };

            if (otherIds.Any())
            {
                d.Whom = RandomId(otherIds);

                if (Me.IsVampire)
                {
                    if (r.NextDouble() * 10 - r.NextDouble() * 5 < turnId)
                    {
                        d.Action = NightActionEnum.Bite;
                    }
                    else if (r.NextDouble() * 10 < 3)
                    {
                        d.Action = NightActionEnum.Watch;
                    }
                    else
                    {
                        d.Action = NightActionEnum.Sleep;
                    }
                }
                else
                {
                    if (r.NextDouble() * 10 < 5)
                    {
                        d.Action = NightActionEnum.Watch;
                    }
                    else
                    {
                        d.Action = NightActionEnum.Sleep;
                    }
                }

                if (d.Action == NightActionEnum.Bite)
                {
                    var maxTastiness = 0d;
                    foreach (var re in Relations.Where(x => otherIds.Contains(x.PlayerId)).Where(x => !x.KnownVampire))
                    {
                        var t = re.GussedBites;
                        if (t > 2.5)
                        {
                            t = 2.5;
                        }
                        t = t + r.NextDouble() * 2;

                        // if we think someone may already be a vampire, don't bite them
                        // todo: but it helps to know for sure they are.....
                        t -= MIstrustToMult(0 - re.DarkSideSuspicion);

                        if (t > maxTastiness)
                        {
                            maxTastiness = t;
                            d.Whom       = re.PlayerId;
                        }
                    }
                    Relation(d.Whom).KnownBites++;
                    Relation(d.Whom).GussedBites++;
                    if (Relation(d.Whom).KnownBites >= 3)
                    {
                        Relation(d.Whom).KnownVampire       = true;
                        Relation(d.Whom).Enmity            -= 2;
                        Relation(d.Whom).DarkSideSuspicion += 10;
                    }
                }
            }
            else
            {
                d.Action = NightActionEnum.Sleep;
            }

            if (d.Action == NightActionEnum.Sleep ||
                (
                    d.Action == NightActionEnum.Bite &&
                    r.NextDouble() * 5 - r.NextDouble() * 5 > SuspicionAgainstMe
                )
                )
            {
                if (Me.Strategy == StrategyEnum.AI)
                {
                    var isTrue = d.Action == NightActionEnum.Sleep;
                    var comms  = new CommsEvent(Me, CommsTypeEnum.WillSleep, !isTrue, Me);
                    SuspicionAgainstMe -= .1;
                    Hub.AnnounceComms(Me.Game, comms);
                    LastNightAnnouncedSleep.Add(Me.Id);
                }
            }
            LastNightAction = d;

            if (d.Action != NightActionEnum.Sleep)
            {
                // assuming someone might observe
                SuspicionAgainstMe += .2;
            }


            return(d);
        }