class State { float position; float velocity; State() { position = 0; velocity = 0; } boolean equals(State other) { return equal(position, other.position) && equal(velocity, other.velocity); } boolean compare(State other) { float threshold = 0.1; return abs(other.position - position) > threshold; } State clone() { State c = new State(); c.position = position; c.velocity = velocity; return c; } }