FAQ: Minimax - Which Move?

This community-built FAQ covers the “Which Move?” exercise from the lesson “Minimax”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Machine Learning

FAQs on the exercise Which Move?

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I wondered why at the end of this section, the result for the following command:
print(minimax(o_winning, False)) or print(minimax(o_winning, True))
I get the same result [-1 , 4]
when the board is:
o_winning = [
[“X”, “X”, “O”],
[“4”, “X”, “6”],
[“7”, “O”, “O”]

So I understand that this means that O will win the game, however why would it be 4 if it was O’s next move? Surely it would be either 6 or 7 because that wins the game?
Why is the position 4 the same whether you’re maximising for X or O?


I was wondering the same thing. I think it might have something to do with the fact that the end goal of the program isn’t necessarily to win, but to maximize the number of winning states and minimize the number of losing states. Picking 4 results in two possible future win states for O, and none for X, as opposed to a singular winning state (in which O has won).

I have the same question :frowning: