Esempio n. 1
0
    private static List <int> recruit(DataPool worldData, TournamentProtocol.Level level, List <int> regionsWithinJurisdiction, bool highestRated)
    {
        List <int> potentialRecruits = new List <int>();

        foreach (int rIndex in regionsWithinJurisdiction)
        {
            foreach (int mIndex in worldData.Regions[rIndex].getRegionsManagerIndexes())
            {
                if (worldData.Managers[mIndex].Rank.Equals(level) && !worldData.Managers[mIndex].isBusy())
                {
                    potentialRecruits.Add(mIndex);
                }
            }
        }

        if (highestRated)
        {
            potentialRecruits = potentialRecruits.OrderByDescending(t => EvaluationProtocol.evaluateBoxer(worldData.Boxers[t])).ToList();
        }
        else
        {
            potentialRecruits = potentialRecruits.OrderByDescending(t => worldData.Managers[t].Priority).ToList();
        }

        return(potentialRecruits);
    }
Esempio n. 2
0
    private static void disposeAndRenewBoxer(ref DataPool worldData, int managerIndex)
    {
        float        currentManagerELO = worldData.Managers[managerIndex].ManagerELO;
        List <Boxer> boxers            = WorldBuilderProtocol.generateBoxerRecruits(ref worldData, worldData.Managers[managerIndex].TownIndex, currentManagerELO);

        int   bIndex = 0;
        float max    = 0.0f;

        for (int i = 0; i < boxers.Count; i++)
        {
            float boxerEval = EvaluationProtocol.evaluateBoxer(boxers[i], worldData.Managers[managerIndex].Preference);

            if (boxerEval > max)
            {
                max    = boxerEval;
                bIndex = i;
            }
        }

        worldData.Boxers.Add(boxers[bIndex]);

        worldData.Managers[managerIndex].recruitBoxer(worldData.Boxers.Count - 1);
        worldData.Managers[managerIndex].setRank(TournamentProtocol.Level.E);
        updateELO(ref worldData, managerIndex);
    }
Esempio n. 3
0
    public void logBoxerResults()
    {
        List <Manager> managers = worldData.Managers.OrderByDescending(m => EvaluationProtocol.evaluateBoxer(worldData.Boxers[m.BoxerIndex])).ToList();

        foreach (Manager m in managers)
        {
            worldData.Boxers[m.BoxerIndex].logBoxerStats(m.Rank);
        }
    }
Esempio n. 4
0
    private void balanceRank(TournamentProtocol.Level rank)
    {
        foreach (Region r in regions)
        {
            List <int> managerIndexes = r.getRegionsManagerIndexes().FindAll(index => managers[index].Rank.Equals(rank)).ToList();

            managerIndexes = managerIndexes.OrderByDescending(index => EvaluationProtocol.evaluateBoxer(boxers[managers[index].BoxerIndex])).ToList();

            if (managerIndexes.Count > 12)
            {
                managers[managerIndexes[0]].graduateRank();
            }
        }
    }
Esempio n. 5
0
    void Start()
    {
        worldData = new DataPool();

        WorldBuilderProtocol.createWorld(ref worldData, 220, 220);

        Manager manager = new Manager("Capn", "AT", 0, 155.0f, BoxerClass.Type.Bullseye);

        worldData.Managers.Add(manager);

        List <Boxer> boxers = WorldBuilderProtocol.generateBoxerRecruits(ref worldData, manager.TownIndex, 0);

        int   bIndex = 0;
        float max    = 0.0f;

        for (int i = 0; i < boxers.Count; i++)
        {
            float boxerEval = EvaluationProtocol.evaluateBoxer(boxers [i], worldData.Managers [0].Preference);

            Debug.Log(boxerEval);
            boxers [i].logBoxerStats();

            if (boxerEval > max)
            {
                max    = boxerEval;
                bIndex = i;
            }
        }

        worldData.Boxers.Add(boxers [bIndex]);
        manager.recruitBoxer(worldData.Boxers.Count - 1);

        for (int i = 0; i < 5; i++)
        {
            Debug.Log("Year " + (i + 1));
            for (int j = 0; j < 48; j++)
            {
                ManagerProtocol.executeWeek(ref worldData, 0);
                worldData.Boxers [manager.BoxerIndex].logBoxerStats();
            }
        }
    }
Esempio n. 6
0
    private List <int> recruit(TournamentProtocol.Level level, Vector2Int p1, bool highestRated)
    {
        List <int> potentialRecruits = new List <int>();

        int index = 0;

        foreach (Manager m in worldData.Managers)
        {
            Vector2Int p2 = worldData.Towns[worldData.Managers[index].TownIndex].Location;

            float distance = Mathf.Sqrt(Mathf.Pow((p2.x - p1.x), 2) + Mathf.Pow((p2.y - p1.y), 2));

            if (level.Equals(TournamentProtocol.Level.S))
            {
                if (m.Rank.Equals(level) && !m.isBusy())
                {
                    potentialRecruits.Add(index);
                }
            }
            else
            {
                if (distance < getDistanceFromLevel(level) && m.Rank.Equals(level) && !m.isBusy())
                {
                    potentialRecruits.Add(index);
                }
            }

            index++;
        }

        if (highestRated)
        {
            potentialRecruits = potentialRecruits.OrderByDescending(t => EvaluationProtocol.evaluateBoxer(worldData.Boxers[t])).ToList();
        }
        else
        {
            potentialRecruits = potentialRecruits.OrderByDescending(t => worldData.Managers[t].Priority).ToList();
        }

        return(potentialRecruits);
    }
Esempio n. 7
0
    private static void createManagerBasedOnTown(ref DataPool worldData, int townIndex, int regionIndex)
    {
        for (int j = 0; j < 2; j++)
        {
            List <BoxerClass.Type> typeList = BoxerClass.getTypeList();

            Manager manager = new Manager(
                worldData.generateFirstName(), worldData.generateLastName(), townIndex, generateRandomInt(145, 225), typeList[generateRandomInt(0, typeList.Count - 1)]);
            manager.Record.setELO(getEloFromRegion(worldData.Towns[townIndex].RegionLevel));
            manager.setupHomebase(ref worldData, true);
            worldData.Managers.Add(manager);

            List <Boxer> boxers = WorldBuilderProtocol.generateBoxerRecruits(ref worldData, manager.TownIndex, manager.Record.ELO);

            int   bIndex = 0;
            float max    = 0.0f;

            for (int i = 0; i < boxers.Count; i++)
            {
                float boxerEval = EvaluationProtocol.evaluateBoxer(boxers[i], worldData.Managers[worldData.Managers.Count - 1].Preference);

                if (boxerEval > max)
                {
                    max    = boxerEval;
                    bIndex = i;
                }
            }

            TournamentProtocol.Level boxerLevel = (TournamentProtocol.Level)generateRandomInt(0, (int)worldData.Towns[townIndex].RegionLevel);

            worldData.Boxers.Add(boxers[bIndex]);
            manager.recruitBoxer(worldData.Boxers.Count - 1);
            ManagerProtocol.updateELO(ref worldData, worldData.Managers.Count - 1);
            manager.upgradeFacilities(ref worldData);
            manager.setRank(boxerLevel);
            ageAndDevelop(ref worldData, worldData.Boxers.Count - 1, boxerLevel);

            worldData.Regions[regionIndex].addManager(worldData.Managers.Count - 1);
        }
    }