Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ff46426199
Fetching contributors…

Cannot retrieve contributors at this time

file 54 lines (40 sloc) 1.088 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#ifndef MINIMAX_H
#define MINIMAX_H

#include <QCache>
#include "game.h"
#include "globals.h"

struct SearchResult;

class MinimaxAI
{
public:
    MinimaxAI(PlayerType, int);
    
    Move searchTree(const GameState&);
    Move searchTreeCache(const GameState&);

protected:
    bool oneMoveWin(const GameState&,
                    const QList<Move>&, int&);
    
    double minimax(const GameState&, bool,
                   int, int&, double, double);
    
    double minimaxCache(const GameState&, bool,
                   int, int&, double, double);
    
protected:
    bool isMax;
    int hitNodes;
    int numNodes;
    int lookahead;
    PlayerType player;
    QCache<GameState,SearchResult> cache;
};

enum ResultType { Exact, LowerBound, UpperBound };

struct SearchResult {
    int depth;
    int movInd;
    double eval;
    ResultType type;
    
    SearchResult();
    SearchResult(int, int, double, ResultType);
    
    GameState st;
    double alpha, beta;
};

uint qHash(const GameState&);

#endif // MINIMAX_H
Something went wrong with that request. Please try again.