Esempio n. 1
0
    public override void Decide()
    {
        List <Looter> list = Player.units.ToList();

        if (Player.units.Where(x => x.unitType == 4).ToList().Count == 0)
        {
            Go(new Coordinate(0, 0), throttle);
            return;
        }
        else
        {
            Looter ClosestWreck = null;

            while (ClosestWreck == null)
            {
                ClosestWreck = ClosestUnit(list, 4);

                foreach (Looter l in Player.units.Where(x => x.playerId != -1).Where(x => x.unitType == 0))
                {
                    if (ClosestWreck == null || list.Count == 0)
                    {
                        ClosestWreck = Player.joueurs[0].units[1];
                        break;
                    }

                    if (ClosestWreck.DistanceFrom(l.position) < 200)
                    {
                        list.Remove(ClosestWreck);
                        ClosestWreck = null;
                    }
                }

                Console.Error.WriteLine(ClosestWreck);
            }

            if (ClosestWreck == null)
            {
                ClosestWreck = (Wreck)ClosestUnit(Player.units, 4);
            }

            int acc = (int)Utility.map(DistanceFrom(ClosestWreck.position), 500 / mass, 1000 / mass, 0, throttle);
            Go(ClosestWreck.position, Math.Max(0, acc));
        }
    }