How can I write a program to implement this pseudocode for a mini-max algorithm?

  • #1
shivajikobardan
542
34
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?
 

Answers and Replies

  • #2
pbuk
Science Advisor
Homework Helper
Gold Member
4,048
2,379
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
shivajikobardan
542
34
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
pbuk
Science Advisor
Homework Helper
Gold Member
4,048
2,379
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.
 

Suggested for: How can I write a program to implement this pseudocode for a mini-max algorithm?

  • Last Post
Replies
15
Views
722
Replies
16
Views
870
Replies
2
Views
398
  • Last Post
Replies
7
Views
774
  • Last Post
Replies
2
Views
417
Replies
2
Views
468
Replies
9
Views
439
Replies
1
Views
414
  • Last Post
Replies
1
Views
82
Top