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 void DecideWhetherAnnounceWentOut(CommsEvent comms)
        {
            if (Me.Strategy == StrategyEnum.AI)
            {
                // covers both lies and truths

                var keepMouthShut = false;
                var accuse        = false;

                if (comms.Whom != null && LastNightAnnouncedSleep.Contains(comms.Whom.Id))
                {
                    // they went out, and lied about it [or we're claiming they lied about it] - do we accuse?
                    // But careful not to rat out (or falsely accuse) an accomplice
                    if (Me.IsVampire)
                    {
                        if (Relation(comms.Whom.Id).KnownVampire)
                        {
                            keepMouthShut = true;
                        }
                        else if (Relation(comms.Whom.Id).Enmity > 1 + 3 * r.NextDouble())
                        {
                            accuse = true;
                        }
                        else if (Relation(comms.Whom.Id).GussedBites > 1.5 + 1 * r.NextDouble())
                        {
                            // also don't rat out a probable vampire
                            keepMouthShut = true;
                        }
                        else
                        {
                            accuse = true;
                        }
                    }
                    else
                    {
                        accuse = true;
                        // 'lied' comms redundant, as AI's detect discrepancy elsewhere

                        //var comms = new CommsEvent(Me, CommsTypeEnum.LiedAboutSleeping, lie, Me.Game.GetPlayer(announceWhom));
                        //Me.Game.AnnounceToAIs(comms);  redundant
                        //Me.Game.AddToLog(comms);
                    }
                }

                if (!keepMouthShut)
                {
                    if (comms.Where == null)
                    {
                        if (accuse)
                        {
                            Hub.AnnounceComms(Me.Game, comms, true);
                        }
                        else
                        {
                            SuspicionAgainstMeThisTurn -= .1;
                            Hub.AnnounceComms(Me.Game, comms);
                        }
                    }
                    else
                    {
                        if (accuse)
                        {
                            Hub.AnnounceComms(Me.Game, comms, true);
                        }
                        else
                        {
                            SuspicionAgainstMeThisTurn -= .1;
                            Hub.AnnounceComms(Me.Game, comms);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void ReceiveWatchResult(bool stayedAtHome, IEnumerable <string> met)
        {
            LastNightMet = met;
            LastNightKnownWentOut.AddRange(met);
            foreach (var m in met)
            {
                LastNightWentOutProbability[m] = 100;
                if (LastNightAnnouncedSleep.Contains(m))
                {
                    ProcessLie(m, CommsTypeEnum.LiedAboutSleeping, null, null);
                }
            }
            if (LastNightAction.Action == NightActionEnum.Watch || LastNightAction.Action == NightActionEnum.Bite)
            {
                var whomRelation = Relation(LastNightAction.Whom);

                // set suspicion based on observation
                //if (Me.IsVampire)
                //{
                if (stayedAtHome)
                {
                    whomRelation.DarkSideSuspicion -= .3;
                    LastNightKnownSlept.Add(LastNightAction.Whom);
                    LastNightWentOutProbability[whomRelation.PlayerId] = -100;
                }
                else
                {
                    LastNightKnownWentOut.Add(whomRelation.PlayerId);
                    LastNightWentOutProbability[whomRelation.PlayerId] = 100;
                    if (LastNightAnnouncedSleep.Contains(whomRelation.PlayerId))
                    {
                        // went out, and lied about it
                        whomRelation.DarkSideSuspicion += 5;
                        Trace(false, "Detect lie sus +5");
                    }
                    else
                    {
                        // went out, but didn't lie about it
                        whomRelation.DarkSideSuspicion += .2;
                    }
                }
                //}


                if (Me.Strategy == StrategyEnum.AI)
                {
                    // before going any futher:  never claim to know anything if we claimed we were staying home!
                    if (LastNightAnnouncedSleep.Contains(Me.Id))
                    {
                        return;
                    }

                    // work out whether/what to announce

                    bool lie = false;
                    if (Me.IsVampire && !met.Any())
                    {
                        if (r.Next(10) >= 5)
                        {
                            return;
                        }

                        if (r.Next(10) >= 7 || LastNightAction.Action == NightActionEnum.Bite)
                        {
                            lie = true;
                        }
                    }

                    var    announceWhom     = LastNightAction.Whom;
                    string alsoAnnounceWhom = null;


                    if (lie)
                    {
                        if (r.NextDouble() > .9)
                        {
                            stayedAtHome = false;
                            announceWhom = PickEnemy(-100);
                            if (announceWhom == null)
                            {
                                announceWhom = RandomNotMe();
                            }
                        }
                        else if (r.NextDouble() > .95 || LastNightAction.Action == NightActionEnum.Bite)
                        {
                            stayedAtHome = false;
                            announceWhom = RandomNotMe();
                        }
                        else
                        {
                            stayedAtHome = !stayedAtHome;
                        }

                        if (r.NextDouble() * 15 < Me.Game.CurrentTurn().Id + 5 - SuspicionAgainstMe)
                        {
                            alsoAnnounceWhom = PickEnemy(0);
                            if (alsoAnnounceWhom == announceWhom)
                            {
                                alsoAnnounceWhom = null;
                            }
                            if (Me.Game.JailedPlayer != null)
                            {
                                if (alsoAnnounceWhom == Me.Game.JailedPlayer.Id)
                                {
                                    alsoAnnounceWhom = null;
                                }
                            }
                        }
                        if (alsoAnnounceWhom != null)
                        {
                            var comms = new CommsEvent(Me, CommsTypeEnum.WentOut, true, Me.Game.GetPlayer(alsoAnnounceWhom), Me.Game.GetPlayer(LastNightAction.Whom));
                            DecideWhetherAnnounceWentOut(comms);
                        }
                    }
                    else
                    {
                        // not lying, so announce who we met
                        foreach (var m in met)
                        {
                            var comms = new CommsEvent(Me, CommsTypeEnum.WentOut, false, Me.Game.GetPlayer(m), Me.Game.GetPlayer(LastNightAction.Whom));
                            DecideWhetherAnnounceWentOut(comms);
                            //Hub.AnnounceComms(Me.Game, comms);
                        }
                    }
                    if (stayedAtHome)
                    {
                        //Hub.Send(Me.Game.GameId, Me.Id, Me.Game.GetPlayer(announceWhom).Name + " stayed at home");
                        var comms = new CommsEvent(Me, CommsTypeEnum.Slept, lie, Me.Game.GetPlayer(announceWhom));
                        if (!lie)
                        {
                            SuspicionAgainstMeThisTurn -= .1;
                        }
                        Hub.AnnounceComms(Me.Game, comms);
                    }
                    else
                    {
                        var comms = new CommsEvent(Me, CommsTypeEnum.WentOut, lie, Me.Game.GetPlayer(announceWhom), null);
                        DecideWhetherAnnounceWentOut(comms);
                    }
                }
            }
        }
Exemplo n.º 4
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);
        }