public override void CalculateWinnings(CasinoNumberViewModel drawnNumber)
        {
            foreach (var bet in _LastBets)
                CalculateWinningsOnBet(bet, drawnNumber);

            if (Settings.NumberNegligenceBettingSettings.BetOnSameEndings && Settings.NumberNegligenceBettingSettings.WaitForRepetitionCount > 0)
            {
                if (_LastBets.All(cur => cur.Result == BetResultKind.Loss))
                {
                    _repetitionLossCount++;
                    if (_repetitionLossCount >= Settings.NumberNegligenceBettingSettings.AbortWaitOnLossCount)
                        WaitingOnRepetitionCount = 0;
                }
                else if (_LastBets.Any(cur => cur.Result == BetResultKind.Win))
                {
                    if (IsInBettingStreak)
                    {
                        WaitingOnRepetitionCount--;
                    }
                    else if (Settings.NumberNegligenceBettingSettings.WaitForRepetitionCount > 0)
                    {
                        _repetingNumbers.Clear();
                        WaitingOnRepetitionCount = Settings.NumberNegligenceBettingSettings.WaitForRepetitionCount;
                        foreach (var bet in _LastBets)
                            _repetingNumbers.Add(bet.Number);
                    }
                }
            }

            _LastBets.Clear();
        }
Example #2
0
        protected BetResultKind CalculateWinningsOnBet(BetViewModel bet, CasinoNumberViewModel curNumber)
        {
            if (bet == null)
                return BetResultKind.None;

            if (curNumber == null)
            {
                bet.Result = BetResultKind.Unclear;
            }
            else
            {

                bool isZero = RouletteHelper.IsNumberOfType(curNumber.Number, NumberKind.Zero);
                bool isRed = RouletteHelper.IsNumberOfType(curNumber.Number, NumberKind.Red);
                bool isBlack = RouletteHelper.IsNumberOfType(curNumber.Number, NumberKind.Black);
                bool isOdd = RouletteHelper.IsNumberOfType(curNumber.Number, NumberKind.Odd);
                bool isEven = RouletteHelper.IsNumberOfType(curNumber.Number, NumberKind.Even);
                bool isTo18 = RouletteHelper.IsNumberOfType(curNumber.Number, NumberKind.To18);
                bool isFrom19 = RouletteHelper.IsNumberOfType(curNumber.Number, NumberKind.From19);

                bool isWin = false;
                switch (bet.BetKind)
                {
                    case BettingKind.To18:
                        isWin = isTo18;
                        break;
                    case BettingKind.From19:
                        isWin = isFrom19;
                        break;
                    case BettingKind.Even:
                        isWin = isEven;
                        break;
                    case BettingKind.Odd:
                        isWin = isOdd;
                        break;
                    case BettingKind.Red:
                        isWin = isRed;
                        break;
                    case BettingKind.Black:
                        isWin = isBlack;
                        break;
                    case BettingKind.To18AltFrom19:
                        bool isLastNumberTo18 = RouletteHelper.IsNumberOfType(bet.LastNumber, NumberKind.To18);
                        isWin = (isTo18 == isLastNumberTo18);
                        break;
                    case BettingKind.EvenAltOdd:
                        bool isLastNumberEven = RouletteHelper.IsNumberOfType(bet.LastNumber, NumberKind.Even);
                        isWin = (isEven == isLastNumberEven);
                        break;
                    case BettingKind.RedAltBlack:
                        bool isLastNumberRed = RouletteHelper.IsNumberOfType(bet.LastNumber, NumberKind.Red);
                        isWin = (isRed == isLastNumberRed);
                        break;
                    default:
                        isWin = false;
                        break;
                }

                if (isWin)
                {
                    Statistics.WinningsAmount += bet.Amount;
                    Statistics.WinCount++;

                    bet.Result = BetResultKind.Win;
                }
                else
                {
                    Statistics.LossesAmount += bet.Amount;
                    Statistics.LossCount++;

                    bet.Result = BetResultKind.Loss;
                }
            }

            return bet.Result;
        }
Example #3
0
 public abstract void CalculateWinnings(CasinoNumberViewModel drawnNumber);
Example #4
0
        protected BetResultKind CalculateWinningsOnBet(NumberBetViewModel bet, CasinoNumberViewModel curNumber)
        {
            if (bet == null)
                return BetResultKind.None;

            if (curNumber == null)
            {
                bet.Result = BetResultKind.Unclear;
            }
            else
            {
                bool isWin = curNumber.Number == bet.Number;
                if (isWin)
                {
                    Statistics.WinningsAmount += bet.Amount * 35;
                    Statistics.WinCount++;

                    bet.Result = BetResultKind.Win;
                }
                else
                {
                    Statistics.LossesAmount += bet.Amount;
                    Statistics.LossCount++;

                    bet.Result = BetResultKind.Loss;
                }
            }

            return bet.Result;
        }
        private void CountStreaks(CasinoNumberViewModel number)
        {
            CountNumberNegligenceStreaks(number);
            CountRepetingNumbers();

            bool isZero = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Zero);
            bool isRed = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Red);
            bool isBlack = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Black);
            bool isOdd = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Odd);
            bool isEven = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Even);
            bool isTo18 = RouletteHelper.IsNumberOfType(number.Number, NumberKind.To18);
            bool isFrom19 = RouletteHelper.IsNumberOfType(number.Number, NumberKind.From19);

            DozenKind dozenKind = RouletteHelper.GetDozenKind(number.Number);
            ThirdKind thirdKind = RouletteHelper.GetThirdKind(number.Number);

            if (isZero)
            {
                ZeroCount++;

                if (ApplicationViewModel.Instance.Settings.ResetStreaksOnZero)
                {
                    //commit streaks
                    AddToSimpleStreakHistory(RedStreakCount, true);
                    AddToSimpleStreakHistory(BlackStreakCount, true);
                    AddToSimpleStreakHistory(OddStreakCount, true);
                    AddToSimpleStreakHistory(EvenStreakCount, true);
                    AddToSimpleStreakHistory(To18StreakCount, true);
                    AddToSimpleStreakHistory(From19StreakCount, true);
                    AddToSimpleStreakHistory(Alternating1818StreakCount, true);
                    AddToSimpleStreakHistory(AlternatingOddEvenStreakCount, true);
                    AddToSimpleStreakHistory(AlternatingRedBlackStreakCount, true);

                    AddToThirdsStreakHistory(Dozen1StreakCount, true);
                    AddToThirdsStreakHistory(Dozen2StreakCount, true);
                    AddToThirdsStreakHistory(Dozen3StreakCount, true);
                    AddToThirdsStreakHistory(Third1StreakCount, true);
                    AddToThirdsStreakHistory(Third2StreakCount, true);
                    AddToThirdsStreakHistory(Third3StreakCount, true);

                    //reset
                    ResetStreaks();
                }
                else
                {
                    AddZeroToThirdsStreakHistory(Dozen1StreakCount);
                    AddZeroToThirdsStreakHistory(Dozen2StreakCount);
                    AddZeroToThirdsStreakHistory(Dozen3StreakCount);
                    AddZeroToThirdsStreakHistory(Third1StreakCount);
                    AddZeroToThirdsStreakHistory(Third2StreakCount);
                    AddZeroToThirdsStreakHistory(Third3StreakCount);
                }

                return;
            }

            if (dozenKind == DozenKind.First)
                Dozen1StreakCount++;
            else
            {
                AddToThirdsStreakHistory(Dozen1StreakCount);
                Dozen1StreakCount = 0;
            }

            if (dozenKind == DozenKind.Second)
                Dozen2StreakCount++;
            else
            {
                AddToThirdsStreakHistory(Dozen2StreakCount);
                Dozen2StreakCount = 0;
            }

            if (dozenKind == DozenKind.Third)
                Dozen3StreakCount++;
            else
            {
                AddToThirdsStreakHistory(Dozen3StreakCount);
                Dozen3StreakCount = 0;
            }

            if (thirdKind == ThirdKind.First)
                Third1StreakCount++;
            else
            {
                AddToThirdsStreakHistory(Third1StreakCount);
                Third1StreakCount = 0;
            }

            if (thirdKind == ThirdKind.Second)
                Third2StreakCount++;
            else
            {
                AddToThirdsStreakHistory(Third2StreakCount);
                Third2StreakCount = 0;
            }

            if (thirdKind == ThirdKind.Third)
                Third3StreakCount++;
            else
            {
                AddToThirdsStreakHistory(Third3StreakCount);
                Third3StreakCount = 0;
            }

            if (isRed)
                RedStreakCount++;
            else
            {
                AddToSimpleStreakHistory(RedStreakCount);
                RedStreakCount = 0;
            }

            if (isBlack)
                BlackStreakCount++;
            else
            {
                AddToSimpleStreakHistory(BlackStreakCount);
                BlackStreakCount = 0;
            }

            if (isOdd)
                OddStreakCount++;
            else
            {
                AddToSimpleStreakHistory(OddStreakCount);
                OddStreakCount = 0;
            }

            if (isEven)
                EvenStreakCount++;
            else
            {
                AddToSimpleStreakHistory(EvenStreakCount);
                EvenStreakCount = 0;
            }

            if (isTo18)
                To18StreakCount++;
            else
            {
                AddToSimpleStreakHistory(To18StreakCount);
                To18StreakCount = 0;
            }

            if (isFrom19)
                From19StreakCount++;
            else
            {
                AddToSimpleStreakHistory(From19StreakCount);
                From19StreakCount = 0;
            }

            //Count alternating streaks
            if (LastNumber.HasValue)
            {
                bool isLastNumberZero = RouletteHelper.IsNumberOfType(LastNumber.Value, NumberKind.Zero);
                bool isLastNumberRed = RouletteHelper.IsNumberOfType(LastNumber.Value, NumberKind.Red);
                bool isLastNumberBlack = RouletteHelper.IsNumberOfType(LastNumber.Value, NumberKind.Black);
                bool isLastNumberOdd = RouletteHelper.IsNumberOfType(LastNumber.Value, NumberKind.Odd);
                bool isLastNumberEven = RouletteHelper.IsNumberOfType(LastNumber.Value, NumberKind.Even);
                bool isLastNumberTo18 = RouletteHelper.IsNumberOfType(LastNumber.Value, NumberKind.To18);
                bool isLastNumberFrom19 = RouletteHelper.IsNumberOfType(LastNumber.Value, NumberKind.From19);

                if (isLastNumberRed && isBlack ||
                    isLastNumberBlack && isRed)
                    AlternatingRedBlackStreakCount++;
                else
                {
                    AddToSimpleStreakHistory(AlternatingRedBlackStreakCount);
                    AlternatingRedBlackStreakCount = isZero ? 0 : 1;
                }

                if (isLastNumberOdd && isEven ||
                    isLastNumberEven && isOdd)
                    AlternatingOddEvenStreakCount++;
                else
                {
                    AddToSimpleStreakHistory(AlternatingOddEvenStreakCount);
                    AlternatingOddEvenStreakCount = isZero ? 0 : 1;
                }

                if (isLastNumberTo18 && isFrom19 ||
                    isLastNumberFrom19 && isTo18)
                    Alternating1818StreakCount++;
                else
                {
                    AddToSimpleStreakHistory(Alternating1818StreakCount);
                    Alternating1818StreakCount = isZero ? 0 : 1;
                }
            }
            else
            {
                if (isBlack || isRed)
                    AlternatingRedBlackStreakCount++;

                if (isEven || isOdd)
                    AlternatingOddEvenStreakCount++;

                if (isFrom19 || isTo18)
                    Alternating1818StreakCount++;
            }

            UpdateSimpleStreakCounts();
            UpdateThirdsStreakCounts();
        }
        private void CountNumberNegligenceStreaks(CasinoNumberViewModel number)
        {
            if (number == null)
                return;

            var curNumberEntry = _NumberNegligenceStreaks.FirstOrDefault(cur => cur.Number == number.Number);
            if (curNumberEntry != null)
                curNumberEntry.NegligenceCount = 0;

            foreach (var entry in _NumberNegligenceStreaks.Where(cur => cur.Number != number.Number))
                entry.NegligenceCount++;
        }
        private void AddToNumberCounts(CasinoNumberViewModel number)
        {
            if (number == null)
                return;

            var entry = NumberFrequency.FirstOrDefault(cur => cur.Number == number.Number);
            if (entry == null)
            {
                entry = new NumberFrequencyViewModel(number.Number);
                _NumberCounts.Add(entry);
            }

            entry.MaxCount++;
        }
        public void AddNumber(CasinoNumberViewModel number)
        {
            _NumberHistory.Insert(0, number.Number);
            LastNumberAsCollection = new List<CasinoNumberViewModel> { number };

            AddToNumberCounts(number);
            CountStreaks(number);
            UpdateNumberKindBalances(number);
            StatisticsLines.Update();

            if (_NumberHistory.Count > MaxNumberHistoryCount)
                _NumberHistory.RemoveAt(_NumberHistory.Count - 1);

            LastNumber = number.Number;
        }
        private void UpdateNumberKindBalances(CasinoNumberViewModel number)
        {
            bool isRed = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Red);
            bool isBlack = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Black);
            bool isOdd = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Odd);
            bool isEven = RouletteHelper.IsNumberOfType(number.Number, NumberKind.Even);
            bool isTo18 = RouletteHelper.IsNumberOfType(number.Number, NumberKind.To18);
            bool isFrom19 = RouletteHelper.IsNumberOfType(number.Number, NumberKind.From19);

            if (isRed)
                RedBlackBalance.KindACount++;
            else if (isBlack)
                RedBlackBalance.KindBCount++;

            if (isEven)
                EvenOddBalance.KindACount++;
            else if (isOdd)
                EvenOddBalance.KindBCount++;

            if (isTo18)
                To18From19Balance.KindACount++;
            else if (isFrom19)
                To18From19Balance.KindBCount++;

            ApplicationViewModel.Instance.AddNumberKindBalancePoint(NumberKind.Red, RedBlackBalance.CurrentAdvantageKindA);
            ApplicationViewModel.Instance.AddNumberKindBalancePoint(NumberKind.Even, EvenOddBalance.CurrentAdvantageKindA);
            ApplicationViewModel.Instance.AddNumberKindBalancePoint(NumberKind.To18, To18From19Balance.CurrentAdvantageKindA);
        }
Example #10
0
 public override void CalculateWinnings(CasinoNumberViewModel drawnNumber)
 {
     if (CalculateWinningsOnBet(LastBet, drawnNumber) != BetResultKind.Loss)
         LastBet = null;
 }
Example #11
0
 internal void CalculateWinnings(CasinoNumberViewModel drawnNumber)
 {
     CurrentBettingModeInstance.CalculateWinnings(drawnNumber);
 }
Example #12
0
        public override void CalculateWinnings(CasinoNumberViewModel drawnNumber)
        {
            foreach (var bet in _LastBets)
                CalculateWinningsOnBet(bet, drawnNumber);

            if (Settings.LastNumberBettingSettings.IsTendencyAdjustmentEnabled)
            {
                //measure tendencies
                //red black
                var redBlackBet = _LastBets.FirstOrDefault(cur => cur.BetKind == BettingKind.Red || cur.BetKind == BettingKind.Black);
                if (redBlackBet != null)
                {
                    _RedBlackTendencyMeasurement.SpinCount++;
                    if (redBlackBet.Result != BetResultKind.Win)
                        _RedBlackTendencyMeasurement.LossCount++;
                }
                //even odd
                var evenOddBet = _LastBets.FirstOrDefault(cur => cur.BetKind == BettingKind.Even || cur.BetKind == BettingKind.Odd);
                if (evenOddBet != null)
                {
                    _EvenOddTendencyMeasurement.SpinCount++;
                    if (evenOddBet.Result != BetResultKind.Win)
                        _EvenOddTendencyMeasurement.LossCount++;
                }
                //red black
                var to18From19Bet = _LastBets.FirstOrDefault(cur => cur.BetKind == BettingKind.To18 || cur.BetKind == BettingKind.From19);
                if (to18From19Bet != null)
                {
                    _To18From19TendencyMeasurement.SpinCount++;
                    if (to18From19Bet.Result != BetResultKind.Win)
                        _To18From19TendencyMeasurement.LossCount++;
                }

                //adjust to tendencies
                if (_RedBlackTendencyMeasurement.SpinCount >= Settings.LastNumberBettingSettings.TendencyAdjustmentMeasurementCount)
                {
                    if (_RedBlackTendencyMeasurement.LossCount >= Settings.LastNumberBettingSettings.TendencyAdjustmentLossThreshold)
                        _alternateRedBlack = !_alternateRedBlack;

                    _RedBlackTendencyMeasurement.Reset();
                }
                if (_EvenOddTendencyMeasurement.SpinCount >= Settings.LastNumberBettingSettings.TendencyAdjustmentMeasurementCount)
                {
                    if (_EvenOddTendencyMeasurement.LossCount >= Settings.LastNumberBettingSettings.TendencyAdjustmentLossThreshold)
                        _alternateEvenOdd = !_alternateEvenOdd;

                    _EvenOddTendencyMeasurement.Reset();
                }
                if (_To18From19TendencyMeasurement.SpinCount >= Settings.LastNumberBettingSettings.TendencyAdjustmentMeasurementCount)
                {
                    if (_To18From19TendencyMeasurement.LossCount >= Settings.LastNumberBettingSettings.TendencyAdjustmentLossThreshold)
                        _alternateTo18From19 = !_alternateTo18From19;

                    _To18From19TendencyMeasurement.Reset();
                }
            }
            else if (Settings.LastNumberBettingSettings.AlternateAfterLossCount > 0)
            {
                //count loss streaks
                _curLossStreakCountRedBlack += _LastBets.Where(cur => (cur.BetKind == BettingKind.Red || cur.BetKind == BettingKind.Black) && cur.Result == BetResultKind.Loss).Count();
                _curLossStreakCountEvenOdd += _LastBets.Where(cur => (cur.BetKind == BettingKind.Even || cur.BetKind == BettingKind.Odd) && cur.Result == BetResultKind.Loss).Count();
                _curLossStreakCountTo18From19 += _LastBets.Where(cur => (cur.BetKind == BettingKind.To18 || cur.BetKind == BettingKind.From19) && cur.Result == BetResultKind.Loss).Count();

                //alternate
                if (_curLossStreakCountRedBlack >= Settings.LastNumberBettingSettings.AlternateAfterLossCount)
                {
                    _alternateRedBlack = !_alternateRedBlack;
                    _curLossStreakCountRedBlack = 0;
                }
                if (_curLossStreakCountEvenOdd >= Settings.LastNumberBettingSettings.AlternateAfterLossCount)
                {
                    _alternateEvenOdd = !_alternateEvenOdd;
                    _curLossStreakCountEvenOdd = 0;
                }
                if (_curLossStreakCountTo18From19 >= Settings.LastNumberBettingSettings.AlternateAfterLossCount)
                {
                    _alternateTo18From19 = !_alternateTo18From19;
                    _curLossStreakCountTo18From19 = 0;
                }

                if (_LastBets.Any(cur => (cur.BetKind == BettingKind.Red || cur.BetKind == BettingKind.Black) && cur.Result == BetResultKind.Win))
                    _curLossStreakCountRedBlack = 0;
                if (_LastBets.Any(cur => (cur.BetKind == BettingKind.Even || cur.BetKind == BettingKind.Odd) && cur.Result == BetResultKind.Win))
                    _curLossStreakCountEvenOdd = 0;
                if (_LastBets.Any(cur => (cur.BetKind == BettingKind.To18 || cur.BetKind == BettingKind.From19) && cur.Result == BetResultKind.Win))
                    _curLossStreakCountTo18From19 = 0;
            }

            _LastBets.Clear();
        }
Example #13
0
        private bool IsNumberVisible(CasinoNumberViewModel numberMarker, List<ComparisonPixel> numberMarkerComparisonPixels)
        {
            var absoluteNumZeroBounds = new Rect(Settings.FixedCasinoWindowPosition.X + numberMarker.Bounds.Left,
                                                Settings.FixedCasinoWindowPosition.Y + numberMarker.Bounds.Top,
                                                numberMarker.Bounds.Width,
                                                numberMarker.Bounds.Height);

            int pixelMatchCount = 0;
            using (var numZeroScreenshot = ScreenHelper.TakeScreenshot(absoluteNumZeroBounds))
            {
                var xOffset = numberMarker.Bounds.Left;
                var yOffset = numberMarker.Bounds.Top;

                foreach (var originalPixel in numberMarkerComparisonPixels)
                {
                    var dPosition = new Point(originalPixel.Position.X - xOffset,
                                                originalPixel.Position.Y - yOffset).ToDrawingPoint();

                    var curPixelColor = numZeroScreenshot.GetPixel(dPosition.X, dPosition.Y);
                    if (originalPixel.Color.Equals(curPixelColor))
                        pixelMatchCount++;
                }
            }

            //20% here is arbitrary. the number should be visible if at least that much of the pixels match.
            return pixelMatchCount >= (numberMarkerComparisonPixels.Count * 0.2);
        }
Example #14
0
        /// <summary>
        /// Checks if the roulette board is visible in the browser.
        /// If it is not visible, refresh the browser until it is.
        /// </summary>
        private async Task VerifyRouletteBoardIsVisible()
        {
            if (_NumZeroMarker == null)
            {
                _NumZeroMarker = Settings.CasinoNumbers.FirstOrDefault(cur => cur.Number == 0);
                _NumZeroOriginalComparisonPixels = _NumZeroMarker.GetComparisonPixels();
            }

            var oldStatus = ApplicationView.Status.Message;
            ApplicationView.UpdateStatus("Waiting for roulette board...");

            bool isZeroVisible = IsNumberVisible(_NumZeroMarker, _NumZeroOriginalComparisonPixels);
            if (!isZeroVisible)
            {
                ApplicationView.BetManager.ResetBettingStreak();
                Statistics.ResetStreaks();
            }

            while (!isZeroVisible && (!_IsStopScheduled && !_IsPauseScheduled))
            {
                RouletteBoardHelper.ClickButton(RouletteButtonKind.RefreshPosition);
                ApplicationViewModel.InputSimulator.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.F5);

                //wait for refresh
                await Task.Delay(RefreshWaitTimeInMsFast);

                isZeroVisible = IsNumberVisible(_NumZeroMarker, _NumZeroOriginalComparisonPixels);
            }

            ApplicationView.UpdateStatus(oldStatus);
        }
Example #15
0
 private void LogNumber(CasinoNumberViewModel drawnNumber)
 {
     if (_NumberLogWriter != null)
     {
         _NumberLogWriter.Write(string.Format(";{0}", drawnNumber.Number));
         _NumberLogWriter.Flush();
     }
 }