TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
minimax.cpp File Reference

returns which is the longest/shortest number using minimax algorithm More...

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
Include dependency graph for minimax.cpp:

Go to the source code of this file.

Namespaces

namespace  backtracking
 for vector container
 

Functions

template<size_t T>
int backtracking::minimax (int depth, int node_index, bool is_max, const std::array< int, T > &scores, double height)
 Check which is the maximum/minimum number in the array.
 
int main ()
 Main function.
 

Detailed Description

returns which is the longest/shortest number using minimax algorithm

Minimax (sometimes MinMax, MM or saddle point) is a decision rule used in artificial intelligence, decision theory, game theory, statistics, and philosophy for minimizing the possible loss for a worst case (maximum loss) scenario. When dealing with gains, it is referred to as "maximin"—to maximize the minimum gain. Originally formulated for two-player zero-sum game theory, covering both the cases where players take alternate moves and those where they make simultaneous moves, it has also been extended to more complex games and to general decision-making in the presence of uncertainty.

Author
Gleison Batista
David Leal

Definition in file minimax.cpp.

Function Documentation

◆ main()

int main ( void )

Main function.

Returns
0 on exit

Definition at line 56 of file minimax.cpp.

56 {
57 std::array<int, 8> scores = {90, 23, 6, 33, 21, 65, 123, 34423};
58 double height = log2(scores.size());
59
60 std::cout << "Optimal value: "
61 << backtracking::minimax(0, 0, true, scores, height) << std::endl;
62 return 0;
63}
int height(node *root)
Definition avltree.cpp:38
int minimax(int depth, int node_index, bool is_max, const std::array< int, T > &scores, double height)
Check which is the maximum/minimum number in the array.
Definition minimax.cpp:39