Algorithms_in_C++ 1.0.0
Set of 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:

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

Function Documentation

◆ main()

int main ( void )

Main function.

Returns
0 on exit
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
T endl(T... args)
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
T size(T... args)
Here is the call graph for this function: