Exemplo n.º 1
0
        int GameNNTrainToWin(NeuralNetwork neuralNetwork, List <Card> deck)
        {
            List <Player> Players = new List <Player>();

            Players.Add(new Player(1, true));
            Players.Add(new Player(2, false));
            Players[0].Leading = true; //Set Player One to lead trick
            //Apply Neural Network Weights to Deck
            NNDecideCard.ApplyWeightsToCards(neuralNetwork, deck);
            Decision.SetTrumps(deck, 3); //Set Spades as Trump
            Deal.DealToPlayersNN(Players, deck);
            Decision.DecideBids(Players);
            //Train To Win Set Bid to 10
            Players[0].Bid = 10;
            //Record Player 1 Hand
            HandRecord handRecord = Record.RecordHandInit(Players.FirstOrDefault(x => x.ID == 1));

            //State that player 1 should use Neural Network
            Players.FirstOrDefault(x => x.ID == 1).UseNN = true;
            //Write out bids
            //WriteBids(Players);
            //Write out Hands
            //WriteHands(Players);
            for (int i = 1; i < 11; i++)
            {
                //Console.WriteLine("Game " + i);
                //Set NN player to always lead for better training
                Players.FirstOrDefault(p => p.UseNN == true).Leading = true;
                Decision.DecideCardToPlayNN(Players, neuralNetwork);
                Decision.PlayCardNN(Players, false);
            }
            return(Players.FirstOrDefault(x => x.ID == 1).Wins);
        }
Exemplo n.º 2
0
        static void Game()
        {
            List <Player> Players = new List <Player>();

            Players.Add(new Player(1, true));
            Players.Add(new Player(2, false));
            Players[0].Leading = true; //Set Player One to lead trick
            List <Card> deck = Deal.CreateDeck();

            Decision.SetTrumps(deck, 3); //Set Spades as Trump
            Deal.DealToPlayers(Players, deck);
            Decision.DecideBids(Players);
            //Record Player 1 Hand
            HandRecord handRecord = Record.RecordHandInit(Players.FirstOrDefault(x => x.ID == 1));

            //Write out bids
            foreach (Player player in Players)
            {
                Console.WriteLine("Player: " + player.ID + " Bid: " + player.Bid);
            }
            //Write out Hands
            foreach (Player player in Players)
            {
                Console.WriteLine("Player " + player.ID + " Hand:");
                List <Card> OrderedHand = player.Hand.OrderBy(x => x.Value).OrderBy(x => x.suit.ID).ToList();
                foreach (Card card in OrderedHand)
                {
                    Console.WriteLine("Card ID: " + card.ID + " Card Value: " + card.ValueName + " of " + card.suit.SuitName);
                }
                Console.WriteLine("");
            }
            for (int i = 1; i < 11; i++)
            {
                Console.WriteLine("Game " + i);
                Decision.DecideCardToPlay(Players);
                Decision.PlayCard(Players);
            }
            //Work out wins
            foreach (Player player in Players)
            {
                Console.WriteLine("Player Wins: " + player.Wins + " Bid: " + player.Bid);
            }
            //Record if PlayerOne was successful
            if (Players.FirstOrDefault(x => x.ID == 1).Wins == Players.FirstOrDefault(x => x.ID == 1).Bid)
            {
                handRecord.GameWon = 1;
            }
            CSVWriter.WriteHandResult(handRecord);
        }
Exemplo n.º 3
0
        int Game()
        {
            List <Player> Players = new List <Player>();

            Players.Add(new Player(1, true));
            Players.Add(new Player(2, false));
            Players[0].Leading = true; //Set Player One to lead trick
            List <Card> deck = Deal.CreateDeck();

            Decision.SetTrumps(deck, 3); //Set Spades as Trump
            Deal.DealToPlayers(Players, deck);
            Decision.DecideBids(Players);
            //Record Player 1 Hand
            HandRecord handRecord = Record.RecordHandInit(Players.FirstOrDefault(x => x.ID == 1));

            //Write out bids
            WriteBids(Players);
            //Write out Hands
            WriteHands(Players);
            for (int i = 1; i < 11; i++)
            {
                Console.WriteLine("Game " + i);
                Decision.DecideCardToPlay(Players);
                Decision.PlayCard(Players, true);
            }
            //Work out wins
            foreach (Player player in Players)
            {
                Console.WriteLine("Player Wins: " + player.Wins + " Bid: " + player.Bid);
            }
            //Record if PlayerOne was successful
            if (Players.FirstOrDefault(x => x.ID == 1).Wins == Players.FirstOrDefault(x => x.ID == 1).Bid)
            {
                handRecord.GameWon = 1;
            }
            CSVWriter.WriteHandResult(handRecord);
            return(handRecord.GameWon);
        }