public object Clone() { BallState cloneObject = new BallState(); for (int i = 0; i < cloneObject.square.Length; i++) { cloneObject.square[i] = this.square[i]; } return(cloneObject); }
public override bool Equals(object obj) { BallState state = (obj as BallState); for (int i = 0; i < this.square.Length; i++) { if (this.square[i] != state.square[i]) { return(false); } } //if (this.square.Equals(state.square)) return true; return(true); }
public bool Precondition(IState State) { if (toCell == fromCell) { return(false); } if (!(State is BallState)) { return(false); } if (!State.isValid()) { return(false); } BallState currentState = new BallState(); if (toCell + 1 >= BallState._numOfSquares) { return(false); } if (Math.Abs(ToCell - FromCell) < 2) { return(false); } if (currentState.Square[FromCell] == 0 || currentState.Square[FromCell + 1] == 0) { return(false); } if (currentState.Square[ToCell] != 0 || currentState.Square[ToCell + 1] != 0) { return(false); } return(true); }