예제 #1
0
파일: Form.cs 프로젝트: xoposhiy/icfpc2015
        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
파일: Grid.cs 프로젝트: xoposhiy/icfpc2015
 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;
 }