private void doBetSomeMoney()
        {
            byte i = DoublingXForm.STARTROUND, j;
            byte? scoreA, scoreH;
            double bank = DoublingXForm.BANKMONEY, bet = DoublingXForm.BETMONEYPERROUND;
            int r;
            string aTeam, hTeam, q = @"SELECT * FROM dbo.archive WHERE Round>=" + DoublingXForm.STARTROUND + " ORDER BY Country,League,Season,Round";
            ArchiveVal aVal;
            Brush color;
            Dictionary<LRTKey, ArchiveVal> aDict = new Dictionary<LRTKey,ArchiveVal>();
            Dictionary<LRTKey, Power> hDict;

            backgroundWorker.ReportProgress(25, new BGReport("Processing dbo.archive ..."));
            using (SqlDataReader reader = new SqlCommand(q, this.connection).ExecuteReader())
            {
                while (reader.Read())
                {
                    aTeam = reader["AwayTeam"].ToString();
                    hTeam = reader["HomeTeam"].ToString();
                    scoreA = reader["ScoreA"] is DBNull ? null : (byte?)reader["ScoreA"];
                    scoreH = reader["ScoreH"] is DBNull ? null : (byte?)reader["ScoreH"];
                    aDict[new LRTKey(reader, hTeam, aTeam)] = new ArchiveVal(scoreH, scoreA, reader["DrawOdds"]);
                    aDict[new LRTKey(reader, aTeam, hTeam)] = new ArchiveVal(scoreA, scoreH, reader["DrawOdds"]);
                }
            }

            backgroundWorker.ReportProgress(50, new BGReport("Processing dbo.history ..."));
            hDict = MethodAForm.getHistoryDict(this.connection);

            var dictSortedByRound = from item in hDict
                                    let otherKey = LRTKey.getOtherKey(item.Key)
                                    where item.Key.Season == "2011/12" && Math.Abs(item.Value.PrevAvgStrength - hDict[otherKey].PrevAvgStrength) <= 1
                                    orderby item.Key.Round select item;
            var dictRound = from item in dictSortedByRound where item.Key.Round == i select item;
            while (dictRound.Count() > 0)
            {
                using (var cursor = dictRound.GetEnumerator())
                {
                    r = (new Random()).Next(dictRound.Count()) + 1;
                    for (j = 0; j < r; j++)
                        cursor.MoveNext();
                    if (aDict[cursor.Current.Key].result == null) {
                        cursor.Reset();
                        while (cursor.MoveNext()) if (aDict[cursor.Current.Key].result != null)
                            break;
                    }
                    aVal = aDict[cursor.Current.Key];
                    if (aVal.result == 0)
                    {
                        bank += bet * (aVal.DrawOdds - 0.15);
                        bet = DoublingXForm.BETMONEYPERROUND;
                        color = Brushes.Blue;
                    }
                    else
                    {
                        bank -= bet;
                        bet *= 2;
                        color = Brushes.Black;
                    }
                    if (bank < 0) color = Brushes.Red;
                    backgroundWorker.ReportProgress(70, new BGReport(
                        String.Format("{0} {1} - Bet:{2} Bank:{3}", cursor.Current.Key, aVal, bet, bank), color
                    ));
                }
                if (bank < 0) break;
                i++;
                dictRound = from item in dictSortedByRound where item.Key.Round == i select item;
            }
        }
        private void doBetSomeMoney()
        {
            byte       i = DoublingXForm.STARTROUND, j;
            byte?      scoreA, scoreH;
            double     bank = DoublingXForm.BANKMONEY, bet = DoublingXForm.BETMONEYPERROUND;
            int        r;
            string     aTeam, hTeam, q = @"SELECT * FROM dbo.archive WHERE Round>=" + DoublingXForm.STARTROUND + " ORDER BY Country,League,Season,Round";
            ArchiveVal aVal;
            Brush      color;
            Dictionary <LRTKey, ArchiveVal> aDict = new Dictionary <LRTKey, ArchiveVal>();
            Dictionary <LRTKey, Power>      hDict;

            backgroundWorker.ReportProgress(25, new BGReport("Processing dbo.archive ..."));
            using (SqlDataReader reader = new SqlCommand(q, this.connection).ExecuteReader())
            {
                while (reader.Read())
                {
                    aTeam  = reader["AwayTeam"].ToString();
                    hTeam  = reader["HomeTeam"].ToString();
                    scoreA = reader["ScoreA"] is DBNull ? null : (byte?)reader["ScoreA"];
                    scoreH = reader["ScoreH"] is DBNull ? null : (byte?)reader["ScoreH"];
                    aDict[new LRTKey(reader, hTeam, aTeam)] = new ArchiveVal(scoreH, scoreA, reader["DrawOdds"]);
                    aDict[new LRTKey(reader, aTeam, hTeam)] = new ArchiveVal(scoreA, scoreH, reader["DrawOdds"]);
                }
            }

            backgroundWorker.ReportProgress(50, new BGReport("Processing dbo.history ..."));
            hDict = MethodAForm.getHistoryDict(this.connection);

            var dictSortedByRound = from item in hDict
                                    let otherKey = LRTKey.getOtherKey(item.Key)
                                                   where item.Key.Season == "2011/12" && Math.Abs(item.Value.PrevAvgStrength - hDict[otherKey].PrevAvgStrength) <= 1
                                                   orderby item.Key.Round select item;
            var dictRound = from item in dictSortedByRound where item.Key.Round == i select item;

            while (dictRound.Count() > 0)
            {
                using (var cursor = dictRound.GetEnumerator())
                {
                    r = (new Random()).Next(dictRound.Count()) + 1;
                    for (j = 0; j < r; j++)
                    {
                        cursor.MoveNext();
                    }
                    if (aDict[cursor.Current.Key].result == null)
                    {
                        cursor.Reset();
                        while (cursor.MoveNext())
                        {
                            if (aDict[cursor.Current.Key].result != null)
                            {
                                break;
                            }
                        }
                    }
                    aVal = aDict[cursor.Current.Key];
                    if (aVal.result == 0)
                    {
                        bank += bet * (aVal.DrawOdds - 0.15);
                        bet   = DoublingXForm.BETMONEYPERROUND;
                        color = Brushes.Blue;
                    }
                    else
                    {
                        bank -= bet;
                        bet  *= 2;
                        color = Brushes.Black;
                    }
                    if (bank < 0)
                    {
                        color = Brushes.Red;
                    }
                    backgroundWorker.ReportProgress(70, new BGReport(
                                                        String.Format("{0} {1} - Bet:{2} Bank:{3}", cursor.Current.Key, aVal, bet, bank), color
                                                        ));
                }
                if (bank < 0)
                {
                    break;
                }
                i++;
                dictRound = from item in dictSortedByRound where item.Key.Round == i select item;
            }
        }