public void AI() { int side = boat.GetBoatSign() == 1 ? 0 : 1; LandModel land = side == 0 ? start_land : end_land; int p = (start_land.GetRoleNum())[0] + (1 - side) * (boat.GetRoleNumber())[0]; int d = (start_land.GetRoleNum())[1] + (1 - side) * (boat.GetRoleNumber())[1]; SolverState cur_state = new SolverState(p, d, side); SolverState next_state = Solve.solve(cur_state); int move_p = next_state.p - p > 0 ? next_state.p - p : p - next_state.p; int move_d = next_state.d - d > 0 ? next_state.d - d : d - next_state.d; while (move_p < boat.GetRoleNumber()[0]) { MoveRole(boat.GetRoleByType(0)); return; } while (move_d < boat.GetRoleNumber()[1]) { MoveRole(boat.GetRoleByType(1)); return; } while (move_p > boat.GetRoleNumber()[0]) { MoveRole(land.GetRoleByType(0)); return; } while (move_d > boat.GetRoleNumber()[1]) { MoveRole(land.GetRoleByType(1)); return; } MoveBoat(); }