Esempio n. 1
0
        // public override void SimulateRound(int round)
        // {
        //     if (ExplodeAt != round)
        //     {
        //         return;
        //     }
        //     if (HasBomb)
        //     {
        //         Bomb = null;
        //     }
        //     if (HasItem)
        //     {
        //         Item = null;
        //     }
        //     if (HasPlayer)
        //     {
        //         Player = null;
        //     }
        //     if (HasBox)
        //     {
        //         var boxContent = Box.Content;
        //         Box = null;
        //         if (boxContent != 0)
        //         {
        //             Item = new Item(boxContent);
        //         }
        //     }
        // }

        public override decimal SetExplodeAt(int direction, int range, int when, int bombOwner)
        {
            if (ExplodeAt == null)
            {
                ExplodeAt = new List <int>();
            }
            if (!ExplodeAt.Contains(when))
            {
                ExplodeAt.Add(when);
            }
            if (range == 0)
            {
                return(0m);
            }
            if (HasBox(when))
            {
                Box.ExistsUntil = when;
                Box.DestroyedBy = bombOwner;
                Item            = new Item(Box.Content, when + 1);
                return(1 / when);
            }
            if (HasItem(when))
            {
                Item.ExistsUntil = when;
                return(0m);
            }
            var fitness = 0m;

            if (HasBomb(when) && !Bomb.HasExploded)
            {
                Bomb.HasExploded = true;
                for (int i = 0; i < 4; i++)
                {
                    if (Neighbors[i] == null)
                    {
                        continue;
                    }
                    fitness += Neighbors[i].SetExplodeAt(i, Bomb.ExplosionRange, when, Bomb.Owner);
                }
            }
            else
            {
                if (Neighbors[direction] == null)
                {
                    return(0m);
                }
                fitness += Neighbors[direction].SetExplodeAt(direction, range - 1, when, bombOwner);
            }
            return(fitness);
        }
Esempio n. 2
0
 public override char GetIcon()
 {
     if (HasPlayer(0))
     {
         if (HasBomb(0))
         {
             return('P');
         }
         return('p');
     }
     if (HasBomb(0))
     {
         return('b');
     }
     if (HasItem(0))
     {
         return('i');
     }
     if (HasBox(0))
     {
         return('o');
     }
     return(ExplodeAt?.FirstOrDefault().ToString().ToCharArray()[0] ?? '-');
 }