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