Пример #1
0
 public void ToggleMoveType()
 {
     if (moveType == MoveType.MOVE_POSITION)
         moveType = MoveType.NONE;
     else
         moveType = MoveType.MOVE_POSITION;
 }
        public CollisionType EvaluateNextMove(MoveType move, IFigure figure)
        {
            var collision = CollisionType.None;
            IFigure movedFigure;
            switch (move)
            {
                case MoveType.RowAdded:
                    collision = ResolveRowAdded();
                    break;
                case MoveType.MoveRight:
                    movedFigure = figure.MoveRight();
                    collision = ResolveMoveRight(movedFigure);
                    break;
                case MoveType.MoveLeft:
                    movedFigure = figure.MoveLeft();
                    collision = ResolveMoveLeft(movedFigure);
                    break;
                case MoveType.MoveDown:
                    movedFigure = figure.MoveDown();
                    collision = ResolveMoveDown(movedFigure);
                    break;
                case MoveType.TossDown:
                    // for now do nothing
                    break;
                case MoveType.Rotate:
                    var rotatedFigure = figure.RotateClockwise();
                    collision = ResolveRotate(rotatedFigure);
                    break;
                default:
                    throw new NotImplementedException("unknown movement type: " + move);
            }

            return collision;
        }
Пример #3
0
 //determine the outcome of the current move action
 void CheckProbabilities()
 {
     switch (movementType) {
     case MoveType.HORIZONTAL: {
         if (Random.value < probabilities.horizontal * indicatorMultiplier) {
             MoveLandSlide(-1);
         } else {
             movementType = MoveType.NONE;
             //probabilities.horizontal += 0.1f;
             //probabilities.vertical /= 1.5f;
         }
         break;
     }
     case MoveType.VERTICAL: {
         if (Random.value < probabilities.vertical * indicatorMultiplier) {
             MoveLandSlide(-2);
         } else {
             movementType = MoveType.NONE;
             probabilities.horizontal *= additionalLandSlideChance_vertical;
             probabilities.vertical *= additionalLandSlideChance_vertical;
         }
         break;
     }
     case MoveType.LANDSLIDE: {
         movementType = MoveType.NONE;
         ResetProbabilities();
         break;
         }
     }
 }
Пример #4
0
        public Ball(Color color, PointF point, float jumpSpeed, float radius, Frame frame, Direction direction)
        {
            this.pen = new Pen(color);
            this.frame = frame;
            this.x = point.X;
            this.y = point.Y;
            this.jumpSpeed = jumpSpeed;
            this.radius = radius;

            switch (direction)
            {
                case Direction.DOWN:
                    xmt = MoveType.Down;
                    ymt = MoveType.Down;
                    break;
                case Direction.LEFT:
                    xmt = MoveType.Up;
                    ymt = MoveType.Down;
                    break;
                case Direction.RIGHT:
                    xmt = MoveType.Down;
                    ymt = MoveType.Up;
                    break;
                case Direction.UP:
                    xmt = MoveType.Up;
                    ymt = MoveType.Up;
                    break;
            }
        }
 public bool CheckLastMove([NotNull] IList<MoveType> moves, MoveType lastMove)
 {
     if (lastMove == MoveType.NW || lastMove == MoveType.NE)
         return false;
     if (lastMove == MoveType.SW || lastMove == MoveType.SE)
         return true;
     if (symmetric == 1)
     {
         if (lastMove == MoveType.RotateCCW || lastMove == MoveType.RotateCW)
             return false;
         var prevMove = moves.Any() ? moves.Last() : (MoveType?)null;
         if (lastMove == MoveType.E && prevMove == MoveType.W)
             return false;
         if (lastMove == MoveType.W && prevMove == MoveType.E)
             return false;
         return true;
     }
     var used = new HashSet<Tuple<int, int>>();
     var position = Tuple.Create(0, 0);
     used.Add(position);
     position = ApplyMove(lastMove, position);
     if (position == null)
         throw new InvalidOperationException("Position couldn't be null here");
     used.Add(position);
     for (var i = moves.Count - 1; i >= 0; i--)
     {
         position = ApplyMove(moves[i], position);
         if (position == null)
             return true;
         if (!used.Add(position))
             return false;
     }
     return true;
 }
Пример #6
0
 public Vector(MoveType move, int y, int length = 1)
 {
     switch (move)
     {
         case MoveType.E:
             X = length;
             break;
         case MoveType.W:
             X = -length;
             break;
         case MoveType.SW:
             Y = length;
             X = GetWestDX(y, length);
             break;
         case MoveType.SE:
             Y = length;
             X = GetEastDX(y, length);
             break;
         case MoveType.NW:
             Y = -length;
             X = GetWestDX(y, length);
             break;
         case MoveType.NE:
             Y = -length;
             X = GetEastDX(y, length);
             break;
         default:
             throw new ArgumentOutOfRangeException(move.ToString(), move, null);
     }
 }
Пример #7
0
 public StateTypeSet(StateSystem statesystem, String label, TextSection textsection)
     : base(statesystem, label, textsection)
 {
     m_statetype = textsection.GetAttribute<StateType>("statetype", StateType.Unchanged);
     m_movetype = textsection.GetAttribute<MoveType>("movetype", MoveType.Unchanged);
     m_physics = textsection.GetAttribute<Physics>("Physics", Physics.Unchanged);
 }
Пример #8
0
        public ActionResult PlayAgainstFriend(MoveType moveOne, MoveType moveTwo, MoveType moveThree, Guid roundId)
        {
            // Play moves
            _bus.Send(new PlayMoves(Player.Id, roundId, moveOne, moveTwo, moveThree));

            return RedirectToAction("PlaySummary", "Player");
        }
Пример #9
0
        public void HandleInput(float dt)
        {
            float mvSpd = walkSpeed;

            if (myController.Sprint.Down && (currentMoveType == MoveType.RUN || currentMoveType == MoveType.WALK))
            {
                currentMoveType = MoveType.RUN;
                mvSpd = runSpeed;
            }
            else if (currentMoveType == MoveType.RUN)
            {
                currentMoveType = MoveType.WALK;
            }

            if (Math.Abs(myController.Movement.X) > 0.1f)
            {
                myMotion.X = myController.Movement.X * mvSpd;
            }
            else
            {
                myMotion.X = 0.0f;
            }

            if (Math.Abs(myController.Movement.Y) > 0.1f)
            {
                myMotion.Y = myController.Movement.Y * mvSpd;
            }
            else
            {
                myMotion.Y = 0.0f;
            }
        }
Пример #10
0
 public Move(Piece promoteTo, Coordinate from, Coordinate to)
 {
     m_moveType = MoveType.Promotion;
     m_promoteTo = promoteTo;
     m_from = from;
     m_to = to;
 }
Пример #11
0
 public bool isWall(MoveType type)
 {
     bool collide = false;
     switch (type)
     {
         case MoveType.Down:
             if (point.Y > GameConsole.Height)
             {
                 collide = true;
             }
             break;
         case MoveType.Up:
             if (point.Y >= 0){
                 collide = true;
             }
             break;
         case MoveType.Left:
             if (point.X <= 0 )
             {
                 collide = true;
             }
             break;
         case MoveType.Right:
             if (point.X > GameConsole.Width)
             {
                 collide = true;
             }
             break;
     }
     return collide;
 }
Пример #12
0
 public void PrepareForLanding(Vector2 landPosition, Vector2 planetPosition)
 {
     var method = new LandingMove (landPosition, planetPosition);
     method.Landed += MoveOnPlanet;
     actualMethod = method;
     type = MoveType.Landing;
 }
Пример #13
0
 public PageData(int pageLevel, Genre pageGenre, MoveType pageType, bool isRare)
 {
     m_pageLevel = pageLevel;
     m_pageGenre = pageGenre;
     m_pageType = pageType;
     m_isRare = isRare;
     m_inventoryId = -1;
 }
Пример #14
0
        public MoveResult(MoveType type, CheckersPiece piece, int nx, int ny)
        {
            Type = type;
            OriginalPieceLocation = new Location(piece.X, piece.Y);
            FinalPieceLocation = new Location(nx, ny);

            JumpResults = new List<JumpResult>();
        }
Пример #15
0
 public Move(int Piece, Position StartPosition, Position EndPosition, MoveType Type, Position MiddlePosition = Position.None)
 {
     this.Piece = Piece;
     this.StartPosition = StartPosition;
     this.EndPosition = EndPosition;
     this.MiddlePosition = MiddlePosition;
     this.Type = Type;
 }
Пример #16
0
    public void MoveOnPlanet(Vector2 planetPosition)
    {
        if (actualMethod is LandingMove)
            (actualMethod as LandingMove).Landed -= MoveOnPlanet;

        actualMethod = new LandMove (planetPosition);
        type = MoveType.LandMove;
    }
Пример #17
0
    internal void Move(MoveType type, TileController start, TileController stop) {
        string moveType = type == MoveType.Empty
            ? "MoveToEmpty"
            : type == MoveType.Merge ? "MoveToMerge" : type == MoveType.Attack ? "MoveToAttack" : "";

        _tcpClient.Send(string.Format("[Notify:{0}:{1}|({2}:{3})|({4}:{5})]", moveType, _guid, start.Position.x,
            start.Position.y, stop.Position.x, stop.Position.y));
    }
Пример #18
0
 public PageData(int pageLevel, Genre pageGenre, int inventoryId)
 {
     m_pageLevel = pageLevel;
     m_pageGenre = pageGenre;
     m_inventoryId = inventoryId;
     m_pageType = MoveType.None;
     m_isRare = false;
 }
Пример #19
0
 private CoordCmd(double? x, double? y, double? z, double? a, MoveType type)
 {
     Contract.Assert(x.HasValue || y.HasValue || z.HasValue || a.HasValue);
     X = x;
     Y = y;
     Z = z;
     A = a;
     Type = type;
 }
Пример #20
0
        /// <summary>
        /// Log a game move to the logging session
        /// </summary>
        /// <param name="player"></param>
        /// <param name="timeOfMove"></param>
        /// <param name="moveType"></param>
        public void LogMove(string player, int timeOfMove, MoveType moveType)
        {
            if (_gameData == null)
            {
                throw new InvalidOperationException("The logging session has not begun. Unable to log move.");
            }

            _gameData.AddGameMoveDataPoint(player, timeOfMove, moveType);
        }
Пример #21
0
        public Move(MoveType type, Coordinate from, Coordinate to)
        {
            if (type != MoveType.Standard && type != MoveType.PawnStart && type != MoveType.EnPassant && type != MoveType.CastleKingside && type != MoveType.CastleQueenside)
                throw new ArgumentException("type");

            m_moveType = type;
            m_from = from;
            m_to = to;
        }
Пример #22
0
        public bool MoveWon(MoveType move1, MoveType move2)
        {
            if ((move1 == MoveType.Punch && move2 == MoveType.Block) ||
                (move1 == MoveType.Kick && move2 == MoveType.Punch) ||
                (move1 == MoveType.Block && move2 == MoveType.Kick))
                return true;

            return false;
        }
Пример #23
0
        /// <summary>
        /// タイプ指定
        /// </summary>
        /// <param name="moveType"></param>
        public MoveData(MoveType moveType)
        {
            MoveType = moveType;

            this.ToSquare = 0;
            this.FromSquare = 0;
            this.Piece = Piece.NoPiece;
            this.CapturePiece = Piece.NoPiece;
        }
Пример #24
0
 private static RoundResult GetResult(MoveType player1Move, MoveType player2Move, bool isPlayer1Human)
 {
     return new RoundResult
     {
         Player1IsHuman = isPlayer1Human,
         Player1Move = player1Move,
         Player2Move = player2Move,
         Result = DetermineWinner(player1Move, player2Move)
     };
 }
Пример #25
0
        public ActionResult PlayPost(MoveType moveOne, MoveType moveTwo, MoveType moveThree)
        {
            var moveResults = new List<MoveResult> {
                new MoveResult { YourMove = moveOne, TheirMove = MoveType.Kick, Won = _moveCalc.MoveWon(moveOne, MoveType.Kick) },
                new MoveResult { YourMove = moveTwo, TheirMove = MoveType.Punch, Won = _moveCalc.MoveWon(moveTwo, MoveType.Punch) },
                new MoveResult { YourMove = moveThree, TheirMove = MoveType.Block, Won = _moveCalc.MoveWon(moveThree, MoveType.Block) }
            };

            return PlayResult(moveResults);
        }
Пример #26
0
        public ActionResult Play(MoveType moveOne, MoveType moveTwo, MoveType moveThree)
        {
            // 1. Create a round
            var roundId = Guid.NewGuid();
            _bus.Send(new CreateRound(roundId, RoundType.VsComputer));

            // 2. Play moves
            _bus.Send(new PlayMoves(Player.Id, roundId, moveOne, moveTwo, moveThree));

            return RedirectToAction("PlaySummary", "Player");
        }
Пример #27
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="board"></param>
 /// <param name="from"></param>
 /// <param name="to"></param>
 public Move(Board board, Square from, Square to)
 {
     m_moveType = MoveType.StandardMove;
       m_from = from;
       m_to = to;
       m_piece = board[from];
       m_capture = board[to];
       //m_promoteTo = Piece.None;
       //m_rookFrom = Square.None;
       //m_rookTo = Square.None;
 }
    protected override void OnTriggerEnter(Collider other)
    {
        if(other.name != GameObjectNameHelper.playerObjectName){return;}
        other.transform.parent = gameObject.transform;

        if(this.transform.position.y >= uperGoalVecY){
            moveType = MoveType.DOWN;
        }else if(this.transform.position.y <= 0){
            moveType = MoveType.UPER;
        }
        Debug.Log("move type ----> "+moveType);
    }
Пример #29
0
 protected string TypePrefix(MoveType type)
 {
     switch (type)
     {
         case MoveType.SendResources:
             return "Gửi từ";
         case MoveType.Return:
             return "Quay về từ";
         default:
             return "";
     }
 }
Пример #30
0
        public ActionResult PlayAgainstRegisteredFriend(MoveType moveOne, MoveType moveTwo, MoveType moveThree, long opponentId, Guid roundId)
        {
            // Play moves
            _bus.Send(new PlayMoves(Player.Id, roundId, moveOne, moveTwo, moveThree));

            // 3. Challenge opponents
            //note:How can we get rid of FB specific code?
            var opponent = _playerReadModel.GetFacebookPlayer(opponentId);
            _bus.Send(new ChallengeRegisteredFriend(Player.Id, roundId, opponent.Id));

            return RedirectToAction("PlaySummary", "Player");
        }
Пример #31
0
        private static void SightProcedure(int steps_r, int steps_f, Location l, int rs, int fs, MoveType mt)
        {
            int r = l.rank, f = l.file, steps;

            if (mt == MoveType.TELEPORTABLE)
            {
                steps = 1;
                r    += steps_r * rs;
                f    += steps_f * fs;
            }
            else
            {
                steps = Math.Max(steps_r, steps_f);
                r    += rs;
                f    += fs;
            }
            bool jumped = false;

            while (Location.Valid(r, f) && steps > 0)
            {
                int stack_height = piece.board.StackHeight(r, f);

                if (stack_height < Constants.MAX_TIERS && mt != MoveType.JUMP_ATTACK && !piece.board.ContainsMarshal(r, f))
                {
                    Location l_move = new Location(r, f, stack_height + 1);
                    piece.AddValidMoveAt(l_move);
                }

                if (stack_height > 0)
                {
                    if (!piece.IsFriendlyWith(piece.board.TopPieceAt(r, f)) && mt != MoveType.BLOCKABLE_PACIFIST && (mt != MoveType.JUMP_ATTACK || jumped))
                    {
                        Location l_attack = new Location(r, f, stack_height);
                        piece.AddValidAttackAt(l_attack);
                    }

                    if (mt == MoveType.JUMP_ATTACK && !jumped)
                    {
                        jumped = true;
                    }
                    else
                    {
                        break;
                    }
                }

                steps -= 1;
                if (steps == 1)
                {
                    r = l.rank + (steps_r * rs);
                    f = l.file + (steps_f * fs);
                }
                else
                {
                    r += rs;
                    f += fs;
                }
            }
        }
Пример #32
0
 public static void DisplayOpponentHand(MoveType hand)
 {
     Console.WriteLine(Messages.DialogueOpponentMove + _text.GetText(hand));
 }
Пример #33
0
        /// <summary>
        /// Constructor, should not be used by extern user, rather use <see cref="Move.FromUCI(Grid, string, Piece)
        /// </summary>
        /// <param name="start">Start tile <see cref="Tile"/></param>
        /// <param name="end">End tile <see cref="Tile"/></param>
        /// <param name="player">Player who made the move <see cref="Player"/></param>
        /// <param name="moveType">The Move movetype <see cref="MoveType"/></param>
        /// <param name="promotionPiece">A promotion piece if the movetype is Promotion</param>

        public Move(Tile start, Tile end, Player player, MoveType moveType = MoveType.Normal, Piece promotionPiece = null)
        {
            (Start, End, Player, MoveType, PromotionPiece) = (start, end, player, moveType, promotionPiece);
        }
Пример #34
0
 public virtual void DoWhenStay(Player player, MoveType moveType)
 {
 }
Пример #35
0
        public override void Execute(Npc npc)
        {
            if (Position == null)
            {
                Stop(npc);
                return;
            }
            bool  move   = false;
            float x      = npc.Position.X - Position.X;
            float y      = npc.Position.Y - Position.Y;
            float z      = npc.Position.Z - Position.Z;
            float MaxXYZ = Math.Max(Math.Max(Math.Abs(x), Math.Abs(y)), Math.Abs(z));
            float tempMovingDistance;

            if (Math.Abs(x) > distance)
            {
                if (MaxXYZ != Math.Abs(x))
                {
                    tempMovingDistance = Math.Abs(x) / (MaxXYZ / MovingDistance);
                    tempMovingDistance = Math.Min(tempMovingDistance, MovingDistance);
                }
                else
                {
                    tempMovingDistance = MovingDistance;
                }

                if (x < 0)
                {
                    npc.Position.X += tempMovingDistance;
                }
                else
                {
                    npc.Position.X -= tempMovingDistance;
                }
                if (Math.Abs(x) < tempMovingDistance)
                {
                    npc.Position.X = Position.X;
                }
                move = true;
            }
            if (Math.Abs(y) > distance)
            {
                if (MaxXYZ != Math.Abs(y))
                {
                    tempMovingDistance = Math.Abs(y) / (MaxXYZ / MovingDistance);
                    tempMovingDistance = Math.Min(tempMovingDistance, MovingDistance);
                }
                else
                {
                    tempMovingDistance = MovingDistance;
                }
                if (y < 0)
                {
                    npc.Position.Y += tempMovingDistance;
                }
                else
                {
                    npc.Position.Y -= tempMovingDistance;
                }
                if (Math.Abs(y) < tempMovingDistance)
                {
                    npc.Position.Y = Position.Y;
                }
                move = true;
            }
            if (Math.Abs(z) > distance)
            {
                if (MaxXYZ != Math.Abs(z))
                {
                    tempMovingDistance = Math.Abs(z) / (MaxXYZ / MovingDistance);
                    tempMovingDistance = Math.Min(tempMovingDistance, MovingDistance);
                }
                else
                {
                    tempMovingDistance = MovingDistance;
                }
                if (z < 0)
                {
                    npc.Position.Z += tempMovingDistance;
                }
                else
                {
                    npc.Position.Z -= tempMovingDistance;
                }
                if (Math.Abs(z) < tempMovingDistance)
                {
                    npc.Position.Z = Position.Z;
                }
                move = true;
            }


            //模拟unit / Simulated unit
            var type = (MoveTypeEnum)1;
            //返回moveType对象 / Return moveType object
            var moveType = (UnitMoveType)MoveType.GetType(type);

            //改变NPC坐标 / Changing NPC coordinates
            moveType.X                = npc.Position.X;
            moveType.Y                = npc.Position.Y;
            moveType.Z                = npc.Position.Z;
            moveType.Flags            = 5;
            moveType.DeltaMovement    = new sbyte[3];
            moveType.DeltaMovement[0] = 0;
            moveType.DeltaMovement[1] = 127;
            moveType.DeltaMovement[2] = 0;
            moveType.Stance           = 0;
            moveType.Alertness        = 2;
            moveType.Time             = Seq;


            if (move)
            {
                //广播移动状态 / Broadcasting Mobile State
                npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true);
                LoopDelay = 500;
                Repet(npc);
            }
            else
            {
                //停止移动 / Stop moving
                moveType.DeltaMovement[1] = 0;
                npc.BroadcastPacket(new SCOneUnitMovementPacket(npc.ObjId, moveType), true);
                LoopAuto(npc);
            }
        }
Пример #36
0
        private static void MakeBentMoves(int up_updiag, int side_updiag, int side_downdiag, int down_downdiag, int num_diag, MoveType mt)
        {
            Location location = piece.location;

            if (up_updiag > 1)
            {
                SightProcedure(up_updiag, up_updiag - num_diag, location, 1, 1, mt);
                SightProcedure(up_updiag, up_updiag - num_diag, location, 1, -1, mt);
            }
            if (side_updiag > 1)
            {
                SightProcedure(side_updiag - num_diag, side_updiag, location, 1, 1, mt);
                SightProcedure(side_updiag - num_diag, side_updiag, location, 1, -1, mt);
            }
            if (side_downdiag > 1)
            {
                SightProcedure(side_downdiag - num_diag, side_downdiag, location, -1, 1, mt);
                SightProcedure(side_downdiag - num_diag, side_downdiag, location, -1, -1, mt);
            }
            if (down_downdiag > 1)
            {
                SightProcedure(down_downdiag, down_downdiag - num_diag, location, -1, 1, mt);
                SightProcedure(down_downdiag, down_downdiag - num_diag, location, -1, -1, mt);
            }
        }
Пример #37
0
 private void Move(GamePoint point, MoveType moveType)
 {
     _game.Move(point, moveType);
     GetCell(point).MoveTypeOnCell = moveType;
 }
Пример #38
0
 public PlayerMove(string _name, MoveType _type, int _damage)
 {
     name   = _name;
     type   = _type;
     damage = _damage;
 }
Пример #39
0
 public Action(int rank)
 {
     this.move   = MoveType.Connect;
     this.rank   = rank;
     this.module = Player.me.module;
 }
Пример #40
0
 public Action(Molecule molecule)
 {
     this.move     = MoveType.Connect;
     this.molecule = molecule;
     this.module   = Player.me.module;
 }
Пример #41
0
 public Action(Sample sample)
 {
     this.move   = MoveType.Connect;
     this.sample = sample;
     this.module = Player.me.module;
 }
Пример #42
0
 public Action(Module module)
 {
     this.move   = MoveType.Goto;
     this.module = module;
 }
Пример #43
0
 public override string ToString()
 {
     return($"{MoveType.ToString()} {PointToString(KillPoint)}");
 }
Пример #44
0
        public IActionResult SubmitGeneratedPuzzle(string category, string last_pos, string last_move, string move_list, string variant)
        {
            Puzzle generated = new Puzzle();

            variant                     = Utilities.NormalizeVariantNameCapitalization(variant.Replace(" ", "").Replace("-", ""));
            generated.Variant           = variant;
            generated.Rating            = new Rating(1500, 350, 0.06);
            generated.ExplanationUnsafe = "Auto-generated puzzle. Category: " + category;
            generated.Author            = loginHandler.LoggedInUserId(HttpContext).Value;
            generated.Approved          = loginHandler.LoggedInUser(HttpContext).Roles.Contains(UserRole.GENERATOR);
            generated.InReview          = !generated.Approved;
            generated.Reviewers         = new List <int>();
            generated.DateSubmittedUtc  = DateTime.UtcNow;

            string[] lastPosParts = last_pos.Split(' ');
            if (lastPosParts.Length == 7)
            {
                string counter = lastPosParts[4];

                lastPosParts[4] = lastPosParts[5];
                lastPosParts[5] = lastPosParts[6];

                int[] counterParts   = counter.Split('+').Select(int.Parse).ToArray();
                int   whiteDelivered = 3 - counterParts[0];
                int   blackDelivered = 3 - counterParts[1];

                lastPosParts[6] = string.Format("+{0}+{1}", whiteDelivered, blackDelivered);
                last_pos        = string.Join(" ", lastPosParts);
            }

            ChessGame game = gameConstructor.Construct(generated.Variant, last_pos);

            MoveType moveType = game.ApplyMove(new Move(last_move.Substring(0, 2), last_move.Substring(2, 2), game.WhoseTurn, last_move.Length == 4 ? null : new char?(last_move[last_move.Length - 1])),
                                               false);

            if (moveType == MoveType.Invalid)
            {
                return(Json(new { success = false, error = "Invalid last_move." }));
            }

            string[] initialFenParts = game.GetFen().Split(' ');
            initialFenParts[4] = "0";
            initialFenParts[5] = "1";

            generated.InitialFen = string.Join(" ", initialFenParts);

            Puzzle possibleDuplicate = puzzleRepository.FindByFenAndVariant(generated.InitialFen, generated.Variant);

            if (possibleDuplicate != null)
            {
                return(Json(new { success = false, error = "This puzzle is a duplicate." }));
            }

            generated.Solutions = new List <string>()
            {
                string.Join(" ",
                            move_list.Split(' ')
                            .Select(x => string.Concat(
                                        x.Substring(0, 2),
                                        "-",
                                        x.Substring(2, 2),
                                        x.Length == 4 ? "" : "=" + x[x.Length - 1].ToString()
                                        )
                                    ))
            };

            generated.ID = counterRepository.GetAndIncrease(Counter.PUZZLE_ID);

            if (puzzleRepository.Add(generated))
            {
                return(Json(new { success = true, id = generated.ID }));
            }
            else
            {
                return(Json(new { success = false, error = "Failure when inserting puzzle in database." }));
            }
        }
Пример #45
0
 public MoveCommand(string gameObjectToMove, Vector3?vec, MoveType moveType)
 {
     this.gameObjectToMove = gameObjectToMove;
     this.vec      = vec;
     this.moveType = moveType;
 }
Пример #46
0
 public virtual void DoWhenPass(Player player, MoveType moveType)
 {
 }
Пример #47
0
 public List <Cell> Move(MoveType dig)
 {
     throw new NotImplementedException();
 }
Пример #48
0
 public Move(int x, int y, MoveType type)
 {
     X    = x;
     Y    = y;
     Type = type;
 }
Пример #49
0
        private static void MakeStraightMoves(int up, int updiag, int side, int downdiag, int down, MoveType mt)
        {
            Location location = piece.location;

            if (up > 0)
            {
                SightProcedure(up, 0, location, 1, 0, mt);
            }
            if (updiag > 0)
            {
                SightProcedure(updiag, updiag, location, 1, 1, mt);
                SightProcedure(updiag, updiag, location, 1, -1, mt);
            }
            if (side > 0)
            {
                SightProcedure(0, side, location, 0, 1, mt);
                SightProcedure(0, side, location, 0, -1, mt);
            }
            if (downdiag > 0)
            {
                SightProcedure(downdiag, downdiag, location, -1, 1, mt);
                SightProcedure(downdiag, downdiag, location, -1, -1, mt);
            }
            if (down > 0)
            {
                SightProcedure(down, 0, location, -1, 0, mt);
            }
        }
Пример #50
0
        /// <inheritdoc/>
        public void MoveObject(ILocateable obj, byte newX, byte newY, object moveLock, MoveType moveType)
        {
            var differentBucket = this.MoveObjectOnMap(obj, newX, newY, moveLock, moveType);

            if (obj is IObservable observable)
            {
                observable.ObserverLock.EnterReadLock();
                try
                {
                    observable.Observers.ForEach(o => o.WorldView.ObjectMoved(obj, moveType));
                }
                finally
                {
                    observable.ObserverLock.ExitReadLock();
                }
            }

            var observingPlayer = obj as IBucketMapObserver;

            if (differentBucket && observingPlayer != null)
            {
                this.UpdateObservingBuckets(newX, newY, observingPlayer);
            }
        }
Пример #51
0
        private static void AddBentMove(int t, int up_updiag, int side_updiag, int side_downdiag, int down_downdiag, int num_diag, MoveType mt)
        {
            if (piece.player.color == PlayerColor.BLACK)
            {
                int temp;
                temp = up_updiag; up_updiag = down_downdiag; down_downdiag = temp;
                temp = side_updiag; side_updiag = side_downdiag; side_downdiag = temp;
            }

            if (t == piece.acting_tier || t == 0 || piece.lt_sight)
            {
                MakeBentMoves(up_updiag, side_updiag, side_downdiag, down_downdiag, num_diag, mt);
            }
        }
Пример #52
0
        private float GetAgentSpeed(MoveType Action)
        {
            var speed = Agent.Movement.Speed(Action);

            return(GameSettings.Current.CreatureMovementAdjust * Agent.Stats.Dexterity * speed * SpeedAdjust);
        }
Пример #53
0
        // Must be updated after elevators
        private static void AddStraightMove(int t, int up, int updiag, int side, int downdiag, int down, MoveType mt)
        {
            if (piece.player.color == PlayerColor.BLACK)
            {
                int temp;
                temp = up; up = down; down = temp;
                temp = updiag; updiag = downdiag; downdiag = temp;
            }

            if ((t == piece.acting_tier) || (t == 0) || piece.lt_sight)
            {
                MakeStraightMoves(up, updiag, side, downdiag, down, mt);
            }
        }
Пример #54
0
 public virtual void StartCursorFollow()
 {
     movementType = MoveType.CursorFollow;
 }
 public override MoveEventResponse MoveBeingGenerated(MoveList moves, int from, int to, MoveType type)
 {
     if (pieceTypes.Contains(Board[from].PieceType))
     {
         //	follow the steps from the from-square to the to-square, checking
         //	for enemy pieces that can be optinally captured.
         int movingPlayerNumber           = Board[from].Player;
         int direction                    = Board.DirectionLookup(from, to);
         int bitPatternOfPotentialVictims = 0;
         int nSteps     = 1;
         int nextSquare = Board.NextSquare(direction, from);
         while (nextSquare != to && nSteps <= 8)
         {
             if (Board[nextSquare] != null && Board[nextSquare].Player != movingPlayerNumber)
             {
                 //	this square contains a piece we can capture.
                 //	set the appropriate bit indexed by number of steps
                 bitPatternOfPotentialVictims |= 1 << (nSteps - 1);
             }
             //	advance to the next square
             nextSquare = Board.NextSquare(direction, nextSquare);
             nSteps++;
         }
         //	if any bits are set, add additional capture moves for
         //	every possible combination of captures
         if (bitPatternOfPotentialVictims != 0)
         {
             generatePermutations(moves, from, to, bitPatternOfPotentialVictims, 0);
         }
     }
     //	Always return NotHandled, even if we did because we still want
     //	normal move generation to take place so that pieces that can
     //	capture by overtake can still move when they are not doing so.
     return(MoveEventResponse.NotHandled);
 }
Пример #56
0
        /// <summary>
        /// The "main" method of this class, returns a correct move from a string essentially
        /// <example>
        /// <code>
        /// Grid board = new Grid();
        /// Move e4 = Move.FromUCI(board, "e2e4");
        /// </code>
        /// The example above will return a move with all the features that containst:
        /// Good move printing
        /// MoveType detection
        /// Promotion pieces
        /// Castltes
        /// </example>
        /// <see cref="Grid"/>
        /// <see cref="Piece"/>
        /// <see cref="Move.MoveTypeIdentifier(Grid, Tile, Tile)"
        /// </summary>
        /// <param name="board">The current board <see cref="Grid"/></param>
        /// <param name="uci">A uci string <example>"e2e4"</example> (must be lower case)</param>
        /// <param name="promotionPiece">Optional paramter for promotion piece, the MakeMove in <see cref="Grid"/> will handle it automatically</param>
        /// <returns>A move <see cref="Move"/></returns>
        /// <exception cref="ArgumentException">Will be thrown if the uci string length is different from 4</exception>
        /// <exception cref="InvalidMoveException">
        /// Will be thrown from a few reasons, mainly Invalid moves, like source tile has no piece etc'
        /// And also from wrong promotion
        /// </exception>
        public static Move FromUCI(Grid board, string uci, Piece promotionPiece = null)
        {
            Move move = null;

            if (uci.Length != 4)
            {
                throw new ArgumentException("UCI must be 4 characters");
            }

            int startX = (int)(uci[0] - 'a');
            int startY = int.Parse(uci[1].ToString()) - 1;
            int endX   = (int)(uci[2] - 'a');
            int endY   = int.Parse(uci[3].ToString()) - 1;

            Tile start = board.GetTile(startX, startY);
            Tile end   = board.GetTile(endX, endY);

            if (start.Piece == null)
            {
                throw new InvalidMoveException("Source tile has no piece");
            }

            if (end.Piece != null)
            {
                if (start.Piece.IsWhite == end.Piece.IsWhite)
                {
                    throw new InvalidMoveException("Source tile piece and destination tile piece are of the same team");
                }
            }

            if (promotionPiece == null)
            {
                MoveType temp = MoveType.Normal;
                move = new Move(start, end, board.CurrentPlayer, Move.MoveTypeIdentifier(board, start, end, ref temp));
                move.additionalMoveType = temp;
                return(move);
            }
            //promotion move
            Pawn pawn = start.Piece as Pawn;

            if (pawn == null)
            {
                throw new InvalidMoveException("Source tile must contain pawn");
            }

            if (pawn.IsWhite)
            {
                if (end.Y != 7)
                {
                    throw new InvalidMoveException("Destination tile must be the last rank");
                }
            }
            else
            {
                if (end.Y != 0)
                {
                    throw new InvalidMoveException("Destination tile must be the first rank");
                }
            }

            //check if promotion piece is not pawn
            if (promotionPiece is Pawn)
            {
                throw new InvalidMoveException("Can't promote to pawn");
            }

            move = new Move(start, end, board.CurrentPlayer, MoveType.Promotion, promotionPiece);
            return(move);
        }
 protected void generatePermutations(MoveList moves, int from, int to, int pendingBits, int activeBits)
 {
     if (pendingBits == 0)
     {
         //	here is where we generate a move, capturing whichever pieces
         //	are indicated by activeBits
         if (activeBits != 0)
         {
             //	Determine whether activeBits has only one bit set.
             //	If it has only one, the type of generated move will
             //	be MoveType.ExtraCapture (a move type inherrently
             //	understood by the framework.)  If more than one
             //	bit is set, we have multiple indirect captures and
             //	we will need to use a custom MoveType
             MoveType moveType = (activeBits & (activeBits - 1)) == 0
                                         ? MoveType.ExtraCapture
                                         : MoveType.CustomMove;
             //	Calculate the evaluation for the move (we will add to
             //	it as we pick up other pieces
             int eval = 2000 + (Board[to] != null ? Board[to].MidgameValue : 0);
             //	Add the move
             moves.BeginMoveAdd(moveType, from, to, activeBits);
             Piece movingPiece = moves.AddPickup(from);
             if (Board[to] != null)
             {
                 moves.AddPickup(to);
             }
             //	Step through the intervening squares picking up
             //	the appropriate pieces
             int direction  = Board.DirectionLookup(from, to);
             int nSteps     = 1;
             int nextSquare = Board.NextSquare(direction, from);
             while (nextSquare != to && activeBits != 0)
             {
                 if ((activeBits & (1 << (nSteps - 1))) != 0)
                 {
                     moves.AddPickup(nextSquare);
                     if (moveType == MoveType.ExtraCapture)
                     {
                         moves.SetMoveTag(nextSquare);
                     }
                     eval       += Board[nextSquare].MidgameValue;
                     activeBits ^= 1 << (nSteps - 1);
                 }
                 nextSquare = Board.NextSquare(direction, nextSquare);
                 nSteps++;
             }
             moves.AddDrop(movingPiece, to);
             moves.EndMoveAdd(eval);
         }
     }
     else
     {
         //	get the next bit from pendingBits and recursively call this
         //	function both with and without that bit in activeBits
         int newPendingBits = pendingBits ^ (pendingBits & -pendingBits);
         int currentBit     = pendingBits ^ newPendingBits;
         generatePermutations(moves, from, to, newPendingBits, activeBits);
         generatePermutations(moves, from, to, newPendingBits, activeBits | currentBit);
     }
 }
Пример #58
0
 /// <summary>
 /// Moves the instance to the specified position.
 /// </summary>
 /// <param name="target">The new coordinates.</param>
 /// <param name="type">The type of moving.</param>
 protected virtual void Move(Point target, MoveType type)
 {
     throw new NotSupportedException("NPCs can't be moved");
 }
Пример #59
0
 public Action()
 {
     this.move = MoveType.Wait;
 }
Пример #60
0
        private bool MoveObjectOnMap(ILocateable obj, byte newX, byte newY, object moveLock, MoveType moveType)
        {
            if (moveType == MoveType.Walk)
            {
                if (obj is ISupportWalk supportWalk)
                {
                    newX = supportWalk.WalkTarget.X;
                    newY = supportWalk.WalkTarget.Y;
                }
            }

            var differentBucket = obj.X / this.Map.BucketSideLength != newX / this.Map.BucketSideLength ||
                                  obj.Y / this.Map.BucketSideLength != newY / this.Map.BucketSideLength;

            if (!differentBucket)
            {
                return(false);
            }

            lock (moveLock)
            {
                var oldX = obj.X;
                var oldY = obj.Y;
                Bucket <ILocateable> oldBucket;
                Bucket <ILocateable> newBucket = this.Map[newX, newY];
                if (obj is IHasBucketInformation bucketInfo)
                {
                    oldBucket            = bucketInfo.NewBucket;
                    bucketInfo.NewBucket = newBucket;
                    bucketInfo.OldBucket = oldBucket;
                }
                else
                {
                    oldBucket = this.Map[oldX, oldY];
                }

                obj.X = newX;
                obj.Y = newY;
                oldBucket?.Remove(obj);
                newBucket.Add(obj);
            }

            return(true);
        }