Learning Pseudocode: A Crash Course for Beginners

In summary, pseudocode is provided for implementing the minimax algorithm. The code makes use of functions to determine if a node is a leaf, a min or max node, and to evaluate the node's value. The algorithm involves recursively calling the minimax function on the node's children and returning the min or max value depending on the type of node. To learn how to implement it, one can refer to the explanation on Wikipedia, although the code provided may need some adjustments.
  • #1
shivajikobardan
674
54
Homework Statement
minimax algorithm artificial intelligence
Relevant Equations
algorithm given below
I found pseudocode for this problem below-:

Code:
def minimax(current node):
    if is_leaf(current_node):
        return static_evaluation(current_node)
    if is_min_node(current_node):
        return min(minimax(children_of(current_node)))
    if is_max_node(current_node):
        return max(minimax(children_of(current_node)))
How do I learn to do it? I have no idea. Learning these stuffs would be immensely useful. I have ok programming experience. Learnt about dsa and stuffs but I don't have any notes from that time and don't remember much stuffs. Know basic python. Know oop but like dsa forgot and don't have the notes...What to do?
 
Physics news on Phys.org
  • #2
shivajikobardan said:
How do I learn to do it?

The explanation on Wikipedia is reasonable, with similar pseduocode (although that toggles a flag for alternating player whereas the code above has that information in the node).
 
  • #3
pbuk said:
The explanation on Wikipedia is reasonable, with similar pseduocode (although that toggles a flag for alternating player whereas the code above has that information in the node).
any idea how to implement it?
 
  • #4
shivajikobardan said:
any idea how to implement it?
Follow the explanation accompanying the code. I suggest you use the Wikipedia page I linked, the code you posted (which appears to be Python not pseudocode) is rubbish: the first line says that the function minimax has a single node as its only argument but on lines 5 and 6 it is called with what must be a list of nodes.
 

Similar threads

Replies
15
Views
4K
Replies
4
Views
1K
Replies
15
Views
2K
Replies
7
Views
3K
Replies
10
Views
2K
Replies
2
Views
942
Replies
3
Views
1K
Replies
3
Views
2K
Back
Top