forked from Fossana/cplusplus-cfr-poker-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAction.cpp
More file actions
35 lines (33 loc) · 1.04 KB
/
Action.cpp
File metadata and controls
35 lines (33 loc) · 1.04 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
#include "Action.h"
Action::Action(ActionType type, int amount)
{
this->type = type;
this->amount = amount;
}
bool Action::is_valid_action(Action& action, int stackSize, int wager, int callAmount, int minimumRaiseSize)
{
switch(action.type)
{
case FOLD:
return callAmount > 0; // don't allow folding if checking is an option
case CHECK:
return callAmount == 0;
case CALL:
return callAmount > 0
&& ((action.amount == callAmount && action.amount <= stackSize)
|| action.amount == stackSize);
case BET:
return callAmount == 0
&& ((action.amount > minimumRaiseSize && action.amount <= stackSize)
|| (action.amount > 0 && action.amount == stackSize));
case RAISE:
{
int raiseSize = action.amount - callAmount - wager;
return callAmount > 0
&& ((raiseSize >= minimumRaiseSize && action.amount <= (stackSize + wager))
|| (raiseSize > 0 && action.amount == (stackSize + wager)));
}
default:
return false;
}
}