コード例 #1
0
ファイル: Stage.cs プロジェクト: 20chan/wd-solver
        public Stage(Cell[][] map, int truckAmount)
        {
            _map  = map;
            car   = new Car(truckAmount);
            Debug = new StageDebugger(this);

            Width  = map[0].Length;
            Height = map.Length;

            g = new Graph(Width, Height);

            var houses = new List <Vec>();
            var tanks  = new List <Vec>();

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    var p = map[y][x];

                    switch (p)
                    {
                    case WayPoint w:
                        if (w.Value == 1)
                        {
                            xy = new Vec(x, y);
                        }
                        else if (w.Value == 99)
                        {
                            endpoint = new Vec(x, y);
                        }
                        break;

                    case Tank t:
                        tanks.Add(new Vec(x, y));
                        break;

                    case House h:
                        houses.Add(new Vec(x, y));
                        break;
                    }
                }
            }

            this.houses = houses.ToArray();
            this.tanks  = tanks.ToArray();
        }
コード例 #2
0
ファイル: Solver.cs プロジェクト: 20chan/wd-solver
 public bool TrySolveOneDefaultDirs(out Stage stage, out int step)
 {
     var dirs0 = new Vec[] { Vec.LEFT, Vec.RIGHT, Vec.UP, Vec.DOWN };
     var dirs1 = new Vec[] { Vec.DOWN, Vec.UP, Vec.RIGHT, Vec.LEFT };
     var tasks = new Task <(bool, int, Stage)>[] { TrySolveOne(dirs0), TrySolveOne(dirs1) };