Пример #1
0
 public State Unpush(State state)
 {
     if (state.calledLifts.Count == 0 || state.calledLifts.Last() != this.target) {
         return null;
     }
     var result = state.Clone();
     result.calledLifts.RemoveAt(result.calledLifts.Count - 1);
     result.SetNext(state, new Push(this));
     return result;
 }
Пример #2
0
 public State Push(State state)
 {
     if (state.calledLifts.Contains(target)) {
         return null;
     }
     var result = state.Clone();
     result.calledLifts.Add(target);
     result.SetPrevious(state, new Push(this));
     return result;
 }
Пример #3
0
 public State Unmove(State state)
 {
     if (this.lift != null && (state.calledLifts.Contains(this.lift))) {
         return null;
     }
     var result = state.Clone();
     result.position = from;
     if (this.lift != null) {
         result.calledLifts.Insert(0, this.lift);
     }
     result.SetNext(state, new Move(this));
     return result;
 }
Пример #4
0
 public State Move(State state)
 {
     if (this.lift != null && (state.calledLifts.Count == 0 || state.calledLifts[0] != this.lift)) {
         return null;
     }
     var result = state.Clone();
     result.position = to;
     if (this.lift != null) {
         result.calledLifts.RemoveAt(0);
     }
     result.SetPrevious(state, new Move(this));
     return result;
 }
Пример #5
0
        public State Unmove(State state)
        {
            if (this.lift != null && (state.calledLifts.Contains(this.lift)))
            {
                return(null);
            }
            var result = state.Clone();

            result.position = from;
            if (this.lift != null)
            {
                result.calledLifts.Insert(0, this.lift);
            }
            result.SetNext(state, new Move(this));
            return(result);
        }
Пример #6
0
        public State Move(State state)
        {
            if (this.lift != null && (state.calledLifts.Count == 0 || state.calledLifts[0] != this.lift))
            {
                return(null);
            }
            var result = state.Clone();

            result.position = to;
            if (this.lift != null)
            {
                result.calledLifts.RemoveAt(0);
            }
            result.SetPrevious(state, new Move(this));
            return(result);
        }