Esempio n. 1
0
        // Method for game loop thread.
        #region

        static void GameLoop()
        {
            while (!exitCheck)
            {
                // Loop through all agents to increase the player's points bank.
                for (uint i = 0; i < 10; i++)
                {
                    if (!agentObjsArr[i].isLocked)
                    {
                        if (agentObjsArr[i].count.value > 0)
                        {
                            MassiveNumber tempNumber = new MassiveNumber();

                            // Evaluate agents.
                            tempNumber.value = tempNumber.Add(agentObjsArr[i].pointsRate.Mult((agentObjsArr[i].count.value), agentObjsArr[i].count.echelon), agentObjsArr[i].pointsRate.echelon);
                            tempNumber.UpdateEchelon();

                            // Evaluate upgrades.
                            if (upgraObjsArr[i].count.value > 0)
                            {
                                tempNumber.value = tempNumber.Mult(upgraObjsArr[i].count.Mult(upgraObjsArr[i].incomeMultiplier, upgraObjsArr[i].count.echelon) + 1, 1);
                                tempNumber.UpdateEchelon();
                            }

                            gamePoints.value = gamePoints.Add(tempNumber.value, tempNumber.echelon);
                            gamePoints.UpdateEchelon();
                        }
                    }
                }

                RenderWindow.gamePoints = gamePoints;
                gamePoints.UpdateEchelon();

                lock (raceConditionLocker)
                {
                    // Attempt to update the console.
                    UpdateConsole();
                    SharedResource++;

                    // Attempt to unlock every locked agent.
                    UnlockAgents();
                }

                // Loop every second.
                Thread.Sleep(1000);
            }
        }
Esempio n. 2
0
        private uint OptimalItem()
        {
            uint          returnRow  = 0;
            MassiveNumber tempNumber = new MassiveNumber();

            tempNumber.echelon = 1;
            tempNumber.value   = -1;

            for (uint i = 0; i < rowCount; i++)
            {
                // Find the most cost efficient item.
                if (!agentIsLocked[i])
                {
                    // Divide each Agent's price by its income rate.
                    MassiveNumber calcNumber = new MassiveNumber();
                    calcNumber.value   = agentPrice[i].value;
                    calcNumber.echelon = agentPrice[i].echelon;

                    calcNumber.value = calcNumber.Div(agentPointsRate[i].value, agentPointsRate[i].echelon);
                    calcNumber.UpdateEchelon();

                    // If this is the shortest time to break even.
                    if ((!calcNumber.IsGreaterThan(tempNumber)) || tempNumber.value == -1)
                    {
                        returnRow          = i;
                        optimalIsAgent     = true;          // Side effect.
                        tempNumber.value   = calcNumber.value;
                        tempNumber.echelon = calcNumber.echelon;
                    }

                    // Do not consider upgrades for agents that do not exist.
                    if (agentCount[i].value > 0)
                    {
                        if (upgraCount[i].value < 3)
                        {
                            // Divide each Upgrade's price by its immediate income rate.
                            MassiveNumber calcNumber2 = new MassiveNumber();
                            calcNumber2.value   = upgraPrice[i].value;
                            calcNumber2.echelon = upgraPrice[i].echelon;

                            MassiveNumber UpgradeIncome = new MassiveNumber();
                            UpgradeIncome.value = agentCount[i].Mult(upgraIncomeMult[i] + 1, 1);
                            UpgradeIncome.UpdateEchelon();

                            calcNumber2.value = UpgradeIncome.Div(upgraPrice[i].value, upgraPrice[i].echelon);
                            calcNumber2.UpdateEchelon();

                            // If this is the shortest time to break even.
                            if (!calcNumber2.IsGreaterThan(tempNumber))
                            {
                                returnRow          = i;
                                optimalIsAgent     = false;     // Side effect.
                                tempNumber.value   = calcNumber2.value;
                                tempNumber.echelon = calcNumber2.echelon;
                            }
                        }
                    }
                }
            }

            return(returnRow);
        }
Esempio n. 3
0
        // Exponentiation operation:
        public MassiveNumber Pow(double argExponent)
        {
            // Instantiate and initialize variables.
            MassiveNumber returnNumber = new MassiveNumber();

            returnNumber.value   = 1;
            returnNumber.echelon = 1;

            MassiveNumber fractionNumber = new MassiveNumber();

            fractionNumber.value   = 1;
            fractionNumber.echelon = 1;

            double fractionExpo = argExponent % 1d;

            // If the exponent is not an integer.
            if (fractionExpo > 0)
            {
                fractionNumber.value   = this.value;
                fractionNumber.echelon = this.echelon;

                // (x*1,000) ^ y = (x)^y * (10^3)^y
                fractionNumber.value = Math.Pow(fractionNumber.value, fractionExpo);
                fractionNumber.UpdateEchelon();

                for (int i = 0; i < fractionNumber.echelon + 1; i++)
                {
                    fractionNumber.value *= Math.Pow(10, fractionExpo);
                    fractionNumber.UpdateEchelon();
                }
            }

            returnNumber.value   = this.value;
            returnNumber.echelon = this.echelon;

            // x^4 = ( x*x*x*x )
            if ((uint)argExponent > 1)
            {
                for (uint i = 1; i < (uint)argExponent; i++)
                {
                    returnNumber.value = returnNumber.Mult(this.value, this.echelon);
                    returnNumber.UpdateEchelon();

                    if (i < (uint)argExponent - 1)
                    {
                        returnNumber.echelon *= returnNumber.echelon;
                    }
                }
            }
            else
            {
                if ((uint)argExponent > 1)
                {
                    // Mult at least once
                    returnNumber.value = returnNumber.Mult(returnNumber.value, 1);
                    returnNumber.UpdateEchelon();
                }
            }

            // Mult whole exponentiated value to fractional exponentiated value.
            // This method is equivalent to:
            // x^4.5 = ( x*x*x*x ) * ( x^0.5 )

            if (argExponent >= 1)
            {
                if (fractionExpo > 0)
                {
                    returnNumber.value = returnNumber.Mult(fractionNumber.value, fractionNumber.echelon);
                }
            }
            else
            {
                returnNumber.value = fractionNumber.value;
            }

            returnNumber.UpdateEchelon();

            return(returnNumber);
        }