예제 #1
0
 public Vehicle(char identity, int x, int y)
 {
     this.identity = identity;
     this.startPos = new Position(x, y);
     this.length = 1;
     this.direction = Direction.Horizontal;
 }
예제 #2
0
 // Deep copy passed vehicle
 public Vehicle(Vehicle vehicle)
 {
     this.length = vehicle.length;
     this.direction = vehicle.direction;
     this.identity = vehicle.identity;
     this.startPos = vehicle.startPos;
 }
예제 #3
0
파일: Move.cs 프로젝트: RobertDiep/RushHour
        public Position NewStartPos()
        {
            Position pos = movingVehicle.startPos;
            if (movingVehicle.direction == Vehicle.Direction.Horizontal)
            {
                pos = new Position(pos.X + delta, pos.Y);
            }
            else
            {
                pos = new Position(pos.X, pos.Y + delta);
            }

            return pos;
        }
예제 #4
0
        static void Main(string[] args)
        {
            Game.OutputMode outputMode = (Game.OutputMode)int.Parse(Console.ReadLine());
            int boardHeight = int.Parse(Console.ReadLine());

            int yTarget = int.Parse(Console.ReadLine());
            int xTarget = int.Parse(Console.ReadLine());

            Position targetPos = new Position(xTarget, yTarget);

            string[] boardString = new string[boardHeight];

            for (int i = 0; i < boardHeight; i++)
            {
                boardString[i] = Console.ReadLine();
            }

            for (int threadCount = 4; threadCount <= 4; threadCount += 2)
            {
                Console.WriteLine(threadCount);
                System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
                stopWatch.Start();

                for (int i = 0; i < 100; i++)
                {
                    Game g = new Game(outputMode, targetPos, boardString);
                    g.Start(threadCount);
                }

                stopWatch.Stop();

                TimeSpan ts = stopWatch.Elapsed;

                // Format and display the TimeSpan value.
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                    ts.Hours, ts.Minutes, ts.Seconds,
                    ts.Milliseconds / 10);
                Console.WriteLine("RunTime " + elapsedTime);
            }

            Console.ReadKey();
        }
예제 #5
0
파일: Game.cs 프로젝트: RobertDiep/RushHour
 public Game(OutputMode outputMode, Position targetPos, string[] boardString)
 {
     this.outputMode = outputMode;
     this.targetPos = targetPos;
     this.board = new Board(this, boardString);
 }