Esempio n. 1
0
    public Type GetNextSpawn(PodsData pods)
    {
        var   totalPods       = pods.OwnPods.Count;
        var   iRoleAssemblies = Reflection.RoleAssemblies; // todo
        float maxRatio        = 0f;
        Type  maxType         = null;

        foreach (var iRole in iRoleAssemblies)
        {
            var roleType = iRole.AsType();

            var currentRatio = pods.GetPodCollectionWithRole(roleType).Count / (float)totalPods;
            var goalRatio    = _rolesRatios[roleType];

            var prioritizeSpawn = goalRatio / currentRatio;

            //Debug.Print("["+roleType.Name+"] Current Ratio : " + currentRatio + " | Goal : " + goalRatio + " | Prioritized : "+ prioritizeSpawn);

            if (prioritizeSpawn > maxRatio)
            {
                maxRatio = prioritizeSpawn;
                maxType  = roleType;
            }
        }
        //Debug.Print("_");

        return(maxType);
    }
Esempio n. 2
0
 public Game(int myId, int playerCount, int zoneCount)
 {
     MY_ID      = myId;
     NB_PLAYERS = playerCount;
     ZoneCount  = zoneCount;
     map        = new Map(zoneCount);
     podsData   = new PodsData();
     ratios     = new Ratios();
     moves      = new Moves();
     roles      = new List <IRole>()
     {
         new Attacker(), new Defender(), new Explorer()
     };
 }
Esempio n. 3
0
    public void AttributeTargets(PodsData podsData, PrioritizedTargets targets, Map map)
    {
        var target           = targets.Collection.ElementAt(0).Key;
        var offset           = 0;
        var attackers        = podsData.GetPodCollectionWithRole(typeof(Attacker)).ToList();
        var nbTotalAttackers = attackers.Count;

        Debug.Print("total attackers : " + attackers.Count);
        targets.ForEachZone(zone =>
        {
            var nbPodsToAssign = (int)Math.Round(targets.GetPercent(zone) * nbTotalAttackers);
            if (offset + nbPodsToAssign < nbTotalAttackers)
            {
                attackers.GetRange(offset, nbPodsToAssign).ForEach(pod =>
                {
                    pod.AssignTarget(target);
                });
                offset += nbPodsToAssign;
                if (nbPodsToAssign == 0)
                {
                    attackers.GetRange(offset, 1).ForEach(pod =>
                    {
                        pod.AssignTarget(target);
                    });
                    offset += 1;
                }
                Debug.Print("[" + zone.Id + "] " + nbPodsToAssign + "         new offset : " + offset);
            }
        });

        /*
         * foreach (var pod in podsData.GetPodCollectionWithRole(typeof(Attacker)))
         * {
         *  if (pod.IsWaiting)
         *  {
         *      pod.Target = new Target(pod.Position, target);
         *      Debug.Print("Attribute attacker pod : "+pod.Position.Id+" target : " + targets.Collection.ElementAt(0).Key.Id);
         *  }
         *
         * }
         */
    }
Esempio n. 4
0
    public void AttributeTargets(PodsData podsData, PrioritizedTargets targets, Map map)
    {
        if (targets == null)
        {
            return;
        }
        var pods    = podsData.GetPodCollectionWithRole(typeof(Explorer));
        var waiters = pods.Where(p => p.IsWaiting).ToList();

        pods.ForEach(pod =>
        {
            /*
             * if (pod.IsWaiting)
             * {
             *  if (targets.Collection.Count == 0)
             *  {
             *      pod.Draft();
             *  }
             *  else
             *  {
             *      //here proxy
             *      var bestPlatZone = MaxPlatInNeighbors(pod.Position.Neighbors);
             *      if (bestPlatZone != null)
             *      {
             *          Debug.Print("Proxy : " + pod.Position.Id + "  ->   " + bestPlatZone.Id);
             *          pod.AssignTarget(bestPlatZone);
             *          targets.Remove(pod.Target.Dest);
             *      }
             *      else
             *      {
             *          var pathFound = GetPathToClosestNeutralZone(pod.Position, map);
             *          if (pathFound != null)
             *          {
             *              pod.AssignTarget(pathFound);
             *              targets.Remove(pod.Target.Dest);
             *          }
             *          else
             *          {
             *              Debug.Print("[Error] GetPathToClosestNeutralZone returned null for " + pod.Position.Id);
             *          }
             *      }
             *  }
             * }
             */
            if (targets.Collection.Count == 0 && pod.IsWaiting)
            {
                pod.Draft();
            }
            else
            {
                var bestPlatZone = MaxPlatInNeighbors(pod.Position.Neighbors);
                if (bestPlatZone != null)
                {
                    if (!pod.IsWaiting)
                    {
                        pod.RemoveTarget();
                    }
                    pod.AssignTarget(bestPlatZone);
                }
                else
                {
                    if (!pod.IsWaiting)
                    {
                        var destAssignedMission = pod.Target.Dest.AssignedMissions;
                        if (destAssignedMission.Count > 1)
                        {
                            FindAndAssignNextNeutralZone(targets, pod, map);
                        }
                    }
                    else
                    {
                        FindAndAssignNextNeutralZone(targets, pod, map);
                    }
                }
            }
        });
    }
Esempio n. 5
0
 public void AttributeTargets(PodsData podsData, PrioritizedTargets targets, Map map)
 {
 }