AIMA.Environment.CellWorld.CellWorldAction.getYResult C# (CSharp) Метод

getYResult() публичный метод

public getYResult ( int curY ) : int
curY int
Результат int
    public int getYResult(int curY)
    {
        int newY = curY;

        switch (this._action)
        {
            case ActionEnum.Up:
                newY++;
                break;
            case ActionEnum.Down:
                newY--;
                break;
        }

        return newY;
    }

Usage Example

Пример #1
0
        /**
         * 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.
         *
         * @param s
         *            the cell location from which the action is to be performed.
         * @param a
         *            the action to perform (Up, Down, Left, or Right).
         * @return the Cell an agent would end up in if they performed the specified
         *         action from the specified cell location.
         */

        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);
        }