private void FindBestMoveEnd <Igra>(Igra cookieCallBack, MoveExt move) { if (move != null) { while (CBoard.CurrentPlayer == Igrac2PlayerE(trenutniIgrac)) { CBoard.CancelSearch(); //Prekidamo pretragu najboljeg poteza CBoard.DoMove(move); //Igramo potez PrikaziTablu(); //Prikazujemo u tabli ono sto smo odigrali ZvukFigure(); listePoteza.Add(new ListaPoteza(CBoard.GetHumanPos(move), PlayerE2Igrac(Igrac2PlayerE(trenutniIgrac)).ToString(), TipIgraca.Masina.ToString())); if (CBoard.CurrentPlayer == ChessBoard.PlayerE.Black) { StopericaPublic.Stop1(); StopericaPublic.Start2(); } if (CBoard.CurrentPlayer == ChessBoard.PlayerE.White) { StopericaPublic.Stop2(); StopericaPublic.Start1(); } } if (move.Move.Type == Move.TypeE.PieceEaten) { SahovskeFigurice = new SahovskeFigurice { Pozicija = Int2Pozicija(move.Move.EndPos), TipFigurice = PieceE2Figurice(move.Move.OriginalPiece), Igrac = PieceE2Igrac(move.Move.OriginalPiece) }; if (trenutniIgrac == Igrac.Beli) { konteinerCrni.Add(SahovskeFigurice); PrikazPojedenihCrnihFigura(); } else { konteinerBeli.Add(SahovskeFigurice); PrikazPojedenihBelihFigura(); } PrikaziTablu(); } } }
private void FindBestMoveEnd <Igra>(FindBestMoveCookie <Igra> cookieCallBack, MoveExt move) { if (move != null) { move.TimeToCompute = DateTime.Now - cookieCallBack.m_dtStartFinding; } cookieCallBack.m_oriAction(cookieCallBack.m_oriCookie, move); }
public void PomeriFiguru(Point pozicija, SahovskeFigurice figura) { Move m = CBoard.FindIfValid(CBoard.CurrentPlayer, Pozicija2Int(pozicija), Pozicija2Int(figura.Pozicija)); MoveExt me = new MoveExt(m); PromocijaPesakaPublic = CBoard.FindValidPawnPromotion(CBoard.CurrentPlayer, Pozicija2Int(pozicija), Pozicija2Int(figura.Pozicija)); if (PromocijaPesakaPublic != ChessBoard.ValidPawnPromotionE.None) { PromocijaPesakaDijalog promocija = new PromocijaPesakaDijalog(this); if (promocija.ShowDialog() ?? false == true) { switch (PromocijaPesakaPublic) { case ChessBoard.ValidPawnPromotionE.Queen: me.Move.Type = Move.TypeE.PawnPromotionToQueen; break; case ChessBoard.ValidPawnPromotionE.Rook: me.Move.Type = Move.TypeE.PawnPromotionToRook; break; case ChessBoard.ValidPawnPromotionE.Bishop: me.Move.Type = Move.TypeE.PawnPromotionToBishop; break; case ChessBoard.ValidPawnPromotionE.Knight: me.Move.Type = Move.TypeE.PawnPromotionToKnight; break; default: break; } } } if (CBoard.IsMoveValid(m)) { CBoard.DoMove(me); NadjiNajboljiPotez(); listePoteza.Add(new ListaPoteza(CBoard.GetHumanPos(me), figura.Igrac.ToString(), TipIgraca.Covek.ToString())); ZvukFigure(); } else { MediaPlayer PlayPotez = new MediaPlayer(); PlayPotez.Open(new Uri(@"../../Zvuk/pogresan_potez.wav", UriKind.Relative)); PlayPotez.Play(); } if (m.Type == Move.TypeE.PieceEaten) { SahovskeFigurice = new SahovskeFigurice { TipFigurice = PieceE2Figurice(m.OriginalPiece), Igrac = PieceE2Igrac(m.OriginalPiece) }; if (CBoard.LastMovePlayer == ChessBoard.PlayerE.White) { konteinerCrni.Add(SahovskeFigurice); PrikazPojedenihCrnihFigura(); } else { konteinerBeli.Add(SahovskeFigurice); PrikazPojedenihBelihFigura(); } } //PrikaziTablu(); }