public override double rollOut() { this.s = 0; DeterministicNode tmp = new DeterministicNode(this.board.getBoardState(), null, Constant.NONE, Constant.NONE); while (tmp.board.isEnd() == END_STATE.CONTINUE) { this.s += 1; CESPFMove tmpMove = tmp.board.CESPF(); if (tmpMove.isFlippingAction()) { tmp.board.flip(tmpMove.move.from.row, tmpMove.move.from.column); } else { tmp.board.move(tmpMove.move.from.row, tmpMove.move.from.column, tmpMove.move.to.row, tmpMove.move.to.column); } } END_STATE end = tmp.board.isEnd(); if (end == END_STATE.DRAW) { return(0.5); } else if (DeterministicNode.side == (int)end) { return(1); } return(0); }
public override double rollOut() { //Console.WriteLine("TASK : " + Task.CurrentId+","+Thread.CurrentThread.ManagedThreadId); this.s = 0; DeterministicNode tmp = new DeterministicNode(this.board.getBoardState(), null, NODE.NONE, Constant.NONE, Constant.NONE); while (tmp.board.isEnd() == END_STATE.CONTINUE) { this.s += 1; CESPFMove tmpMove = tmp.board.CESPF(); if (tmpMove.isFlippingAction()) { tmp.board.flip(tmpMove.move.from.row, tmpMove.move.from.column); } else { tmp.board.move(tmpMove.move.from.row, tmpMove.move.from.column, tmpMove.move.to.row, tmpMove.move.to.column); } } END_STATE end = tmp.board.isEnd(); if (end == END_STATE.DRAW) { return(0.5); } else if (DeterministicNode.side == (int)end) { return(1); } return(0); }
private void switchTurn() { END_STATE tmpResult = this.logicalCDC.isEnd(); if (tmpResult == END_STATE.BLACK_WIN) { //MAINKAN SUARANYA if (Properties.Settings.Default["Sound"].ToString() == "Enable") { Player.Open(new Uri(@"PindahPiece\" + Properties.Settings.Default["EndingSound"].ToString() + ".wav", UriKind.RelativeOrAbsolute)); Player.Play(); } MessageBox.Show("BLACK WIN"); main.newGame(); } else if (tmpResult == END_STATE.RED_WIN) { //MAINKAN SUARANYA if (Properties.Settings.Default["Sound"].ToString() == "Enable") { Player.Open(new Uri(@"PindahPiece\" + Properties.Settings.Default["EndingSound"].ToString() + ".wav", UriKind.RelativeOrAbsolute)); Player.Play(); } MessageBox.Show("RED WIN"); main.newGame(); } else if (tmpResult == END_STATE.DRAW) { //MAINKAN SUARANYA if (Properties.Settings.Default["Sound"].ToString() == "Enable") { Player.Open(new Uri(@"PindahPiece\" + Properties.Settings.Default["EndingSound"].ToString() + ".wav", UriKind.RelativeOrAbsolute)); Player.Play(); } MessageBox.Show("DRAW"); main.newGame(); } else { if (this.currentTurn == PLAYER.COMPUTER) { this.currentTurn = PLAYER.HUMAN; changeDisable(); } else { this.currentTurn = PLAYER.COMPUTER; changeDisable(); if (this.tournament == TOURNAMENT.HUMAN_VS_COMPUTER) { Task.Run(() => { string metode = Properties.Settings.Default["Metode"].ToString(); string fungsiEvaluasi = Properties.Settings.Default["Evaluasi"].ToString(); int jlhParallelTask = int.Parse(Properties.Settings.Default["ParallelTask"].ToString()); int moveTime = int.Parse(Properties.Settings.Default["MoveTime"].ToString()); if (metode.Equals("Root")) { if (fungsiEvaluasi.Equals("Cumulative")) { cumulativeRP.RootParallelization a = new cumulativeRP.RootParallelization(jlhParallelTask, moveTime, this.logicalCDC.getBoardState(), false); a.setPGLValue(); cumulativeRP.Node tmp = a.startNMCTS(); this.Dispatcher.BeginInvoke((Action)(() => {//jalankan moveByCoding(tmp.action.from, tmp.action.to); main.tree.Content = new CumulativeTree(a.result, CumulativeTree.METODE.ROOT); //switchTurn(); })); } else { SimpleCumulativeRP.RootParallelization a = new SimpleCumulativeRP.RootParallelization(jlhParallelTask, moveTime, this.logicalCDC.getBoardState(), false); a.setPGLValue(); SimpleCumulativeRP.Node tmp = a.startNMCTS(); this.Dispatcher.BeginInvoke((Action)(() => {//jalankan moveByCoding(tmp.action.from, tmp.action.to); main.tree.Content = new SimpleTree(a.result, SimpleTree.METODE.ROOT); //switchTurn(); })); } } else if (metode.Equals("Tree")) { if (fungsiEvaluasi.Equals("Cumulative")) { cumulativeTP.TreeParallelization a = new cumulativeTP.TreeParallelization(jlhParallelTask, moveTime, this.logicalCDC.getBoardState(), false); a.setPGLValue(); cumulativeTP.Node tmp = a.startNMCTS(); this.Dispatcher.BeginInvoke((Action)(() => {//jalankan moveByCoding(tmp.action.from, tmp.action.to); main.tree.Content = new CumulativeTree(a.tree, CumulativeTree.METODE.TREE); //switchTurn(); })); } else { SimpleCumulativeTP.TreeParallelization a = new SimpleCumulativeTP.TreeParallelization(jlhParallelTask, moveTime, this.logicalCDC.getBoardState(), false); a.setPGLValue(); SimpleCumulativeTP.Node tmp = a.startNMCTS(); this.Dispatcher.BeginInvoke((Action)(() => {//jalankan moveByCoding(tmp.action.from, tmp.action.to); main.tree.Content = new SimpleTree(a.tree, SimpleTree.METODE.TREE); //switchTurn(); })); } } else { if (fungsiEvaluasi.Equals("Cumulative")) { cumulativeTPVL.TreeParallelization a = new cumulativeTPVL.TreeParallelization(jlhParallelTask, moveTime, this.logicalCDC.getBoardState(), false); a.setPGLValue(); cumulativeTPVL.Node tmp = a.startNMCTS(); this.Dispatcher.BeginInvoke((Action)(() => {//jalankan moveByCoding(tmp.action.from, tmp.action.to); main.tree.Content = new CumulativeTree(a.tree, CumulativeTree.METODE.TREEVL); //switchTurn(); })); } else { SimpleCumulativeTPVL.TreeParallelization a = new SimpleCumulativeTPVL.TreeParallelization(jlhParallelTask, moveTime, this.logicalCDC.getBoardState(), false); a.setPGLValue(); SimpleCumulativeTPVL.Node tmp = a.startNMCTS(); this.Dispatcher.BeginInvoke((Action)(() => {//jalankan moveByCoding(tmp.action.from, tmp.action.to); main.tree.Content = new SimpleTree(a.tree, SimpleTree.METODE.TREEVL); //switchTurn(); })); } } }); } } } }