/* % Initialize a new state with an initial value new_state(InitialValue, State) :- gensym(obj_state_, State), % Generate a new unique atom starting with obj_state_ assertz(is_registered_state(State)), % Assert the new state nb_setval(State, InitialValue). % Link the state to its initial value using a non-backtrackable global variable % Update the state’s value to a new value change_state(State, NewValue) :- if_debugging(is_state(State)), % Check if State is a valid state nb_setval(State, NewValue). % Update the value of the non-backtrackable global variable linked to the state % Retrieve the current value of the state get_state(State, CurrentValue) :- if_debugging(is_state(State)), % Check if State is a valid state nb_getval(State, CurrentValue). % Retrieve the value of the non-backtrackable global variable linked to the state % Verify whether a given term is a state is_state(State) :- is_nb_state(State),!. is_state(State) :- atom(State), % Check if State is an atom atom_concat(obj_state_, _, State), % Check if State starts with obj_state_ is_registered_state(State). % Check if State has been asserted */