-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSPMiniMaxNode.h
More file actions
executable file
·84 lines (72 loc) · 2.74 KB
/
SPMiniMaxNode.h
File metadata and controls
executable file
·84 lines (72 loc) · 2.74 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef SPMINIMAXNODE_H_
#define SPMINIMAXNODE_H_
#include "SPFIARGame.h"
//Put all decleartions and constants here
/**
* @param t - char.
* @return 1 if t == player_1_char, (-1) if t == player_2_char, or o otherwise.
*/
int charToVal(char t);
/**
* Given a current game state, goes over the board game and updates the scoring vector
* as per the current discs in the horizontal rows. e.g. vetcorsArray[0]++ if player_2
* has 4 discs in a row in a horizontal lane.
* @param resArray -the resultVectorArray, currentGame - game State
*/
void verticals(int resArray[9], SPFiarGame* currentGame);
/**
* Given a current game state, goes over the board game and updates the scoring vector
* as per the current discs in the vertical rows. e.g. vetcorsArray[0]++ if player_2
* has 4 discs in a row in a vertical lane.
* @param resArray -the resultVectorArray, currentGame - game State
*/
void horizontals(int resArray[9], SPFiarGame* currentGame);
/**
* Given a current game state, goes over the board game and updates the scoring vector
* as per the current discs in the diagunals (that go from the bottom left corner to
* the top right corner) rows. e.g. vetcorsArray[0]++ if player_2 has 4 discs in a row
* in a diagunal.
* @param resArray -the resultVectorArray, currentGame - game State
*/
void diagunalsLeftRight(int resArray[9], SPFiarGame* currentGame);
/**
* Given a current game state, goes over the board game and updates the scoring vector
* as per the current discs in the diagunals (that go from the bottom right corner to
* the top left corner) rows. e.g. vetcorsArray[0]++ if player_2 has 4 discs in a row
* in a diagunal.
* @param resArray -the resultVectorArray, currentGame - game State
*/
void diagunalsRightRight(int resArray[9], SPFiarGame* currentGame);
/**
* Given a current game state, computes the value of the scoring funcion
* @param currentGame
* @retrun socringFunctionValue
*/
int comFunc(SPFiarGame* currentGame);
/**
* The function initilazes the MinMax tree. It then computes the minimal and maximal
* potential values of the scoring function, and returns bestMoveMIN of bestMoveMax
* according to the current player.
*
* @param currentGame
* @retrun SuggestedMove
*/
int initMinmaxTree(SPFiarGame* currentGame, unsigned int maxDepth);
/**
* The function is running the minmax tree - if we are at the desiered depth
* and/or the game is over return the scoring function value
* otherwise recursive call to the bottom nodes
*
* @param currentGame
* @retrun maximal/minimal value of the scoring function
*/
int minmaxTree(SPFiarGame* currentGame, int depth, int alpha, int beta);
/**
* return b if b > a, a otherwise
*/
int maxFunc(int a, int b);
/**
* return b if b < a, a otherwise
*/
int minFunc(int a, int b);
#endif