Snippet example

PHOTO EMBED

Wed Sep 27 2023 07:59:17 GMT+0000 (Coordinated Universal Time)

Saved by @paolo #python

# This function chooses at random which action to be performed within the range 
# of all the available actions.
def ActionChoice(available_actions_range):
    if(sum(PossibleAction)>0):
        next_action = int(ql.random.choice(PossibleAction,1))
    if(sum(PossibleAction)<=0):
        next_action = int(ql.random.choice(5,1))
    return next_action

# Sample next action to be performed
action = ActionChoice(PossibleAction)
content_copyCOPY

Snippet example

https://github.com/PacktPublishing/Artificial-Intelligence-By-Example/blob/master/Chapter01/mdp02.py