Beispiel #1
0
        /// <summary>
        /// Determine what cell would be moved into if the specified action is
        /// performed in the specified cell. Normally, this will be the cell adjacent
        /// in the appropriate direction. However, if there is no cell in the
        /// adjacent direction of the action then the outcome of the action is to
        /// stay in the same cell as the action was performed in.
        /// </summary>
        /// <param name="s">the cell location from which the action is to be performed.</param>
        /// <param name="a">the action to perform (Up, Down, Left, or Right).</param>
        /// <returns>
        /// the Cell an agent would end up in if they performed the specified
        /// action from the specified cell location..
        /// </returns>
        public Cell <C> Result(Cell <C> s, CellWorldAction a)
        {
            Cell <C> sDelta = GetCellAt(a.GetXResult(s.getX()), a.GetYResult(s
                                                                             .getY()));

            if (null == sDelta)
            {
                // Default to no effect
                // (i.e. bumps back in place as no adjoining cell).
                sDelta = s;
            }

            return(sDelta);
        }
Beispiel #2
0
        /// <summary>
        /// Get the second right angled action related to this action.
        /// </summary>
        /// <returns>the second right angled action related to this action.</returns>
        public CellWorldAction GetSecondRightAngledAction()
        {
            CellWorldAction a = null;

            if (Up == this ||
                Down == this)
            {
                a = Right;
            }
            else if (Left == this ||
                     Right == this)
            {
                a = Up;
            }
            else if (None == this)
            {
                a = None;
            }

            return(a);
        }
Beispiel #3
0
        /// <summary>
        /// Get the first right angled action related to this action.
        /// </summary>
        /// <returns>the first right angled action related to this action.</returns>
        public CellWorldAction GetFirstRightAngledAction()
        {
            CellWorldAction a = null;

            if (Up == this ||
                Down == this)
            {
                a = Left;
            }
            else if (Left == this ||
                     Right == this)
            {
                a = Down;
            }
            else if (None == this)
            {
                a = None;
            }

            return(a);
        }