Пример #1
0
        public static void Init()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            FastCoord.Init();

            for (int speed = 0; speed <= Constants.MAX_SHIP_SPEED; speed++)
            {
                for (int orientation = 0; orientation < 6; orientation++)
                {
                    for (int x = 0; x < Constants.MAP_WIDTH; x++)
                    {
                        for (int y = 0; y < Constants.MAP_HEIGHT; y++)
                        {
                            foreach (var moveCommand in ShipMoveCommands.all)
                            {
                                var shipPosition  = new ShipPosition(new Coord(x, y), orientation, speed);
                                var nextPositions = shipPosition.Apply(moveCommand);
                                if (nextPositions.Count != 2)
                                {
                                    throw new InvalidOperationException("nextPositions.Count != 2");
                                }
                                var fastShipPosition = Create(shipPosition);
                                var moved            = 0u;
                                for (int phase = 0; phase < nextPositions.Count; phase++)
                                {
                                    moved = unchecked ((moved << 16) | (uint)Create(nextPositions[phase]));
                                }
                                moves[fastShipPosition | ((int)moveCommand << positionBits)] = moved;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
 public static int Create(ShipPosition position)
 {
     return(Create(position.coord.x, position.coord.y, position.orientation, position.speed));
 }