Beispiel #1
0
        public clsWinTree(int _iInitialBalance, int _iNumBetsRemaining, int _iBetAmount, int _iTargetBalance)
        {
            iInitialBalance = _iInitialBalance;

            iBetAmount = _iBetAmount;

            rnd = new Random();

            iNumBetsRemaining = _iNumBetsRemaining;

            iTargetBalance = _iTargetBalance;

            lndHitTargetLeafNodes = new List <clsWinNode>();

            ndClosest = new clsWinNode(enWin.Loss, null, -1000, 0);

            iMinBet = int.Parse(ConfigurationManager.AppSettings["MinBet"]);

            iMaxBet = int.Parse(ConfigurationManager.AppSettings["MaxBet"]);

            iNumTargetLeafNodes = int.Parse(ConfigurationManager.AppSettings["NumTargetLeafNodes"]);

            Array aWins = Enum.GetValues(typeof(enWin));
            int   iWin  = (int)aWins.GetValue(aWins.Length - 2);

            iRandomMargin = Math.Abs(_iInitialBalance - _iTargetBalance) + iWin * iMaxBet; //int.Parse(ConfigurationManager.AppSettings["iRandomMargin"]);
        }
Beispiel #2
0
        public clsWinNode ndfnAddChild(enWin _winType)
        {
            clsWinNode ndChild = new clsWinNode(_winType, this, iBalance + (iBetAmount * (int)_winType), iBetAmount);

            lndChildren.Insert(0, ndChild);

            return(ndChild);
        }
Beispiel #3
0
 public clsWinNode(enWin _winType, clsWinNode _ndParent, int _iBalance, int _iBetAmount)
 {
     winType     = _winType;
     ndParent    = _ndParent;
     iBalance    = _iBalance;
     iBetAmount  = _iBetAmount;
     lndChildren = new List <clsWinNode>(Enum.GetValues(typeof(enWin)).Length);
 }
Beispiel #4
0
        private void fnTraverseWinSequence(clsWinNode _ndChild, List <clsWinNode> _lndWinSequence)
        {
            if (_ndChild == null)
            {
                return;
            }

            _lndWinSequence.Insert(0, _ndChild);

            fnTraverseWinSequence(_ndChild.ParentNode, _lndWinSequence);
        }
Beispiel #5
0
        public void fnGenerateTree(clsWinNode _ndParent, int _iNumBetsRemaining)
        {
            if (lndHitTargetLeafNodes.Count >= iNumTargetLeafNodes || Math.Abs(ndClosest.Balance - iTargetBalance) <= iMinBet)
            {
                return;
            }

            if (_iNumBetsRemaining < 0)
            {
                if ((_ndParent.Balance == iTargetBalance))
                {
                    lndHitTargetLeafNodes.Insert(0, _ndParent);
                }
                else if (Math.Abs(_ndParent.Balance - iTargetBalance) < Math.Abs(ndClosest.Balance - iTargetBalance))
                {
                    ndClosest = _ndParent;
                }

                return;
            }

            _iNumBetsRemaining--;

            int i = rnd.Next(0, iNoWinTypes);

            for (int j = i + iNoWinTypes; j <= (i + 2 * iNoWinTypes - 1); j++)
            {
                int k = j % iNoWinTypes == 0 ? -1 : j % iNoWinTypes;

                clsWinNode ndChild = _ndParent.ndfnAddChild((enWin)k);

                if (lndHitTargetLeafNodes.Count > 0 && (Math.Abs(ndChild.Balance - iTargetBalance) > _iNumBetsRemaining * iMinBet)) // --------------------------- CHECK THIS (distance from tgtbal)
                {
                    return;
                }

                fnGenerateTree(ndChild, _iNumBetsRemaining);
            }
        }
Beispiel #6
0
        public void fnGenerateRandomTree(clsWinNode _ndParent, int _iNumBetsRemaining)
        {
            if (_iNumBetsRemaining < 0)
            {
                lndHitTargetLeafNodes.Insert(0, _ndParent);

                return;
            }

            int   iChildBalance;
            enWin winType;

            do
            {
                winType       = enfnRandomEnum();
                iChildBalance = _ndParent.Balance + (_ndParent.BetAmount * (int)winType);
            } while (_iNumBetsRemaining > 0 && Math.Abs(iChildBalance - iTargetBalance) >= iRandomMargin); // ==== TWEAK ME!!! i'm dying

            clsWinNode ndChild = _ndParent.ndfnAddChild(winType);

            fnGenerateRandomTree(ndChild, --_iNumBetsRemaining);
        }