public void RunGameLogic_AgentTurnSelfCheck()
        {
            using (var game = new GamePage())
            {
                var moves = new[]{
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                };

                foreach (var move in moves)
                {
                    var prevState = game.GridState;
                    var expected = GameLogic.MakeMove(prevState, move);
                    game.Turn(move);

                    var actual = game.GridStateNoNew;

                    if (expected.ToString() != actual.ToString())
                    {
                        Console.WriteLine("Failed selfcheck");
                        Console.WriteLine(prevState);
                        Console.WriteLine(move);
                        Console.WriteLine(actual);
                    }
                }

            }
        }
Exemplo n.º 2
0
        public PathGridXna(GamePage parent, int width, int height)
            : base(width, height, defaultCellSize)
        {
            this.parent = parent;

            this.camera = new Camera2D(SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport);
        }
Exemplo n.º 3
0
    public void GoToPage(PageType pageType)
    {
        if (_currentPageType == pageType)
                        return;

                Page pageToCreate = null;

                if (pageType == PageType.MenuPage)
                {
                    pageToCreate = new MainMenuPage();
                }

                if (pageType == PageType.GamePage)
                {
                        pageToCreate = new GamePage ();
                }

                if (pageType == PageType.FinalPage)
                {
                        pageToCreate = new FinalPage ();
                }

                if (pageToCreate != null) {
                        _currentPageType = pageType;

                        if (_currentPage != null) {
                            _stage.RemoveAllChildren();
                        }

                        _currentPage = pageToCreate;
                        _stage.AddChild (_currentPage);
                        _currentPage.Start ();
                }
    }
        public void RunGameLogic_WorldTurnSelfCheck()
        {
            using (var game = new GamePage())
            {
                var moves = new[]{
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                    Move.Up, Move.Left, Move.Down, Move.Right,
                };

                foreach (var move in moves)
                {
                    game.Turn(move);
                    if (game.NewEl == 4)
                        continue;

                    var state = game.GridStateNoNew;
                    var possibleStates = GameLogic.NextPossibleWorldStates(state);

                    var actual = game.GridState;
                    if (possibleStates.All(s => s.ToString() != actual.ToString()))
                    {
                        Console.WriteLine("Failed selfcheck");
                        Console.WriteLine(game.GridStateNoNew);
                        Console.WriteLine(actual);
                    }
                }

            }
        }
Exemplo n.º 5
0
    public void GoToPage(GamePage page)
    {
        switch (page)
        {
            case GamePage.MainMenu:
                mainMenu.SetActive(true);
                instructionsMenu.SetActive(false);
                playArea.SetActive(false);

                //levelManager.Init();

                break;

            case GamePage.Instructions:
                mainMenu.SetActive(false);
                instructionsMenu.SetActive(true);
                playArea.SetActive(false);

                instructionsMenu.GetComponent<Instructions>().StartAnimation();
                break;

            case GamePage.PlayArea:
                mainMenu.SetActive(false);
                instructionsMenu.SetActive(false);
                playArea.SetActive(true);
                break;
        }
    }
Exemplo n.º 6
0
    public void GoToPage(GamePageType pageType)
    {
        if (currentPageType == pageType)
        {
            return;
        }

        GamePage pageToCreate = null;
        switch (pageType)
        {
            case GamePageType.MissionPage:
                pageToCreate = new MissionPage();
                break;
            default:
                break;
        }

        if (pageToCreate != null)
        {
            currentPageType = pageType;

            if (currentPage != null)
            {
                Futile.stage.RemoveChild(currentPage);
            }

            currentPage = pageToCreate;
            Futile.stage.AddChild(currentPage);
            currentPage.Start();
        }
    }
Exemplo n.º 7
0
    public static FContainer getGameUIContainer(GamePage game)
    {
        if (GameUIContainer == null)
        {
            GameUIContainer = new FContainer();

            // add background
            FSprite bg = new FSprite("UI_background.png");
            bg.x = 0;
            bg.y = Futile.screen.halfHeight - (bg.height / 2);
            GameUIContainer.AddChildAtIndex(bg, 99);

            // add minimap
            GameUIContainer.AddChild(game._dungeon.minimap);

            // add gold count
            playerGold.text = "g: " + game.player.GoldCount;
            playerGold.x += -140;
            playerGold.y += Futile.screen.halfHeight - 20;
            GameUIContainer.AddChild(playerGold);

            // add sanity count
            playerSanity.text = game.player.HP.ToString();
            playerSanity.x += 260;
            playerSanity.y += Futile.screen.halfHeight - 60;
            GameUIContainer.AddChild(playerSanity);

            return GameUIContainer;
        }
        else return GameUIContainer;
    }
Exemplo n.º 8
0
        public void GamePage_GameButton_Clicked_Default_Should_Pass()
        {
            // Arrange

            var page = new GamePage();

            // Act
            page.GameButton_Clicked(null, null);

            // Reset

            // Assert
            Assert.IsTrue(true); // Got to here, so it happened...
        }
Exemplo n.º 9
0
        public void GamePage_Get_Default_Should_Pass()
        {
            // Arrange

            var page = new GamePage();

            // Act
            var result = page.Content;

            // Reset

            // Assert
            Assert.NotNull(result);
        }
Exemplo n.º 10
0
        public void GamePage_OnBindingContextChanged_Default_Should_Pass()
        {
            // Arrange

            var page = new GamePage();

            // Act
            OnBindingContextChanged();

            // Reset

            // Assert
            Assert.IsTrue(true);
        }
Exemplo n.º 11
0
        public void GamePage_Constructor_Default_Should_Pass()
        {
            // Arrange
            MockForms.Init();
            var page = new GamePage();

            // Act
            var result = page.Content;

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 12
0
        public void Can_make_offline_deposit_and_view_updated_balance_on_game_page()
        {
            // register a player on member website
            _playerData = _container.Resolve <PlayerTestHelper>().CreatePlayerForMemberWebsite("CAD");
            _username   = _playerData.Username;
            _password   = _playerData.Password;

            //check empty balance of the player
            _memberWebsiteLoginPage = new MemberWebsiteLoginPage(_driver);
            _memberWebsiteLoginPage.NavigateToMemberWebsite();
            _playerProfilePage = _memberWebsiteLoginPage.Login(_username, _password);

            _gameListPage = _playerProfilePage.Menu.ClickPlayGamesMenu();
            _gamePage     = _gameListPage.StartGame("Football");
            var initialBalance = _gamePage.Balance;

            Assert.AreEqual("Balance: $0.00", initialBalance);


            var playerName = _gamePage.PlayerName;
            var expectedPlayerLoginName = String.Format("Name: {0}", _playerData.Username);

            Assert.AreEqual(expectedPlayerLoginName, playerName);

            // login to admin website and make an offline deposit request
            _driver.Manage().Cookies.DeleteAllCookies();
            var dashboardPage = _driver.LoginToAdminWebsiteAsSuperAdmin();

            _driver.MakeOfflineDeposit(_username, Amount, _playerData.FullName);

            var playerManagerPage = dashboardPage.Menu.ClickPlayerManagerMenuItem();
            var playerInfoPage    = playerManagerPage.OpenPlayerInfoPage(_username);

            playerInfoPage.OpenTransactionsSection();

            Assert.AreEqual(Amount, playerInfoPage.GetTransactionMainAmount("Deposit"));

            // check the balance on the member website
            _memberWebsiteLoginPage = new MemberWebsiteLoginPage(_driver);
            _memberWebsiteLoginPage.NavigateToMemberWebsite();

            _playerProfilePage = _memberWebsiteLoginPage.Login(_username, _password);
            var gameListPage = _playerProfilePage.Menu.ClickPlayGamesMenu();

            _gamePage = gameListPage.StartGame("Football");
            var currentBalance = _gamePage.Balance;

            Assert.AreEqual("Balance: $100.25", currentBalance);
        }
Exemplo n.º 13
0
        public GHMenuPage(GamePage gamepage, GHWindow ghwindow)
        {
            InitializeComponent();
            //TestView.ItemsSource = MenuItems;
            MenuView.ItemsSource = MenuItems;
            _clientGame          = gamepage.ClientGame;
            _gamePage            = gamepage;
            _ghwindow            = ghwindow;

            Assembly assembly = GetType().GetTypeInfo().Assembly;

            myImage.Source  = ImageSource.FromResource("GnollHackClient.Assets.button_normal.png", assembly);
            myImage2.Source = ImageSource.FromResource("GnollHackClient.Assets.button_normal.png", assembly);
            //BackgroundImage.Source = ImageSource.FromResource("GnollHackClient.Assets.UI.menubackground.png", assembly);
        }
Exemplo n.º 14
0
        public MainPageViewModel()
        {
            BeginGameCommand = new Command(async() =>
            {
                var gameGrid = new GameGrid()
                {
                    SliderValue = SliderLevel
                };
                var gameViewModel       = new GamePageViewModel(gameGrid);
                var gamePage            = new GamePage(gameViewModel);
                gamePage.BindingContext = gameViewModel;

                await Application.Current.MainPage.Navigation.PushAsync(gamePage);
            });
        }
Exemplo n.º 15
0
        private void AddGamePage(string alias, WarcraftVersion version, PackageGroup group, SerializedTree nodeTree)
        {
            var page = new GamePage(group, nodeTree, version, alias);

            page.FileLoadRequested          += OnFileLoadRequested;
            page.SaveRequested              += OnSaveRequested;
            page.ExportItemRequested        += OnExportItemRequested;
            page.EnqueueFileExportRequested += OnEnqueueItemRequested;

            _gamePages.Add(page);
            _gameTabNotebook.AppendPage(page.PageWidget, new Label(page.Alias));
            _gameTabNotebook.SetTabReorderable(page.PageWidget, true);

            _gameTabNotebook.ShowAll();
        }
Exemplo n.º 16
0
 /// <summary>Closes the Page.</summary>
 private void ClosePage()
 {
     if (!_blnStart)
     {
         GameState.GoBack();
     }
     else
     {
         GameState.CurrentUser = new User(_createUser);
         GameState.AllUsers.Add(new User(_createUser));
         GamePage gamePage = new GamePage();
         gamePage.NewUser();
         GameState.Navigate(gamePage);
     }
 }
Exemplo n.º 17
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            this.SupportedOrientations = GamePage.get().SupportedOrientations;

            // Set the page's state according to the context
            if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
            {
                this.ViewModel   = NavigationContext.GetData <AlternativeRoutesPageViewModel>();
                this.DataContext = this.ViewModel;

                // And translate the page
                LanguageResources.Instance.UpdateControl(this);
            }
        }
Exemplo n.º 18
0
        public void Navigate(string page)
        {
            switch (page)
            {
            case "homepage":
                homePage = new HomePage();
                ApplicationHelper.NavigationService.Navigate(homePage);
                break;

            case "setuppage":
                setupPage = new SetupPage();
                ApplicationHelper.NavigationService.Navigate(setupPage);
                break;

            case "gamepage":
                gamePage = new GamePage();
                ApplicationHelper.NavigationService.Navigate(gamePage);
                break;

            case "leaderboardpage":
                leaderboardPage = new LeaderboardPage();
                ApplicationHelper.NavigationService.Navigate(leaderboardPage);
                break;

            case "adminpage":
                adminPage = new AdminPage();
                ApplicationHelper.NavigationService.Navigate(adminPage);
                break;

            case "boardsadminpage":
                boardsAdminPage = new BoardsAdminPage();
                ApplicationHelper.NavigationService.Navigate(boardsAdminPage);
                break;

            case "playersadminpage":
                playersAdminPage = new PlayersAdminPage();
                ApplicationHelper.NavigationService.Navigate(playersAdminPage);
                break;

            case "sessionsadminpage":
                sessionsAdminPage = new SessionsAdminPage();
                ApplicationHelper.NavigationService.Navigate(sessionsAdminPage);
                break;

            default:
                break;
            }
        }
Exemplo n.º 19
0
        private void Replay_Btn_Click(object sender, RoutedEventArgs e)
        {
            PokerTableBL pokerTable;
            var          serverResponse = MainWindow.client.GetTableByHistory(currTable);

            if (serverResponse.ErrorMsg == null)
            {
                pokerTable = serverResponse.Result;
                GamePage p = new GamePage(pokerTable.NumOfPlayers, pokerTable.Players.ToList(), pokerTable.MinBet, Wallet, true, currTable.Id);
                this.NavigationService.Navigate(p, UriKind.Relative);
            }
            else
            {
                MessageBox.Show("An unhandled exception just occurred: " + serverResponse.ErrorMsg, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 20
0
        public static void PageInit()
        {
            AdminMain   = new AdminMainPage();
            InquiryUser = new InquiryUserPage();
            //UpdateUser = new UpdateUserPage();
            PrintReport = new PrintReportPage();
            //UpdateUser = new UpdateUserPage();
            AdminLogin = new AdminLoginPage();

            Login = new LoginPage();

            Questionandgame = new QuesGameSeclectPage();
            Game            = new GamePage();
            Question1       = new QuestionPage1();
            Question2       = new QuestionPage2();
        }
        public GameLayer(float _dynamicWidth, float _dynamicHeight, IconStorageObject json, GamePage _gamePage) : base(CCColor4B.Gray)
        {
            this.Color          = CCColor3B.Gray;
            this.GamePageParent = _gamePage;
            this.mRandom        = new Random(DateTime.Now.Millisecond);

            spriteModelFactory = new SpriteMaker(_dynamicWidth, _dynamicHeight);

            MakeListener();

            MakeStaticSprites();

            LoadSprites(json);

            Schedule(RunGameLogic);
        }
Exemplo n.º 22
0
        public void SetupNavigation()
        {
            var homePage = new HomePage();

            AddChild(homePage);
            var mapPage = new MapPage();

            AddChild(mapPage);
            var gamePage = new GamePage();

            AddChild(gamePage);

            Navigator.Instance.RegisterPage(PageType.Home, homePage);
            Navigator.Instance.RegisterPage(PageType.Map, mapPage);
            Navigator.Instance.RegisterPage(PageType.Game, gamePage);
        }
Exemplo n.º 23
0
 public App()
 {
     InitializeComponent();
     auth = DependencyService.Get <IAuth>();
     if (auth.IsSignIn())
     {
         MainPage = new GamePage();
     }
     else
     {
         MainPage = new MainPage();
     }
     //Device.SetFlags(new[] { "Brush_Experimental" });
     //MainPage = new ShellApp();
     //MainPage = new NavigationPage(new Page1());
 }
Exemplo n.º 24
0
        private void AddGamePage(string alias, WarcraftVersion version, PackageGroup group, OptimizedNodeTree nodeTree)
        {
            GamePage page = new GamePage(group, nodeTree, version);

            page.Alias = alias;

            page.FileLoadRequested          += OnFileLoadRequested;
            page.ExportItemRequested        += OnExportItemRequested;
            page.EnqueueFileExportRequested += OnEnqueueItemRequested;

            this.GamePages.Add(page);
            this.GameTabNotebook.AppendPage(page.PageWidget, new Label(page.Alias));
            this.GameTabNotebook.SetTabReorderable(page.PageWidget, true);

            this.GameTabNotebook.ShowAll();
        }
Exemplo n.º 25
0
        public GameViewModel()
        {
            GamePage = new GamePage();
            GamePage.BindingContext = this;

            Images = new List <List <ImageWithCoordinates> >();
            for (int y = 0; y < 7; y++)
            {
                var list = new List <ImageWithCoordinates>();
                for (int x = 0; x < 11; x++)
                {
                    list.Add(new ImageWithCoordinates("Cross.png", x, y));
                }
                Images.Add(list);
            }
            OnPropertyChanged(nameof(Images));

            HandModel       = new HandModel();
            HandModel.Cards = new List <string>();

            for (int i = 0; i < 6; i++)
            {
                HandModel.Cards.Add("Cross.png");
            }
            HandModel.RoleImage = "blue_dwarf.png";

            OnPropertyChanged(nameof(HandModel));


            EquipmentList = new List <EquipmentModel>
            {
                new EquipmentModel
                {
                    Image = "lamp_fix.png"
                },
                new EquipmentModel
                {
                    Image = "pick_fix.png"
                },
                new EquipmentModel
                {
                    Image = "trolley_fix.png"
                },
            };
            OnPropertyChanged(nameof(EquipmentList));
        }
Exemplo n.º 26
0
 public void GoToMainMenu()
 {
     //End the game completely if running
     if (MainFrame.Content is GamePage)
     {
         GameGridManager.Clear();
         GamePage gp = (GamePage)MainFrame.Content;
         gp.EndGame();
     }
     //Clear the overlay frame
     ClearOverlayFrame();
     //Clear the main frame
     while (MainFrame.CanGoBack)
     {
         MainFrame.GoBack();
     }
 }
Exemplo n.º 27
0
        public void RunSimulation()
        {
            var agent = new OptiminiOptimaxAgent(Heuristic.AllRotatiions(Heuristic.CornerVave));

            for (int i = 0; i < 10; i++)
            using (var game = new GamePage())
            {
                while (game.CanMove)
                {
                    var move = agent.MakeDecision(game.GridState);
                    game.Turn(move);
                }

                game.TakeScreenshot().SaveAsFile("game_" + game.Score + ".png", ImageFormat.Png);
                Console.WriteLine(game.Score);
            }
        }
Exemplo n.º 28
0
        /// <summary> Changes to the next game. </summary>
        public void NextGame()
        {
            ScoreInterface.Instance.ResetTimeBar();

            if (games.Count == 0)
            {
                ScoreInterface.Instance.SubmitScore();

                DialogManager.Instance.TheEnd();
            }
            else
            {
                gameChanger.IsEnabled = true;

                currentGame = gameFactory.GetGame(games.Dequeue());
            }
        }
Exemplo n.º 29
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            this.SupportedOrientations = GamePage.get().SupportedOrientations;

            if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
            {
                base.OnNavigatedTo(e);


                miniMenuItems = NavigationContext.GetData <List <WazeMenuItem> >();


                LanguageResources.Instance.UpdateControl(this);
            }

            base.OnNavigatedTo(e);
        }
Exemplo n.º 30
0
    private static void init()    // throws Exception
    {
        Logger.log("In init!!!!!!!!!!");
        //Class cls = Class.forName("CRunTime");
        Stream isData = Application.GetResourceStream(new Uri("/WazeWP7;component/resources/program.data.bin", UriKind.Relative)).Stream;

        Logger.log("program.data.bin:" + isData);
        CRunTime.init(isData);
        isData.Close();
        CRunTime.publishCallback("Cibyl.atexit");
        int c_start = CibylCallTable.getAddressByName("__start");

        Logger.log("Start: " + c_start);

        /*
         * This is the stack which will be used for all the C calls.
         */
        int c_sp = (CRunTime.memory.Length * 4) - 8;

        Logger.log("c_sp: " + c_sp);
        CibylCallTable.fcall(c_start, c_sp, 0, 0, 0, 0);

        /*
         * The blackberry menu button can be clicked on async when other waze tasks
         * are handled, and we want the response to be immediate. Thus we allocate a special
         * stack for the menu button clicks, to be used by the FreemapMainScreen object.
         */
        int c_malloc_stack = 0;

        try
        {
            c_malloc_stack = CibylCallTable.getAddressByName("roadmap_main_alloc_stack");
        }
        catch (Exception e)
        {
            Logger.log("could not call c_malloc_stack" + e.ToString());
            safe_exit();
            //MessageBox.Show("Exception in c_malloc_stack");
        }
        if (c_malloc_stack != 0)
        {
            int stackAddress = CibylCallTable.fcall(c_malloc_stack, c_sp, 4096, 0, 0, 0);
            GamePage.setStackAddress(stackAddress);
        }
    }
Exemplo n.º 31
0
 public void Init(
     SoundManager soundManager,
     MessageItemsController messageItemsController,
     ShipsManager shipsManager,
     SessionDataManager sessionDataManager,
     GridManager gridManager,
     GamePage gamePage)
 {
     _soundManager           = soundManager;
     _messageItemsController = messageItemsController;
     _shipsManager           = shipsManager;
     _sessionDataManager     = sessionDataManager;
     _gridManager            = gridManager;
     _gamePage          = gamePage;
     _userGridCells     = _gridManager.UserGrid;
     _computerGridCells = _gridManager.ComputerGrid;
     _gridSize          = _gridManager.GridSize;
 }
Exemplo n.º 32
0
 /// <summary>
 /// Initializes the given values of grid, rows, cols, gamepage, firstcard and secondcard.
 /// calls InitializeGameGrid(cols, rows);
 /// Puts new images or loads images in depending if loadGame is true.
 /// </summary>
 /// <param name="grid"></param>
 /// <param name="cols"></param>
 /// <param name="rows"></param>
 /// <param name="backImages"></param>
 /// <param name="gamePage"></param>
 /// <param name="loadGame"></param>
 /// <param name="firstCard"></param>
 /// <param name="secondCard"></param>
 public MemoryGrid(Grid grid, int cols, int rows, List <Image> backImages, GamePage gamePage, bool loadGame, Image firstCard, Image secondCard)
 {
     this.rows       = rows;
     this.cols       = cols;
     this.grid       = grid;
     this.gamePage   = gamePage;
     this.firstCard  = firstCard;
     this.secondCard = secondCard;
     InitializeGameGrid(cols, rows);
     if (loadGame)
     {
         LoadImages(backImages);
     }
     else
     {
         AddImages();
     }
 }
Exemplo n.º 33
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            // Start with calling the base implementation
            base.OnNavigatedTo(e);

            this.SupportedOrientations = GamePage.get().SupportedOrientations;

            // Replace the context only if it's not null. A null context should mean we were backed to the page
            if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
            {
                this.pageContext = NavigationContext.GetData <SingleSearchPageContext>();
                LanguageResources.Instance.UpdateControl(this);
            }

            // Make sure the message grids are collapsed
            InProgressGrid.Visibility = System.Windows.Visibility.Collapsed;
            MessageGrid.Visibility    = System.Windows.Visibility.Collapsed;
        }
Exemplo n.º 34
0
        private static void ReportStat(string eventName, string exceptionName, string details)
        {
            try
            {
                var tableName = "WazeStatLog";

                string lang = "";

                try
                {
                    lang = LanguageResources.Instance.CurrentLanguage;
                }
                catch (Exception)
                {
                    // cross thread access to IsolatedStorage can cause exception here - just ignore it
                }

                var wazeStatLog = new WazeStatLog
                {
                    DeviceID   = deviceID,
                    Lang       = lang,
                    Ver        = GamePage.get().GetAppVersion(),
                    DeviceType = Microsoft.Phone.Info.DeviceStatus.DeviceName,
                    Event      = eventName,
                    Details    = details,
                    Timestamp  = DateTime.Now
                };

                context.AddObject(tableName, wazeStatLog);


                context.BeginSaveChanges(
                    asyncResult =>
                {
                    TableSaveCallBack(context, asyncResult);
                },
                    null);
            }
            catch (Exception exc)
            {
                System.Diagnostics.Debug.WriteLine(exc.ToString());
            }
        }
Exemplo n.º 35
0
 public void RunSimulation()
 {
     using (var game = new GamePage())
     {
         Console.WriteLine(game.GridState);
         game.Turn(Move.Up);
         Console.WriteLine("Up");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Left);
         Console.WriteLine("Left");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Down);
         Console.WriteLine("Down");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Right);
         Console.WriteLine("Right");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Up);
         Console.WriteLine("Up");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Left);
         Console.WriteLine("Left");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Down);
         Console.WriteLine("Down");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Right);
         Console.WriteLine("Right");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Up);
         Console.WriteLine("Up");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Left);
         Console.WriteLine("Left");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Down);
         Console.WriteLine("Down");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Right);
         Console.WriteLine("Right");
         Console.WriteLine(game.GridState);
     }
 }
Exemplo n.º 36
0
        private void ADGame(object sender, RoutedEventArgs e)
        {
            GamePage mygame = new GamePage();

            mygame.ParentWindow    = ParentWindow;
            mygame.GameHeight      = 20;
            mygame.GameWidth       = 10;
            mygame.ADmode          = true;
            mygame.ADmodeDiffculyt = 20;
            mygame.outterLayer     = 5;
            mygame.GameDiffculty   = 10;

            mygame.reveal_partone.Height     = 0;
            mygame.reveal_partone.Visibility = Visibility.Hidden;
            mygame.reveal_parttwo.Height     = 0;
            mygame.reveal_parttwo.Visibility = Visibility.Hidden;


            ParentWindow.Content = mygame;
        }
Exemplo n.º 37
0
        public static Tile GenerateTile(int power, Coordinates coordinates) // generate tile with specific power in specific cell
        {
            Tile t = new Tile();

            t.CurrentState = Tile.State.Normal; // regular tile
            t.Visibility   = Visibility.Hidden;
            t.Uid          = Guid.NewGuid().ToString();
            t.Content      = Math.Pow(BASE, power); // calc number on tile
            GamePage.SetTileStyleByPower(t, power); // set tile style depend on power

            // setting grid row and column
            Grid.SetRow(t, coordinates.Row);
            Grid.SetColumn(t, coordinates.Column);

            gameBoardGrid.Children.Add(t); // add to game grid

            t.Visibility = Visibility.Visible;
            Tile.Count++; // increasing total count of tiles
            return(t);
        }
Exemplo n.º 38
0
 private static void RunGameInBrowser()
 {
     using (var game = new GamePage())
     {
         var agent = new Agent(game.GridState, new ProbabilityLimitedExpectiMaxerFactory(), new VictorHeuristic());
         try
         {
             while (true)
             {
                 var result = agent.MakeDecision();
                 game.Turn(result.BestMove);
                 agent.UpdateGrid(game.GridState);
             }
         }
         catch (GameOverException)
         {
             game.TakeScreenshot().SaveAsFile("game_" + game.Score + ".png", ImageFormat.Png);
             Console.WriteLine(game.Score);
         }
     }
 }
Exemplo n.º 39
0
        /// <summary>
        /// Handler appelé lors d'un click sur l'un des item du menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menu = ((MenuItem)e.Source);

            if (menu == NewGame)
            {
                if (game == null)
                {
                    game = GamePage.GamePageInstance;
                }
                MainFrame.Navigate(game);
            }
            if (menu == Options)
            {
                if (options == null)
                {
                    options = OptionsPage.OptionsPageInstance;
                }
                MainFrame.Navigate(options);
            }
        }
Exemplo n.º 40
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            var gamePage = Window.Current.Content as GamePage;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (gamePage == null)
            {
                // Create a main GamePage
                gamePage = new GamePage(args.Arguments);

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                // Place the GamePage in the current Window
                Window.Current.Content = gamePage;
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }
Exemplo n.º 41
0
    public void GoToPage(PageType pageType)
    {
        Page pageToCreate = null;

            _currentPageType = pageType;

            if(_currentPage != null)
            {
                _stage.RemoveChild(_currentPage);
            }

            if (pageType == PageType.GamePage)
                pageToCreate = new GamePage();

            _currentPage = pageToCreate;
            _stage.AddChild(_currentPage);
            _currentPage.Start();
    }
Exemplo n.º 42
0
 private void new_game(object sender, EventArgs e)
 {
     Form view = new GamePage(_startedGame);
     view.Show();
 }
Exemplo n.º 43
0
 public void Dispose()
 {
     parent = null;
 }
Exemplo n.º 44
0
 public TileMap(GamePage gp)
 {
     CurrentPage = gp;
     Rows = 32;
     Columns = 18;
 }
Exemplo n.º 45
0
 public void RunSimulation()
 {
     using (var game = new GamePage())
     {
         Console.WriteLine(game.GridState);
         game.Turn(Move.Up);
         Console.WriteLine("Up");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Left);
         Console.WriteLine("Left");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Down);
         Console.WriteLine("Down");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Right);
         Console.WriteLine("Right");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Up);
         Console.WriteLine("Up");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Left);
         Console.WriteLine("Left");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Down);
         Console.WriteLine("Down");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Right);
         Console.WriteLine("Right");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Up);
         Console.WriteLine("Up");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Left);
         Console.WriteLine("Left");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Down);
         Console.WriteLine("Down");
         Console.WriteLine(game.GridState);
         game.Turn(Move.Right);
         Console.WriteLine("Right");
         Console.WriteLine(game.GridState);
     }
 }