Example #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var parameters = (TetrisInput)e.Parameter;

            generateGrid(TetrisSettings.Width, TetrisSettings.Height);
            this.boardOccupation = new bool[width, height];
            this.boardFills      = new Rectangle[width, height];
            this.game            = new TetrisGame(width, height);

            this.ann     = new ANN(ANNSettings.Weights, ANNSettings.Input, ANNSettings.Hidden);
            this.package = new PlacementPackage()
            {
                RemovedRows = 0
            };

            SolidColorBrush blackBrush = new SolidColorBrush(Colors.Black);

            for (int x = 0; x < this.width; x++)
            {
                for (int y = 0; y < this.height; y++)
                {
                    var block = new Rectangle();
                    block.Fill   = transparentBrush;
                    block.Stroke = blackBrush;
                    Grid.SetColumn(block, x);
                    Grid.SetRow(block, y);
                    board.Children.Add(block);
                    boardFills[x, y] = block;
                }
            }
        }
Example #2
0
 public TetrisPlayingANN(double[] weights, bool eval = true)
 {
     this.tetrisGame = new TetrisGame(TetrisSettings.Width, TetrisSettings.Height);
     this.ann        = new ANN(weights, ANNSettings.Input, ANNSettings.Hidden);
     if (eval)
     {
         this.Evaluate();
     }
 }
Example #3
0
 public TetrisPlayingANN(TetrisGame tetrisGame, ANN ann)
 {
     this.tetrisGame = tetrisGame;
     this.ann        = ann;
     this.Evaluate();
 }