Algorithms_in_C++  1.0.0
Set of algorithms implemented in C++.
minimax.cpp File Reference

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

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

Namespaces

 backtracking
 Backtracking algorithms.
 

Functions

template<size_t T>
int backtracking::minimax (int depth, int node_index, bool is_max, const std::array< int, T > &scores, double height)
 
int main ()
 

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

54  {
55  std::array<int, 8> scores = {90, 23, 6, 33, 21, 65, 123, 34423};
56  double height = log2(scores.size());
57 
58  std::cout << "Optimal value: " << backtracking::minimax(0, 0, true, scores, height)
59  << std::endl;
60  return 0;
61 }
Here is the call graph for this function:
std::array::size
T size(T... args)
std::cout
std::array
STL class.
height
int height(node *root)
Definition: avltree.cpp:31
backtracking::minimax
int minimax(int depth, int node_index, bool is_max, const std::array< int, T > &scores, double height)
Definition: minimax.cpp:38
std::endl
T endl(T... args)