Exemplo n.º 1
0
        private void event_butconnect(object sender, EventArgs e)
        {
            cli    = new client();
            servvv = new serveur();
            panelreseau.Controls[6].Click -= event_butconnect;
            try{
                cli.connect(panelreseau.Controls[3].Text, Int32.Parse(panelreseau.Controls[5].Text));
                Console.WriteLine("client co");
            }
            catch (Exception ex) {
                srvth = new Thread(new ThreadStart(srv));
                srvth.Start();
                cltth = new Thread(new ThreadStart(clt));
                cltth.Start();
            }
            if (cltth != null)
            {
                while (cltth.ThreadState != ThreadState.Stopped)
                {
                    Application.DoEvents();
                }
            }

            serveur.send("PSD " + panelreseau.Controls[1].Text, cli.sock);
            while (cli.begin != true)
            {
                Application.DoEvents();
            }

            monop = new Monopoly(cli);
            monop.Show();
            monop.Closed += new System.EventHandler(eventClosed);
            Visible       = false;
        }
        public void correct_banker_should_be_loaded_on_load_game()
        {
            var gameOfMonopoly = new Monopoly();

            // Make him pay a bit of money so we know if it's the same
            // banker being loaded
            Banker.Access().Pay(1000);

            var bankerBeforeSavedBalance = Banker.Access().GetBalance();

            // Need to players on the board for saving and loading correctly
            Board.Access().AddPlayer(new Player());
            Board.Access().AddPlayer(new Player());

            gameOfMonopoly.SaveGame();

            // Set the banker's balance to something random so we know
            // it's then changed when we load the game that has the
            // other banker's balance from the previous save
            Banker.Access().SetBalance(500);

            gameOfMonopoly.LoadGame();

            var bankerAfterLoadedBalance = Banker.Access().GetBalance();

            // The balance should be what it was when we saved it even though we
            // changed it, this is because the banker we're loading is the one
            // before we changed the balance
            Assert.AreEqual(bankerBeforeSavedBalance, bankerAfterLoadedBalance);
        }
Exemplo n.º 3
0
        public void MonopolyCheckerTest()
        {
            int[] OriAndVerRent = new int[6] {
                6, 30, 90, 270, 400, 550
            };
            RegularProperty oriental = new RegularProperty("Oriental Avenue", 100, 6, 50, OriAndVerRent, RegularProperty.ColorGroup.LightBlue);
            RegularProperty vermont  = new RegularProperty("Vermont Avenue", 100, 8, 50, OriAndVerRent, RegularProperty.ColorGroup.LightBlue);

            int[] ConnectRent = new int[6] {
                8, 40, 100, 300, 450, 600
            };
            RegularProperty connecticut = new RegularProperty("Connecticut Avenue", 120, 9, 50, ConnectRent, RegularProperty.ColorGroup.LightBlue);

            int[] PPRent = new int[6] {
                35, 175, 500, 1100, 1300, 1500
            };
            RegularProperty parkPlace = new RegularProperty("Park Place", 350, 37, 200, PPRent, RegularProperty.ColorGroup.DarkBlue);

            int[] BWRent = new int[6] {
                50, 200, 600, 1400, 1700, 2000
            };
            RegularProperty boardWalk = new RegularProperty("Boardwalk", 400, 39, 200, BWRent, RegularProperty.ColorGroup.DarkBlue);

            IProperty[] owned      = new IProperty[] { oriental, vermont, parkPlace, boardWalk };
            Player      testPlayer = new Player("Chris", Player.Token.RaceCar, 1500, owned);

            Assert.IsTrue(Monopoly.MonopolyChecker(testPlayer, boardWalk));
            Assert.IsFalse(Monopoly.MonopolyChecker(testPlayer, vermont));
            testPlayer.OwnedProperties.Append(connecticut);
            Assert.IsTrue(Monopoly.MonopolyChecker(testPlayer, connecticut));
        }
Exemplo n.º 4
0
        public void TestSetPosition()
        {
            Monopoly game = Monopoly.GetInstance();

            game[0].GoToCase(39);
            Assert.AreEqual(game[0].CurrentPosition.value, 39);
        }
        public void correct_banker_should_be_loaded_on_load_game()
        {
            var gameOfMonopoly = new Monopoly();

            // Make him pay a bit of money so we know if it's the same
            // banker being loaded
            Banker.Access().Pay(1000);

            var bankerBeforeSavedBalance = Banker.Access().GetBalance();

            // Need to players on the board for saving and loading correctly
            Board.Access().AddPlayer(new Player());
            Board.Access().AddPlayer(new Player());

            gameOfMonopoly.SaveGame();

            // Set the banker's balance to something random so we know
            // it's then changed when we load the game that has the
            // other banker's balance from the previous save
            Banker.Access().SetBalance(500);

            gameOfMonopoly.LoadGame();

            var bankerAfterLoadedBalance = Banker.Access().GetBalance();

            // The balance should be what it was when we saved it even though we 
            // changed it, this is because the banker we're loading is the one
            // before we changed the balance
            Assert.AreEqual(bankerBeforeSavedBalance, bankerAfterLoadedBalance);
        }
Exemplo n.º 6
0
    public static void Main(string[] args)
    {
        //Declare Monopoly instance
        string CurrentFP;

        Monopoly CurrGame = new Monopoly();

        CurrGame.NewPlayer("Dog", "Andrew")
        CurrGame.NewPlayer("Ship", "Fei")

        //Test
        Boardspace temp;

        temp = CurrGame.CurrBoard.GoSpace;
        Console.WriteLine("BEGIN TEST");
        do
        {
            Console.WriteLine(temp.SpaceName);
            Console.WriteLine(temp.SpaceType);
            Console.WriteLine(temp.GetType());
            temp = temp.Next;
            if (temp is TitleProperty)
            {
                Console.WriteLine(temp is TitleProperty);
                TitleProperty tempTitle = (TitleProperty)temp;
                Console.WriteLine(tempTitle.Rent);
            }
        }while (temp.SpaceName != CurrGame.CurrBoard.GoSpace.SpaceName);
    }
Exemplo n.º 7
0
        public void setting_up_players_fails_with_less_than_2_players()
        {
            Board.Access().ResetBoard();
            _gameOfMonopoly = new Monopoly();
            _gameOfMonopoly.SetUpProperties();

            _gameOfMonopoly.SetUpPlayers(1);
        }
Exemplo n.º 8
0
        private static void FreshBoard()
        {
            Board.Access().ResetBoard();
            // Need to add all properties to board
            var monopoly = new Monopoly();

            monopoly.SetUpProperties();
        }
        public void Setup_GameWith2Players_ShouldWork()
        {
            game = new Monopoly(null, null, null);
            game.AddPlayer(horse);
            game.AddPlayer(car);

            Assert.Contains(horse, game.Players);
            Assert.Contains(car, game.Players);
        }
Exemplo n.º 10
0
        public void setting_up_players_with_valid_players()
        {
            Board.Access().ResetBoard();
            _gameOfMonopoly = new Monopoly();
            _gameOfMonopoly.SetUpProperties();

            _gameOfMonopoly.SetUpPlayers(2, "Josh");

            Assert.AreEqual(2, Board.Access().GetPlayerCount());
        }
Exemplo n.º 11
0
        public void TestTemplate()
        {
            Game game = new Chess();

            game.PlayOneGame(2);


            game = new Monopoly();
            game.PlayOneGame(4);
        }
Exemplo n.º 12
0
        public void TestAddingPlayers()
        {
            Monopoly game = Monopoly.GetInstance();

            //Adding players
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            Assert.AreEqual(game[0], new Player("Jean", null));
        }
Exemplo n.º 13
0
        public void Setup_GameWithWrongNumberOfPlayers_ShouldThrowException(int numPlayers)
        {
            game = new Monopoly(null, null, null);

            for (int i = 0; i < numPlayers; i++)
            {
                game.AddPlayer(new Player(i.ToString()));
            }

            Assert.Throws <InvalidOperationException>(() => game.Start());
        }
Exemplo n.º 14
0
        public void Rounds_GameWith2Players_ShouldPlayFor200Rounds()
        {
            game = new Monopoly(null, null, null);
            game.AddPlayer(horse);
            game.AddPlayer(car);
            game.Start();

            Assert.Equal(200, game.Rounds);
            Assert.Equal(200, horse.Rounds);
            Assert.Equal(200, car.Rounds);
        }
Exemplo n.º 15
0
        public void TestGoToJailwDouble()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //In case an instance already exists
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");
            game[0].Play(4, 4); //Simulates making two 4s three times in a row
            Assert.AreEqual(game[0].InPrison, true);
        }
Exemplo n.º 16
0
        public void TestCircularity()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //In case an instance already exists
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            game[0].GoToCase(39);

            Assert.AreEqual(game[0].CurrentPosition.next.value, 0);
        }
Exemplo n.º 17
0
    private void writeText()
    {
        Font font20 = new Font("Fonts/riffic-bold.ttf", 20);
        Font font40 = new Font("Fonts/comic.ttf", 40);

        string line1;

        if (Monopoly.GetLenguage())
        {
            line1 = "Change lenguage:";
        }
        else
        {
            line1 = "Cambiar idioma:";
        }
        Hardware.WriteHiddenText(line1, 350, 150,
                                 0xFF, 0x00, 0x00, font40);

        short y     = 300;
        short count = 1;

        foreach (KeyValuePair <string, string> leng in lenguages)
        {
            string line;
            if (Monopoly.GetLenguage())
            {
                line = leng.Key;
            }
            else
            {
                line = leng.Value;
            }
            Hardware.WriteHiddenText(count + ".- " + line, 400, y,
                                     0x00, 0x00, 0x00, font20);
            y += 50;
            count++;
        }

        string line2;

        if (Monopoly.GetLenguage())
        {
            line2 = "Press Space To Select!";
        }
        else
        {
            line2 = "¡Presiona Espacio Para Salir!";
        }
        Hardware.WriteHiddenText(line2, 350, 500,
                                 0xFF, 0x00, 0x00, font20);
    }
Exemplo n.º 18
0
        public void SetUp()
        {
            Board.Access().ResetBoard();

            _gameOfMonopoly = new Monopoly();
            _gameOfMonopoly.SetUpProperties();
            _gameOfMonopoly.SetUpCards();

            _player1 = new Player("Josh");
            _player2 = new Player("Hubert");

            Board.Access().AddPlayer(_player1);
            Board.Access().AddPlayer(_player2);
        }
        public void SetUp()
        {
            Board.Access().ResetBoard();

            _gameOfMonopoly = new Monopoly();
            _gameOfMonopoly.SetUpProperties();
            _gameOfMonopoly.SetUpCards();

            _player1 = new Player("Josh");
            _player2 = new Player("Hubert");

            Board.Access().AddPlayer(_player1);
            Board.Access().AddPlayer(_player2);
        }
Exemplo n.º 20
0
        public void OutOfJail1wDouble()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //In case an instance already exists
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            game[0].Play(4, 4);
            game[0].Play(4, 4);

            Assert.AreEqual(game[0].InPrison, false);
            Assert.AreEqual(game[0].CurrentPosition.value, 18);
        }
Exemplo n.º 21
0
        public void TestGoToJailOn30()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //Because with the sigleton pattern it keeps the ulterior state
            //Adding players
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            game[0].Play(4, 6);
            game[0].Play(4, 6);
            game[0].Play(4, 6);
            Assert.AreEqual(game[0].InPrison, true);
        }
Exemplo n.º 22
0
    public Monopoly(client cli)
    {
        Text            = "MONOPOLY";
        Icon            = new Icon("img/monop.ico");
        Size            = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
        MinimumSize     = new Size(350, 400);
        StartPosition   = FormStartPosition.CenterScreen;
        WindowState     = FormWindowState.Maximized;
        FormBorderStyle = FormBorderStyle.Fixed3D;
        Font            = new Font("Feeling Babylon", 10);
        BackColor       = Color.Beige;

        clic      = cli;
        continuer = true;
        blk       = new BlockingCollection <string>();
        clic.blk  = blk;
        formchoix = new Form();

        // INIT PLAT
        plat = new Plateau(nbjoueur);
        plat.setPlat();
        Controls.Add(plat);

        // INIT PLAYERS
        nomjoueurs = new string[6];
        getinf(cli.inf);
        plat.createPlayers(nbjoueur, nomjoueurs);
        plat.setPlayers();

        // INIT PLAYERS ICONES
        panelplayerliste = new Dictionary <int, Panel>();
        createPanelPlayers(nbjoueur);

        // HISTORIQUE
        receivebox = createReceiveBox();
        Controls.Add(receivebox);

        musique.SoundLocation = "snd/ost.wav";
        musique.PlayLooping();

        plth = new Thread(new ThreadStart(PltThread));
        plth.Start();

        if (plat.Nbtour == 0 && plat.Tour == 0 && clic.nbordre == plat.Tour)
        {
            Monopoly.print(Monopoly.receivebox, "plateau", "c'est au tour du joueur " + plat.playerliste[plat.Tour].Name);
        }
    }
Exemplo n.º 23
0
        public void OutOfJail1w3Rounds()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //In case an instance already exists
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            game[0].Play(4, 4); //Go to Jail (it simulate 3 doubles in a row)

            game[0].Play(2, 6);
            game[0].Play(3, 6);
            game[0].Play(4, 6);


            Assert.AreEqual(game[0].InPrison, false);
            Assert.AreEqual(game[0].CurrentPosition.value, 20);
        }
Exemplo n.º 24
0
    public override void Run()
    {
        do
        {
            hardware.ClearScreen();
            hardware.DrawImage(background);
            writeText();
            hardware.ShowHiddenScreen();

            if (hardware.KeyPressed(Sdl.SDLK_1))
            {
                Monopoly.SetLenguage(true);
            }
            else if (hardware.KeyPressed(Sdl.SDLK_2))
            {
                Monopoly.SetLenguage(false);
            }
        }while (!hardware.KeyPressed(Sdl.SDLK_SPACE));
    }
Exemplo n.º 25
0
        public void Birthday_WithTwoOtherPlayers_ShouldCollect20Dollars()
        {
            Monopoly game     = new Monopoly(null, null, null);
            Board    board    = new CardBoard();
            Birthday birthday = new Birthday();
            Player   horse    = new Player("Horse");
            Player   car      = new Player("Car");
            Player   shoe     = new Player("Shoe");

            game.AddPlayer(horse);
            game.AddPlayer(car);
            game.AddPlayer(shoe);
            board.AddPlayerToBoard(car, 0);
            board.AddPlayerToBoard(horse, 0);
            board.AddPlayerToBoard(shoe, 0);

            birthday.Execute(horse);

            Assert.Equal(20, horse.Bank);
            Assert.Equal(-10, car.Bank);
            Assert.Equal(-10, shoe.Bank);
        }
Exemplo n.º 26
0
        public void Setup_GameWith2Players_ShouldRandomizeOrder()
        {
            bool horseFirst = false;
            bool carFirst   = false;

            for (int i = 0; i < 100; i++)
            {
                game = new Monopoly(null, null, null);
                game.AddPlayer(horse);
                game.AddPlayer(car);
                game.Start();
                if (game.Players[0].Name == "Horse")
                {
                    horseFirst = true;
                }
                if (game.Players[0].Name == "Car")
                {
                    carFirst = true;
                }
            }

            Assert.True(horseFirst && carFirst);
        }
Exemplo n.º 27
0
    //Text
    private void writeText()
    {
        Font font18 = new Font("Fonts/comic.ttf", 18);

        short y     = 200;
        short count = 1;

        foreach (KeyValuePair <string, string> leng in lenguages)
        {
            string line;
            if (Monopoly.GetLenguage())
            {
                line = leng.Key;
            }
            else
            {
                line = leng.Value;
            }
            Hardware.WriteHiddenText(count + ".- " + line, 440, y,
                                     0x00, 0x00, 0x00, font18);
            y += 50;
            count++;
        }
    }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            Game game = new Monopoly();

            game.initializeGame();
        }
Exemplo n.º 29
0
        public static void Main(string[] args)
        {
            Monopoly monopoly = new Monopoly(1, 3);

            monopoly.SetUp().Start();
        }
        public void setting_up_players_with_valid_players()
        {
            Board.Access().ResetBoard();
            _gameOfMonopoly = new Monopoly();
            _gameOfMonopoly.SetUpProperties();

            _gameOfMonopoly.SetUpPlayers(2,"Josh");

            Assert.AreEqual(2, Board.Access().GetPlayerCount());
        }
        public void setting_up_players_fails_with_less_than_2_players()
        {
            Board.Access().ResetBoard();
            _gameOfMonopoly = new Monopoly();
            _gameOfMonopoly.SetUpProperties();

            _gameOfMonopoly.SetUpPlayers(1);
        }
 public void SetUp()
 {
     _gameOfMonoploy = new Monopoly();
     _gameOfMonoploy.SetUpProperties();
     _player = new Player("Josh");
 }
Exemplo n.º 33
0
        public static void Problem3()
        {
            Console.WriteLine("Creation of the Game:");
            Monopoly game = Monopoly.GetInstance();

            #region Add players
            //Adding players
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");
            game.AddPlayer("Christine");
            game.AddPlayer("UselessPlayer");
            Console.WriteLine(game);
            #endregion

            #region Try deleting a player
            game.DeletePlayer("UselessPlayer");
            Console.WriteLine("UselessPlayer Deleted:");
            Console.WriteLine(game);
            #endregion

            #region Simulating some round
            Console.WriteLine("\nHow many rounds do you want to simulate ? ");
            string n;
            int    value;
            do
            {
                n = Console.ReadLine();
            } while (!int.TryParse(n, out value));


            for (int i = 0; i < value; i++)
            {
                game.PlayRound();
            }
            #endregion

            #region Others different check
            //Try adding a player during the game
            game.AddPlayer("Cassandre");
            //! You can't add players when the game has already started

            //Check if the iterator pattern works properly
            Console.WriteLine(game);

            //Check if the singleton pattern works properly
            Console.WriteLine("\nLet's check that the singleton pattern works properly");
            Monopoly game2 = Monopoly.GetInstance();
            Console.WriteLine(game2);
            // !! This is exactly the same game, the iterator pattern is working properly.

            //Let's see the historic of moves of Jacques:
            Console.WriteLine("\nLet's see the historic of Jacques");
            game.ShowHistoric("Jacques");

            //Let's see if we can delete the last move of Jacques
            Console.WriteLine("\nLet's try to delete the last move of Jacques");
            game.Restore("Jacques");
            game.ShowHistoric("Jacques");
            #endregion
        }
 public void SetUp()
 {
     var monopoly = new Monopoly();
     monopoly.SetUpProperties();
 }
 public void SetUp()
 {
     _gameOfMonoploy = new Monopoly();
     _gameOfMonoploy.SetUpProperties();
     _player = new Player("Josh");
 }
Exemplo n.º 36
0
        //Sarsa algorithm
        private double Sarsa(Observation lastState, Monopoly.RLClasses.Action lastAction, Observation newState, Monopoly.RLClasses.Action newAction, double reward)
        {
            double QValue = network.Run(createInput(lastState, lastAction.action)).First();

            //run network for last state and last action
            double previousQ = QValue;

            //run network for new state and best action
            double newQ = network.Run(createInput(newState, newAction.action)).First();

            QValue += alpha * (reward + gamma * newQ - previousQ);

            return QValue;
        }
Exemplo n.º 37
0
        //Update traces -- qlearning---Peng's Q(λ)
        private bool updateQTraces(Observation obs, Monopoly.RLClasses.Action a, double reward)
        {
            bool found = false;

            //Since the state space is huge we'll use a similarity function to decide whether two states are similar enough
            for (int i = 0; i < traces.Count; i++)
            {
                if (checkStateSimilarity(obs,traces[i].observation) && (!a.action.Equals(traces[i].action.action)))
                {
                    traces[i].value = 0;
                    traces.RemoveAt(i);
                    i--;

                }
                else if (checkStateSimilarity(obs, traces[i].observation) && (a.action.Equals(traces[i].action.action)))
                {
                    found = true;

                    traces[i].value = 1 ;

                    //Q[t] (s,a)
                    double qT = network.Run(createInput(traces[i].observation, traces[i].action.action))[0];

                    //maxQ[t] (s[t+1],a)
                    int act = findMaxValues(calculateQValues(obs));
                    double maxQt = network.Run(createInput(obs, act))[0];

                    //maxQ[t] (s[t],a)
                    act = findMaxValues(calculateQValues(lastState));
                    double maxQ = network.Run(createInput(lastState, act))[0];

                    //Q[t+1] (s,a) = Q[t] (s,a) + alpha * ( trace[i].value ) * ( reward + gamma * maxQ[t] (s[t+1],a) * maxQ[t] (s[t],a))
                    double qVal = qT + alpha * (traces[i].value) * (reward + gamma * maxQt - maxQ);

                    trainNeural(createInput(traces[i].observation, traces[i].action.action), qVal);

                }
                else
                {
                    traces[i].value = gamma * lamda * traces[i].value;

                    //Q[t] (s,a)
                    double qT = network.Run(createInput(traces[i].observation, traces[i].action.action))[0];

                    //maxQ[t] (s[t+1],a)
                    int act = findMaxValues(calculateQValues(obs));
                    double maxQt = network.Run(createInput(obs, act))[0];

                    //maxQ[t] (s[t],a)
                    act = findMaxValues(calculateQValues(lastState));
                    double maxQ = network.Run(createInput(lastState, act))[0];

                    //Q[t+1] (s,a) = Q[t] (s,a) + alpha * ( trace[i].value ) * ( reward + gamma * maxQ[t] (s[t+1],a) * maxQ[t] (s[t],a))
                    double qVal = qT + alpha * (traces[i].value) * (reward + gamma * maxQt - maxQ);

                    trainNeural(createInput(traces[i].observation, traces[i].action.action), qVal);
                }
            }

            return found;
        }
Exemplo n.º 38
0
 //Update traces  -- sarsa
 private bool updateSTraces(Observation obs, Monopoly.RLClasses.Action a)
 {
     return false;
 }
 private static void FreshBoard()
 {
     Board.Access().ResetBoard();
     // Need to add all properties to board
     var monopoly = new Monopoly();
     monopoly.SetUpProperties();
 }
Exemplo n.º 40
0
 public void Events()
 {
     // Check logs correct output to console
     Monopoly.playerBankruptHandler(_player1, EventArgs.Empty);
     Monopoly.playerPassGoHandler(_player1, EventArgs.Empty);
 }
        static void Main(string[] args)
        {
            Game game = new Monopoly();

            game.InitialiseGame();
        }
Exemplo n.º 42
0
        public static void Test()
        {
            GameObject game = new Monopoly();

            game.PlayOneGame(2);
        }