add game end dialog & make probability value for leduc holdem sample json more reasonable
This commit is contained in:
parent
6c1de0ba3e
commit
64f4b649b3
|
@ -22,7 +22,7 @@
|
||||||
"probabilities": [
|
"probabilities": [
|
||||||
{
|
{
|
||||||
"move": "Check",
|
"move": "Check",
|
||||||
"probability": 0.35
|
"probability": 0.7661
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Raise",
|
"move": "Raise",
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Fold",
|
"move": "Fold",
|
||||||
"probability": 0.01
|
"probability": 0.2339
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -44,11 +44,11 @@
|
||||||
"probabilities": [
|
"probabilities": [
|
||||||
{
|
{
|
||||||
"move": "Raise",
|
"move": "Raise",
|
||||||
"probability": 0.9
|
"probability": 0.4123
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Check",
|
"move": "Check",
|
||||||
"probability": 0.05
|
"probability": 0.4983
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Call",
|
"move": "Call",
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Fold",
|
"move": "Fold",
|
||||||
"probability": 0.01
|
"probability": 0.0894
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -66,19 +66,19 @@
|
||||||
"probabilities": [
|
"probabilities": [
|
||||||
{
|
{
|
||||||
"move": "Call",
|
"move": "Call",
|
||||||
"probability": 0.9
|
"probability": 0.5251
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Check",
|
"move": "Check",
|
||||||
"probability": 0.05
|
"probability": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Raise",
|
"move": "Raise",
|
||||||
"probability": 0.02
|
"probability": 0.1803
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Fold",
|
"move": "Fold",
|
||||||
"probability": 0.01
|
"probability": 0.2946
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -88,19 +88,19 @@
|
||||||
"probabilities": [
|
"probabilities": [
|
||||||
{
|
{
|
||||||
"move": "Check",
|
"move": "Check",
|
||||||
"probability": 0.9
|
"probability": 0.7435
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Raise",
|
"move": "Raise",
|
||||||
"probability": 0.05
|
"probability": 0.2324
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Call",
|
"move": "Call",
|
||||||
"probability": 0.02
|
"probability": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Fold",
|
"move": "Fold",
|
||||||
"probability": 0.01
|
"probability": 0.0241
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -112,19 +112,19 @@
|
||||||
"probabilities": [
|
"probabilities": [
|
||||||
{
|
{
|
||||||
"move": "Raise",
|
"move": "Raise",
|
||||||
"probability": 0.9
|
"probability": 0.5031
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Check",
|
"move": "Check",
|
||||||
"probability": 0.05
|
"probability": 0.2138
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Call",
|
"move": "Call",
|
||||||
"probability": 0.02
|
"probability": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Fold",
|
"move": "Fold",
|
||||||
"probability": 0.01
|
"probability": 0.2931
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -134,19 +134,19 @@
|
||||||
"probabilities": [
|
"probabilities": [
|
||||||
{
|
{
|
||||||
"move": "Call",
|
"move": "Call",
|
||||||
"probability": 0.9
|
"probability": 0.4363
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Check",
|
"move": "Check",
|
||||||
"probability": 0.05
|
"probability": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Raise",
|
"move": "Raise",
|
||||||
"probability": 0.02
|
"probability": 0.3512
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Fold",
|
"move": "Fold",
|
||||||
"probability": 0.01
|
"probability": 0.2485
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -156,19 +156,19 @@
|
||||||
"probabilities": [
|
"probabilities": [
|
||||||
{
|
{
|
||||||
"move": "Raise",
|
"move": "Raise",
|
||||||
"probability": 0.9
|
"probability": 0.6402
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Check",
|
"move": "Check",
|
||||||
"probability": 0.05
|
"probability": 0.2563
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Call",
|
"move": "Call",
|
||||||
"probability": 0.02
|
"probability": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Fold",
|
"move": "Fold",
|
||||||
"probability": 0.01
|
"probability": 0.1035
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -178,19 +178,19 @@
|
||||||
"probabilities": [
|
"probabilities": [
|
||||||
{
|
{
|
||||||
"move": "Call",
|
"move": "Call",
|
||||||
"probability": 0.9
|
"probability": 0.6042
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Check",
|
"move": "Check",
|
||||||
"probability": 0.05
|
"probability": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Raise",
|
"move": "Raise",
|
||||||
"probability": 0.02
|
"probability": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"move": "Fold",
|
"move": "Fold",
|
||||||
"probability": 0.01
|
"probability": 0.3958
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@ import ReplayRoundedIcon from '@material-ui/icons/ReplayRounded';
|
||||||
import NotInterestedIcon from '@material-ui/icons/NotInterested';
|
import NotInterestedIcon from '@material-ui/icons/NotInterested';
|
||||||
import SkipNextIcon from '@material-ui/icons/SkipNext';
|
import SkipNextIcon from '@material-ui/icons/SkipNext';
|
||||||
import SkipPreviousIcon from '@material-ui/icons/SkipPrevious';
|
import SkipPreviousIcon from '@material-ui/icons/SkipPrevious';
|
||||||
|
import DialogTitle from "@material-ui/core/DialogTitle";
|
||||||
|
import DialogContent from "@material-ui/core/DialogContent";
|
||||||
|
import DialogContentText from "@material-ui/core/DialogContentText";
|
||||||
|
import DialogActions from "@material-ui/core/DialogActions";
|
||||||
|
import Dialog from "@material-ui/core/Dialog";
|
||||||
|
|
||||||
class DoudizhuGameView extends React.Component {
|
class DoudizhuGameView extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -47,6 +52,8 @@ class DoudizhuGameView extends React.Component {
|
||||||
gameInfo: this.initGameState,
|
gameInfo: this.initGameState,
|
||||||
gameStateLoop: null,
|
gameStateLoop: null,
|
||||||
gameSpeed: 0,
|
gameSpeed: 0,
|
||||||
|
gameEndDialog: false,
|
||||||
|
gameEndDialogText: "",
|
||||||
fullScreenLoading: false
|
fullScreenLoading: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -89,11 +96,13 @@ class DoudizhuGameView extends React.Component {
|
||||||
this.setState({ gameInfo: gameInfo });
|
this.setState({ gameInfo: gameInfo });
|
||||||
if(winner.role === "landlord")
|
if(winner.role === "landlord")
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
alert("Landlord Wins");
|
const mes = "Landlord Wins";
|
||||||
|
this.setState({gameEndDialog: true, gameEndDialogText: mes});
|
||||||
}, 200);
|
}, 200);
|
||||||
else
|
else
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
alert("Peasants Win");
|
const mes = "Peasants Win";
|
||||||
|
this.setState({gameEndDialog: true, gameEndDialogText: mes});
|
||||||
}, 200);
|
}, 200);
|
||||||
}else{
|
}else{
|
||||||
Message({
|
Message({
|
||||||
|
@ -311,6 +320,10 @@ class DoudizhuGameView extends React.Component {
|
||||||
this.setState({gameInfo: gameInfo});
|
this.setState({gameInfo: gameInfo});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleCloseGameEndDialog() {
|
||||||
|
this.setState({gameEndDialog: false, gameEndDialogText: ""});
|
||||||
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let sliderValueText = (value) => {
|
let sliderValueText = (value) => {
|
||||||
return value;
|
return value;
|
||||||
|
@ -348,6 +361,24 @@ class DoudizhuGameView extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
<Dialog
|
||||||
|
open={this.state.gameEndDialog}
|
||||||
|
onClose={()=>{this.handleCloseGameEndDialog()}}
|
||||||
|
aria-labelledby="alert-dialog-title"
|
||||||
|
aria-describedby="alert-dialog-description"
|
||||||
|
>
|
||||||
|
<DialogTitle id="alert-dialog-title" style={{"width": "200px"}}>{"Game Ends!"}</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText id="alert-dialog-description">
|
||||||
|
{this.state.gameEndDialogText}
|
||||||
|
</DialogContentText>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={()=>{this.handleCloseGameEndDialog()}} color="primary" autoFocus>
|
||||||
|
OK
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
<Navbar gameName={"Doudizhu"} />
|
<Navbar gameName={"Doudizhu"} />
|
||||||
<div className={"doudizhu-view-container"}>
|
<div className={"doudizhu-view-container"}>
|
||||||
<Layout.Row style={{"height": "540px"}}>
|
<Layout.Row style={{"height": "540px"}}>
|
||||||
|
|
|
@ -17,6 +17,11 @@ import ReplayRoundedIcon from '@material-ui/icons/ReplayRounded';
|
||||||
import NotInterestedIcon from '@material-ui/icons/NotInterested';
|
import NotInterestedIcon from '@material-ui/icons/NotInterested';
|
||||||
import SkipNextIcon from '@material-ui/icons/SkipNext';
|
import SkipNextIcon from '@material-ui/icons/SkipNext';
|
||||||
import SkipPreviousIcon from '@material-ui/icons/SkipPrevious';
|
import SkipPreviousIcon from '@material-ui/icons/SkipPrevious';
|
||||||
|
import Dialog from '@material-ui/core/Dialog';
|
||||||
|
import DialogActions from '@material-ui/core/DialogActions';
|
||||||
|
import DialogContent from '@material-ui/core/DialogContent';
|
||||||
|
import DialogContentText from '@material-ui/core/DialogContentText';
|
||||||
|
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||||
|
|
||||||
class LeducHoldemGameView extends React.Component {
|
class LeducHoldemGameView extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -48,6 +53,8 @@ class LeducHoldemGameView extends React.Component {
|
||||||
gameInfo: this.initGameState,
|
gameInfo: this.initGameState,
|
||||||
gameStateLoop: null,
|
gameStateLoop: null,
|
||||||
gameSpeed: 0,
|
gameSpeed: 0,
|
||||||
|
gameEndDialog: false,
|
||||||
|
gameEndDialogText: "",
|
||||||
fullScreenLoading: false
|
fullScreenLoading: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +109,8 @@ class LeducHoldemGameView extends React.Component {
|
||||||
gameInfo.gameStatus = "over";
|
gameInfo.gameStatus = "over";
|
||||||
this.setState({ gameInfo: gameInfo });
|
this.setState({ gameInfo: gameInfo });
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
alert(`Player ${foldedId} folded, player ${winnerId} wins!`);
|
const mes = `Player ${foldedId} folded, player ${winnerId} wins!`;
|
||||||
|
this.setState({ gameEndDialog: true, gameEndDialogText: mes });
|
||||||
}, 200);
|
}, 200);
|
||||||
return gameInfo;
|
return gameInfo;
|
||||||
default:
|
default:
|
||||||
|
@ -118,7 +126,7 @@ class LeducHoldemGameView extends React.Component {
|
||||||
this.setState({gameInfo: gameInfo});
|
this.setState({gameInfo: gameInfo});
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
// TODO: show winner
|
// TODO: show winner
|
||||||
alert("Game Ends!");
|
this.setState({gameEndDialog: true, gameEndDialogText: ""});
|
||||||
}, 200);
|
}, 200);
|
||||||
return gameInfo;
|
return gameInfo;
|
||||||
}
|
}
|
||||||
|
@ -307,6 +315,10 @@ class LeducHoldemGameView extends React.Component {
|
||||||
this.setState({gameInfo: gameInfo});
|
this.setState({gameInfo: gameInfo});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleCloseGameEndDialog() {
|
||||||
|
this.setState({gameEndDialog: false, gameEndDialogText: ""});
|
||||||
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let sliderValueText = (value) => {
|
let sliderValueText = (value) => {
|
||||||
return value;
|
return value;
|
||||||
|
@ -344,6 +356,24 @@ class LeducHoldemGameView extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
<Dialog
|
||||||
|
open={this.state.gameEndDialog}
|
||||||
|
onClose={()=>{this.handleCloseGameEndDialog()}}
|
||||||
|
aria-labelledby="alert-dialog-title"
|
||||||
|
aria-describedby="alert-dialog-description"
|
||||||
|
>
|
||||||
|
<DialogTitle id="alert-dialog-title" style={{"width": "200px"}}>{"Game Ends!"}</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText id="alert-dialog-description">
|
||||||
|
{this.state.gameEndDialogText}
|
||||||
|
</DialogContentText>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={()=>{this.handleCloseGameEndDialog()}} color="primary" autoFocus>
|
||||||
|
OK
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
<Navbar gameName="Leduc Hold'em" />
|
<Navbar gameName="Leduc Hold'em" />
|
||||||
<div className={"leduc-view-container"}>
|
<div className={"leduc-view-container"}>
|
||||||
<Layout.Row style={{"height": "540px"}}>
|
<Layout.Row style={{"height": "540px"}}>
|
||||||
|
|
Loading…
Reference in New Issue