Ejemplo n.º 1
0
    public List <IndividualCard> GetRandomizedOccupiedOrSelectabeCardList()
    {
        List <IndividualCard> selectableCards = GetOccupiedOrSelectableCards();

        RandFuncs.Shuffle(selectableCards);
        return(selectableCards);
    }
Ejemplo n.º 2
0
    void ShuffleWithMatches(int cardTypes)
    {
        CardHandler.s.SetUpGrid();

        List <int> myCards = new List <int> ();

        int totalCards = GS.a.gridSettings.gridSizeX * GS.a.gridSettings.gridSizeY;

        for (int i = 0; i < totalCards; i += 2)
        {
            int rand = Random.Range(0, cardTypes);
            rand++;
            myCards.Add(rand);
            myCards.Add(rand);
        }

        int[] finalList = myCards.ToArray();
        RandFuncs.Shuffle(finalList);

        int n = 0;

        for (int x = 0; x < GS.a.gridSettings.gridSizeX; x++)
        {
            for (int y = 0; y < GS.a.gridSettings.gridSizeY; y++)
            {
                CardHandler.s.allCards[x, y].cardType = finalList[n];
                n++;
            }
        }
    }
Ejemplo n.º 3
0
    public FastSample(params float[] initDistro)
    {
        distro = new float[initDistro.Length];
        float total = 0f;

        for (int i = 0; i < distro.Length; i++)
        {
            distro[i] = initDistro[i];
            total    += distro[i];
        }

        Debug.Log(string.Format("Distro: {0}", RandFuncs.Dump(distro)));


        mean = total / (float)distro.Length;

        Debug.Log(string.Format("Mean: {0}", mean));

        int[] sep = new int[distro.Length];

        int shortMarker = 0;
        int tallMarker  = sep.Length - 1;

        for (int i = 0; i < distro.Length; i++)
        {
            if (distro[i] < mean)
            {
                sep[shortMarker++] = i;
            }
            else
            {
                sep[tallMarker--] = i;
            }
        }

        Debug.Log(string.Format("Sep: {0}", RandFuncs.Dump(sep)));
        tallMarker++;

        Debug.Log(string.Format("Tall marker: {0}", tallMarker));


        aliases = new int[distro.Length];

        for (int i = 0; i < (sep.Length - 1); i++)
        {
            int   curr      = sep[i];
            float shortfall = mean - distro[curr];
            int   firstTall = sep[tallMarker];
            distro[firstTall] -= shortfall;
            aliases[curr]      = firstTall;

            if (distro[firstTall] < mean)
            {
                tallMarker++;
            }
        }

        aliases[sep[sep.Length - 1]] = sep[sep.Length - 1];
    }
Ejemplo n.º 4
0
    public GameObject getRandomItemInstance(Transform parent)
    {
        int        rand          = RandFuncs.Sample(distribution, (float)(normalItemProbability + itemOptions.Length - 1));
        Vector3    position      = new Vector3(parent.position.x, parent.position.y + 1, parent.position.z);
        GameObject resultingItem = (GameObject)Instantiate(itemOptions[rand], position, Quaternion.identity);

        resultingItem.transform.parent = parent;

        return(resultingItem);
    }
Ejemplo n.º 5
0
    private int getWeight()
    {
        int weight;

        if (diversity == 0)
        {
            weight = 0;
        }
        else if (diversity < 0.1)
        {
            weight = RandFuncs.Sample(new float[] { 0.9f, 0.05f, 0.05f });
        }
        else if (diversity < 0.2)
        {
            weight = RandFuncs.Sample(new float[] { 0.8f, 0.1f, 0.1f });
        }
        else if (diversity < 0.3)
        {
            weight = RandFuncs.Sample(new float[] { 0.7f, 0.2f, 0.1f });
        }
        else if (diversity < 0.4)
        {
            weight = RandFuncs.Sample(new float[] { 0.6f, 0.3f, 0.1f });
        }
        else if (diversity < 0.5)
        {
            weight = RandFuncs.Sample(new float[] { 0.5f, 0.35f, 0.15f });
        }
        else if (diversity < 0.6)
        {
            weight = RandFuncs.Sample(new float[] { 0.5f, 0.3f, 0.2f });
        }
        else if (diversity < 0.7)
        {
            weight = RandFuncs.Sample(new float[] { 0.45f, 0.35f, 0.20f });
        }
        else if (diversity < 0.8)
        {
            weight = RandFuncs.Sample(new float[] { 0.4f, 0.35f, 0.25f });
        }
        else if (diversity < 0.9)
        {
            weight = RandFuncs.Sample(new float[] { 0.35f, 0.35f, 0.3f });
        }
        else
        {
            weight = RandFuncs.Sample(new float[] { 0.33333f, 0.3333f, 0.3333f });
        }
        return(weight);
    }
Ejemplo n.º 6
0
    public int Next()
    {
        float rndVal   = RandFuncs.Rnd() * (float)distro.Length;
        int   slotNum  = Mathf.Min(Mathf.FloorToInt(rndVal), distro.Length - 1);
        float fracPart = (rndVal - (float)slotNum) * mean;

        if (fracPart < distro[slotNum])
        {
            return(slotNum);
        }
        else
        {
            return(aliases[slotNum]);
        }
    }
Ejemplo n.º 7
0
    void Start()
    {
        // Spawn the fully random hand (for Task 1-a)
        List <GameObject> fullyRandomHand = getRandomCardHand(5);

        if (fullyRandomHand != null)
        {
            spawnCards(fullyRandomHand, fullRandomHandPosition);
        }

        // Spawn the filtered random hand (for Task 1-b)
        CardFilter randomFilter = RandFuncs.randPick(possibleFilters);

        filterTextMesh.text = "Filtered Random Hand " + randomFilter.filterString + ":";
        List <GameObject> filteredRandomHand = getFilteredRandomCardHand(5, randomFilter);

        if (filteredRandomHand != null)
        {
            spawnCards(filteredRandomHand, filteredRandomHandPosition);
        }
    }
Ejemplo n.º 8
0
    public override IEnumerator MainLoop()
    {
        yield return(new WaitForSeconds(0.5f));

        IndividualCard curTarget = null;

        while (true)
        {
            List <IndividualCard> allCards = GetAllCards();
            RandFuncs.Shuffle(allCards);
            foreach (IndividualCard card in allCards)
            {
                if (card.currentSelectingPlayer != -1)
                {
                    curTarget = card;
                    break;
                }
            }

            if (curTarget == null)
            {
                yield return(new WaitForSeconds(reactionTime));

                continue;
            }

            yield return(MoveToPosition(curTarget));

            while (curTarget.currentSelectingPlayer != -1)
            {
                Activate(curTarget);
                ScoreBoardManager.s.AddScore(curTarget.currentSelectingPlayer, 0, -1, true);

                yield return(new WaitForSeconds(periodicAttackTime));
            }

            yield return(new WaitForSeconds(reactionTime));
        }
    }