From 0ec7c39525db91193a62892a892336ce7df70952 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Fri, 26 Feb 2021 00:18:53 +0000 Subject: [PATCH] Utility function NondetModel.getAvailableActions(s). --- prism/src/explicit/NondetModel.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/prism/src/explicit/NondetModel.java b/prism/src/explicit/NondetModel.java index 49fe9557..5b65b92c 100644 --- a/prism/src/explicit/NondetModel.java +++ b/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 getAvailableActions(int s) + { + List 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()}.