So then the output would be: Max root value is 3 Below is algorithms of the abov
ID: 3601355 • Letter: S
Question
So then the output would be: Max root value is 3
Below is algorithms of the above implementations requirements and a better understanding.
Figure 5.3:
Figure 5.2:
function MINIMAX-DECISION state) returns an action ACTIONS(s) return arg maxa MIN-VALUE(RESULT(state, a)) function Max-VALUE(state) returns a utility value if TerMINAL-TEST(state) then return UTILITY(state) for each a in ACTIONs(state) do v MAX(u, MIN-VALUE(RESULT(s, a))) return iv function MIN-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY (state) for each a in AcTIONS(state) do u MIN(u, MAX-VALUE(RESULT(s, a))) return v Figure 5.3 An algorithm for calculating minimax decisions. It returns the action corre- sponding to the best possible move, that is, the move that leads to the outcome with the best utility, under the assumption that the opponent plays to minimize utility. The functions MAX-VALUE and MIN-VALUE go through the whole game tree, all the way to the leaves, to determine the backed-up value of a state. The notation argmaxa e s f(a) computes the element a of set S that has the maximum value of f(a).Explanation / Answer
def find_max_recursively(S, n): """Find the maximum element in a sequence S, of n elements.""" if n == 1: # reached the left most item return S[n-1] else: previous = find_max_recursively(S, n-1) current = S[n-1] if previous > current: return previous else: return current if __name__ == '__main__': print(find_max_recursively([5, 10, 20, 11, 3], 5))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.