added probs

This commit is contained in:
lpan 2020-02-18 14:40:34 -08:00
parent d9aefc102e
commit ead4a4371f
3 changed files with 187 additions and 15 deletions

View File

@ -18,37 +18,181 @@
[ [
{ {
"playerIdx": 0, "playerIdx": 0,
"move": "Check" "move": "Check",
"probabilities": [
{
"move": "Check",
"probability": 0.9
},
{
"move": "Raise",
"probability": 0.05
},
{
"move": "Call",
"probability": 0.02
},
{
"move": "Fold",
"probability": 0.01
}
]
}, },
{ {
"playerIdx": 1, "playerIdx": 1,
"move": "Raise" "move": "Raise",
"probabilities": [
{
"move": "Raise",
"probability": 0.9
},
{
"move": "Check",
"probability": 0.05
},
{
"move": "Call",
"probability": 0.02
},
{
"move": "Fold",
"probability": 0.01
}
]
}, },
{ {
"playerIdx": 0, "playerIdx": 0,
"move": "Call" "move": "Call",
"probabilities": [
{
"move": "Call",
"probability": 0.9
},
{
"move": "Check",
"probability": 0.05
},
{
"move": "Raise",
"probability": 0.02
},
{
"move": "Fold",
"probability": 0.01
}
]
}, },
{ {
"playerIdx": 1, "playerIdx": 1,
"move": "Check" "move": "Check",
"probabilities": [
{
"move": "Check",
"probability": 0.9
},
{
"move": "Raise",
"probability": 0.05
},
{
"move": "Call",
"probability": 0.02
},
{
"move": "Fold",
"probability": 0.01
}
]
} }
], ],
[ [
{ {
"playerIdx": 0, "playerIdx": 0,
"move": "Raise" "move": "Raise",
"probabilities": [
{
"move": "Raise",
"probability": 0.9
},
{
"move": "Check",
"probability": 0.05
},
{
"move": "Call",
"probability": 0.02
},
{
"move": "Fold",
"probability": 0.01
}
]
}, },
{ {
"playerIdx": 1, "playerIdx": 1,
"move": "Call" "move": "Call",
"probabilities": [
{
"move": "Call",
"probability": 0.9
},
{
"move": "Check",
"probability": 0.05
},
{
"move": "Raise",
"probability": 0.02
},
{
"move": "Fold",
"probability": 0.01
}
]
}, },
{ {
"playerIdx": 0, "playerIdx": 0,
"move": "Raise" "move": "Raise",
"probabilities": [
{
"move": "Raise",
"probability": 0.9
},
{
"move": "Check",
"probability": 0.05
},
{
"move": "Call",
"probability": 0.02
},
{
"move": "Fold",
"probability": 0.01
}
]
}, },
{ {
"playerIdx": 1, "playerIdx": 1,
"move": "Call" "move": "Call",
"probabilities": [
{
"move": "Call",
"probability": 0.9
},
{
"move": "Check",
"probability": 0.05
},
{
"move": "Raise",
"probability": 0.02
},
{
"move": "Fold",
"probability": 0.01
}
]
} }
] ]
] ]

View File

@ -140,8 +140,9 @@
.probability-player { .probability-player {
height: calc(72px - 16px*2); height: calc(72px - 16px*2);
padding: 16px; padding: 16px;
display:table;
span { span {
display: table-cell;
vertical-align: middle; vertical-align: middle;
} }
} }
@ -169,7 +170,6 @@
-ms-transition: background-color 0.3s ease; -ms-transition: background-color 0.3s ease;
transition: background-color 0.3s ease; transition: background-color 0.3s ease;
display: table-cell; display: table-cell;
height: 152px;
vertical-align: middle; vertical-align: middle;
.playingCards ul.hand { .playingCards ul.hand {
@ -177,7 +177,8 @@
} }
.probability-move { .probability-move {
font-size: 10px; font-size: 20px;
font-weight: bold;
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;

View File

@ -227,6 +227,30 @@ class LeducHoldemGameView extends React.Component {
} }
} }
computeProbabilityItem(idx){
if(this.state.gameInfo.gameStatus !== "ready"){
let currentMove = null;
if(this.state.gameInfo.turn !== this.moveHistory[this.state.gameInfo.round].length){
currentMove = this.moveHistory[this.state.gameInfo.round][this.state.gameInfo.turn];
}
let style = {};
style["backgroundColor"] = currentMove !== null ? `rgba(189,183,107,${currentMove.probabilities[idx].probability})` : "#bdbdbd";;
return (
<div className={"playing"} style={style}>
<div className="probability-move">
{currentMove !== null ? currentMove.probabilities[idx].move : <NotInterestedIcon fontSize="large" />}
</div>
{currentMove !== null ?
(<div className={"non-card"}>
<span>{`Probability: ${(currentMove.probabilities[idx].probability * 100).toFixed(2)}%`}</span>
</div>) : ""}
</div>
)
}else {
return <span className={"waiting"}>Waiting...</span>
}
}
go2PrevGameState() { go2PrevGameState() {
let gameInfo = null; let gameInfo = null;
if(this.state.gameInfo.turn === 0 && this.state.gameInfo.round !== 0){ if(this.state.gameInfo.turn === 0 && this.state.gameInfo.round !== 0){
@ -320,13 +344,16 @@ class LeducHoldemGameView extends React.Component {
<Divider /> <Divider />
<div className={"probability-table"}> <div className={"probability-table"}>
<div className={"probability-item"}> <div className={"probability-item"}>
{/* {this.computeProbabilityItem(0)} */} {this.computeProbabilityItem(0)}
</div> </div>
<div className={"probability-item"}> <div className={"probability-item"}>
{/* {this.computeProbabilityItem(1)} */} {this.computeProbabilityItem(1)}
</div> </div>
<div className={"probability-item"}> <div className={"probability-item"}>
{/* {this.computeProbabilityItem(2)} */} {this.computeProbabilityItem(2)}
</div>
<div className={"probability-item"}>
{this.computeProbabilityItem(3)}
</div> </div>
</div> </div>
</Paper> </Paper>