示例#1
0
        public TetrisForm(MainModel model)
        {
            mapHistory = model;
            mapHistory.History.Updated += UpdateAll;
            mapHistory.Suggestions.Updated += () => suggest.Text = "Oracle " + mapHistory.Suggestions.Position;
            grid = new Grid(mapHistory);
            this.KeyPreview = true;
            runBotGame = new Button();
            runBotIteration = new Button();
            suggest = new Button();
            say = new Button();
            player = new ProgramPlayerControl(mapHistory);
            runBotIteration.Text = "Iter";
            runBotGame.Text = "Game";
            suggest.Text = "Oracle";
            say.Text = "Say";

            scores = new Label();
            help = new Label();
            help.Text = "UIOP — movement\r\nQW — rotate\r\nZ — undo\r\nAS — switch between maps\r\nCtrl+C — copy current commamds to clipboard";
            help.BackColor = Color.Black;
            help.Font = new Font("Arial", 10);
            help.ForeColor = Color.Yellow;

            grid.MovementRequested += Grid_MovementRequested1;

            Controls.Add(grid);
            Controls.Add(scores);
            Controls.Add(help);
            Controls.Add(runBotGame);
            Controls.Add(runBotIteration);
            Controls.Add(suggest);
            Controls.Add(player);
            Controls.Add(say);
            currentProblemIndex = Map.Id;

            runBotGame.Click += RunBotGame_Click;
            runBotIteration.Click += RunBotIteration_Click;
            suggest.Click += Suggest_Click;
            say.Click += Say_Click;

            keymap = new Dictionary<Keys, Directions>
            {
                [Keys.Q] = Directions.CCW,
                [Keys.W] = Directions.CW,
                [Keys.U] = Directions.W,
                [Keys.I] = Directions.SW,
                [Keys.O] = Directions.SE,
                [Keys.P] = Directions.E
            };
        }
示例#2
0
        public static void Main()
        {
            var phrases = new Phrases(Phrases.DefaultPowerWords);
            if (Directory.Exists("logs"))
                Directory.Delete("logs", true);
            var map = Problems.LoadProblems()[9].ToMap(0);

            var model = new MainModel() {FastForwardSteps = 1};
            var solver = new AdaptiveSolver(phrases);
            model.Solver = solver.fast;
            model.History = new History(map);
            var form = new TetrisForm(model) {FastForwardSteps = model.FastForwardSteps};
            form.MovementRequested = dir => { map.Unit.Move(dir); };
            Application.Run(form);
        }
示例#3
0
 public Grid(MainModel mapHistory)
 {
     this.mapHistory = mapHistory;
     penTypes = new Dictionary<Occupation, Pen>
     {
         [Occupation.Empty] = Pens.Black,
         [Occupation.Occupied] = Pens.Red,
         [Occupation.Unit] = Pens.LawnGreen,
     };
     brushTypes = new Dictionary<Occupation, Brush>
     {
         [Occupation.Empty] = Brushes.White,
         [Occupation.Occupied] = Brushes.Gray,
         [Occupation.Unit] = Brushes.LawnGreen,
     };
     DoubleBuffered = true;
     requestedLocation = null;
 }