private void startAISearch() { Thread t = new Thread(() => { Process p = new Process(); p.StartInfo.FileName = "bestmove.exe"; p.StartInfo.Arguments = $"{_evalDepth} \"{_board.toFEN()}\" \"{_tree._rpn}\""; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false; p.Start(); string FEN = p.StandardOutput.ReadToEnd().Trim(); _board = new Board(FEN); for (int i = 0; i < _pieces.Length; i++) { _pieces[i] = new PieceIndex(_board._indices[i], (byte)i); _buttons[i] = new SquareTypeIndex(0, (byte)i); } playerMove = true; _color = !_color; resetChessboardButtons(); OnPropertyChanged("_board"); OnPropertyChanged("_buttons"); OnPropertyChanged("_pieces"); }); t.Start(); }
private void _highlightMove(int offset) { if (_highlightedMatch != null) { if (_highlightedMove + offset < 0) { return; } else if (_highlightedMove + offset >= _highlightedMatch._states.Count) { return; } _highlightedMove += offset; _highlightedPosition = _highlightedMatch._states[_highlightedMove]; _buttons = new SquareTypeIndex[Board.BOARD_SIZE]; _pieces = new PieceIndex[Board.BOARD_SIZE]; for (int i = 0; i < Board.BOARD_SIZE; i++) { _buttons[i] = new SquareTypeIndex(0, (byte)i); _pieces[i] = new PieceIndex(_highlightedPosition._pieces[i], (byte)i); } OnPropertyChanged("_buttons"); OnPropertyChanged("_pieces"); } }
private void setProperties() { var g = new BidirectionalGraph <object, IEdge <object> >(); var l = new GraphLayout(); addNodesToGraph(_tree._root, null, g); var slp = new GraphSharp.Algorithms.Layout.Simple.Tree.SimpleTreeLayoutParameters(); slp.Direction = GraphSharp.Algorithms.Layout.LayoutDirection.TopToBottom; slp.LayerGap = 100.0; slp.VertexGap = 100.0; l.LayoutAlgorithmType = "Tree"; l.Graph = g; l.LayoutMode = LayoutMode.Automatic; l.LayoutParameters = slp; _layout = l; _promotionSquare = -1; _pickerVisibility = Visibility.Hidden; COLORS = new string[] { "White", "Black" }; DEPTHS = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; _board = new Board(Board.DEFAULT_POSITION); _playerColor = COLORS[0]; _color = true; playerMove = true; OnPropertyChanged("_playerColor"); _pieces = new PieceIndex[Board.BOARD_EDGE * Board.BOARD_EDGE]; _buttons = new SquareTypeIndex[Board.BOARD_EDGE * Board.BOARD_EDGE]; colorChanged = new RelayCommand(x => changeColor(), x => true); clickEmpty = new RelayCommand(x => resetChessboardButtons(), x => true); clickAllied = new RelayCommand(x => highlightTargetSquares(x), x => true); clickCurrent = new RelayCommand(x => resetChessboardButtons(), x => true); clickTarget = new RelayCommand(x => moveToTargetSquare(x), x => true); promoteQueen = new RelayCommand(x => promoteQ(), x => true); promoteRook = new RelayCommand(x => promoteR(), x => true); promoteBishop = new RelayCommand(x => promoteB(), x => true); promoteKnight = new RelayCommand(x => promoteN(), x => true); for (int i = 0; i < _pieces.Length; i++) { _pieces[i] = new PieceIndex(_board._indices[i], (byte)i); _buttons[i] = new SquareTypeIndex(0, (byte)i); } resetChessboardButtons(); }
private void _setHighlight(MatchHistory h) { _highlightedMatch = h; if (h._states.Count != 0) { _highlightedPosition = h._states[0]; _highlightedMove = 0; _buttons = new SquareTypeIndex[Board.BOARD_SIZE]; _pieces = new PieceIndex[Board.BOARD_SIZE]; for (int i = 0; i < Board.BOARD_SIZE; i++) { _buttons[i] = new SquareTypeIndex(0, (byte)i); _pieces[i] = new PieceIndex(_highlightedPosition._pieces[i], (byte)i); } OnPropertyChanged("_buttons"); OnPropertyChanged("_pieces"); OnPropertyChanged("_highlightedMatch"); } }