private static void Wait()
        {
            if (_plansLeft > 0 && !GetMyEffects().Any() && MyExplorer.Sanity <= 200)
            {
                int countPlayersAroundMe = Gameboard.GetOtherExplorers().Where(x => Gameboard.MyExplorer.GetDistanceTo(x) <= 2).Count();
                if (countPlayersAroundMe > 1)
                {
                    CastPlan();
                    return;
                }
            }
            if (_lightsLeft > 0 && !GetMyEffects().Any())
            {
                int countEnemiesAroundMe = Gameboard.GetActiveEnemies().Where(x => MyExplorer.GetDistanceTo(x) <= 5).Count();
                if (countEnemiesAroundMe > 2)
                {
                    CastLight();
                    return;
                }
            }

            Console.WriteLine(Actions.WAIT);
        }
Exemple #2
0
        public void CalculateScoreForEachField()
        {
            for (int col = 0; col < WIDTH; col++)
            {
                for (int row = 0; row < HEIGHT; row++)
                {
                    Fields[col, row].ResetScore();
                }
            }

            foreach (var entity in Entities.Where(x => x.ID != MyExplorer.ID))
            {
                if (entity.Type == Entity.EntityType.WANDERER)
                {
                    var mob   = (Wanderer)entity;
                    int score = -20;

                    if ((mob.CurrentState == Wanderer.State.SPAWNING && mob.TimeTillSpawn <= 2) || mob.CurrentState == Wanderer.State.WANDERING)
                    {
                        Fields[mob.X, mob.Y].AddScore(score);
                        IEnumerable <Field> neighbouring = GetNeighouringFields(entity, 1);
                        foreach (var field in neighbouring)
                        {
                            field.AddScore(score);
                        }
                    }
                }
                if (entity.Type == Entity.EntityType.SLASHER)
                {
                    var mob = (Slasher)entity;
                    if ((mob.CurrentState == Wanderer.State.SPAWNING && mob.TimeTillSpawn <= 2) || mob.CurrentState == Wanderer.State.WANDERING)
                    {
                        entity.Field.AddScore(-50);
                        IEnumerable <Field> neighbouring = entity.Field.GetNeighouringFields(1);
                        foreach (var field in neighbouring)
                        {
                            field.AddScore(-25);
                        }
                    }
                }
                if (entity.Type == Entity.EntityType.EXPLORER)
                {
                    foreach (var field in entity.Field.GetNeighouringFields(2))
                    {
                        field.AddScore(Game.SanityLossLonely - Game.SanityLossGroup);
                    }
                }
                if (entity.Type == Entity.EntityType.EFFECT_LIGHT)
                {
                    var effect = (Effect)entity;
                    foreach (var field in entity.Field.GetNeighouringFields(effect.Radius))
                    {
                        field.AddScore(1);
                    }
                }
                if (entity.Type == Entity.EntityType.EFFECT_PLAN)
                {
                    var effect = (Effect)entity;
                    foreach (var field in entity.Field.GetNeighouringFields(effect.Radius))
                    {
                        field.AddScore(2);
                    }
                }
                if (entity.Type == Entity.EntityType.EFFECT_SHELTER)
                {
                    var effect = (Shelter)entity;
                    entity.Field.AddScore(effect.RemainingEnergy * 5);
                }
            }

            Console.Error.WriteLine("BEST FIELDS");
            foreach (var field in Fields.Cast <Field>().OrderByDescending(x => x.Score).ThenBy(x => MyExplorer.GetDistanceTo(x)).Take(3))
            {
                Console.Error.WriteLine($"{field}: {field.Score} IsWall: {field.IsWall}");
            }

            //var closestWanderer
        }
        private static bool ShouldYell()
        {
            if (_yellsLeft > 0 && !GetMyEffects().Any())
            {
                int countPlayersAroundMe = Gameboard.GetOtherExplorers().Where(x => Gameboard.MyExplorer.GetDistanceTo(x) <= 1).Count();
                if (countPlayersAroundMe >= 1)
                {
                    bool newPlayerFound = GetOtherExplorers().Where(x => Gameboard.MyExplorer.GetDistanceTo(x) <= 1 && !AlreadyYelledPlayerIDs.Contains(x.ID)).Any();

                    int countEnemiesAroundMe = Gameboard.GetActiveEnemies().Where(x => MyExplorer.GetDistanceTo(x) <= 3).Count();
                    if (countEnemiesAroundMe >= 1)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }