Browse Source

Utility function NondetModel.getAvailableActions(s).

accumulation-v4.7
Dave Parker 5 years ago
parent
commit
0ec7c39525
  1. 15
      prism/src/explicit/NondetModel.java

15
prism/src/explicit/NondetModel.java

@ -26,9 +26,11 @@
package explicit;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.function.IntPredicate;
import prism.PrismLog;
@ -75,6 +77,19 @@ public interface NondetModel extends Model
*/
public Object getAction(int s, int i);
/**
* Get a list of the actions labelling the choices of state {@code s}.
*/
public default List<Object> getAvailableActions(int s)
{
List<Object> actions = new ArrayList<>();
int numChoices = getNumChoices(s);
for (int i = 0; i < numChoices; i++) {
actions.add(getAction(s, i));
}
return actions;
}
/**
* Get the index of the (first) choice in state {@code s} with action label {@code action}.
* Action labels (which are {@link Object}s) are tested for equality using {@link Object#equals()}.

Loading…
Cancel
Save