Esempio n. 1
0
 public async Task<StatRecord> GetTailStats(Game game)
 {
     var tailKey = game.CreateTailKey();
     var res = await Cache.GetTail(tailKey);
     if (res == null)
     {
         MisTailStats[game.Turn]++;
     }
     else
     {
         HitTailStats[game.Turn]++;
     }
     return res;
 }
Esempio n. 2
0
 public async Task<StatRecord> GetBucketStats(Game game)
 {
     var bucketKey = game.CreateBucketKey();
     var res= await Cache.GetBucket(bucketKey);
     if (res == null)
     {
         MisBucketStats[game.Turn]++;
     }
     else
     {
         Collections.TryAdd(res.Collection.Key, null);
         HitBucketStats[game.Turn]++;
     }
     return res;
 }
Esempio n. 3
0
        public void ColorTest3()
        {
            var game = new Game(Player.P1,
                Card.AQ, Card.AK, Card.AA, Card.B7, Card.T8,
                Card.C7, Card.C8, Card.C9, Card.C0, Card.CJ,
                Card.B9, Card.B0, Card.BJ, Card.BQ, Card.BA,
                Card.AJ, Card.B8,
                Card.T9, Card.T0, Card.A0, Card.TQ, Card.TK,
                Card.CQ, Card.CK, Card.CA, Card.BK, Card.T7,
                Card.A7, Card.A8, Card.A9, Card.TJ, Card.TA
                );
            Console.WriteLine(game);

            game = game.MakeTurn(Card.T0);
            game = game.MakeTurn(Card.T7);
            game.MakeTurn(Card.A9);
        }
Esempio n. 4
0
        public async Task<StatRecord> Record(Game game, long cash, long count)
        {
            var bucketKey = game.CreateBucketKey();
            var tailKey = game.CreateTailKey();

            StatRecord record = await Cache.IncrementBucket(bucketKey, cash, count);
            if (record.Count == count)
            {
                CreateBucketStats[game.Turn]++;
            }
            else
            {
                UpdateBucketStats[game.Turn]++;
            }

            UpdateTailStats[game.Turn]++;
            Cache.SetTail(tailKey, record.AggCash, record.Count);

            return record;
        }
Esempio n. 5
0
        public Game(Game src)
        {
            _betSeven = src._betSeven;
            _betGame = src._betGame;
            _bet100 = src._bet100;
            Turn = src.Turn;
            PlayerOnTurn = src.PlayerOnTurn;

            _cardOwners = new Player[Card.Count];
            _sequence = new Card[30];
            _cardUsed = new bool[Card.Count];
            _remainingColorCount = new byte[Player.Count, Color.Count];
            _score = new byte[Player.Count];

            Array.Copy(src._cardUsed, _cardUsed, Card.Count);
            Array.Copy(src._cardOwners, _cardOwners, Card.Count);
            Array.Copy(src._sequence, _sequence, 30);
            Array.Copy(src._remainingColorCount, _remainingColorCount, Player.Count*Color.Count);
            Array.Copy(src._score, _score, Player.Count);
        }
Esempio n. 6
0
        public void RandomGame1(int testCase, int gameIndex)
        {
            Random random;
            Game game;
            if (testCase == -1)
            {
                var seed = (int)(DateTime.UtcNow.ToFileTime() % int.MaxValue);
                random = new Random(seed);
                Console.WriteLine(seed);
            }
            else
            {
                random = new Random(testCase);
            }
            if (gameIndex == -1)
            {
                var deck = new List<Card> {
                    Card.B9, Card.B0, Card.BJ, Card.BQ, Card.BA,
                    Card.CQ, Card.CK, Card.CA, Card.T7, Card.TK,
                    Card.C7, Card.C8, Card.C9, Card.C0, Card.CJ,
                    Card.AJ, Card.T8,
                    Card.T9, Card.T0, Card.TJ, Card.TQ, Card.TA,
                    Card.A7, Card.A8, Card.A9, Card.A0, Card.BK,
                    Card.AQ, Card.AK, Card.AA, Card.B7, Card.B8
                };

                do
                {
                    deck.Shuffle(random);
                } while (deck[15].HasPoints() || deck[16].HasPoints() || deck[15] == Card.T7 || deck[16] == Card.T7);

                game = new Game(Player.P2, deck.ToArray());
            }
            else
            {
                game = games[gameIndex];
            }

            for (int turn = 0; turn < 30; turn++)
            {
                Console.WriteLine(game);
                var possibleTurns = game.PossibleTurns().ToList();
                Console.Write("Choices: ");
                for (int c = 0; c < possibleTurns.Count; c++)
                {
                    if (c != 0)
                    {
                        Console.Write(",");
                    }
                    var choice = possibleTurns[c];
                    Console.Write(choice.ToString());
                }
                Console.WriteLine();

                var next = random.Next(possibleTurns.Count);
                Card playedCard = possibleTurns[next];
                Console.WriteLine($"Choice: {playedCard}");
                Console.WriteLine();
                game = game.MakeTurn(playedCard);
            }
            Console.WriteLine(game);
        }
Esempio n. 7
0
 private Game MakeTurn(Card turn)
 {
     var after = new Game(this);
     after.TurnImpl(turn);
     return after;
 }