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 resetChessboardButtons() { _selectedSquare = byte.MaxValue; for (int i = 0; i < Board.BOARD_SIZE; i++) { _buttons[i]._type = (byte)SquareStates.EMPTY; ulong mask = (ulong)1 << i; if (_playerColor.CompareTo(COLORS[0]) == 0 && (mask & _board._bitboards[(byte)Piece.OCC_WHITE]) != 0) { _buttons[i]._type = (byte)SquareStates.ALLIED_PIECE; } if (_playerColor.CompareTo(COLORS[1]) == 0 && (mask & _board._bitboards[(byte)Piece.OCC_BLACK]) != 0) { _buttons[i]._type = (byte)SquareStates.ALLIED_PIECE; } } for (int i = 0; i < _pieces.Length; i++) { _pieces[i] = new PieceIndex(_board._indices[i], (byte)i); } OnPropertyChanged("_buttons"); OnPropertyChanged("_pieces"); }
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"); } }
public override int GetHashCode() { return(RequestLength.GetHashCode() ^ DataOffset.GetHashCode() ^ PieceIndex.GetHashCode() ^ StartOffset.GetHashCode()); }
public override int GetHashCode() { int hash = 13; hash = (hash * 7) + PieceIndex.GetHashCode(); hash = (hash * 7) + Offset.GetHashCode(); hash = (hash * 7) + Length.GetHashCode(); return(hash); }
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"); } }
private void moveToTargetSquare(object square) { byte?index = square as byte?; if (index != null) { _targetSquare = index.Value; makeMove(); for (int i = 0; i < _pieces.Length; i++) { _pieces[i] = new PieceIndex(_board._indices[i], (byte)i); } OnPropertyChanged("_board"); OnPropertyChanged("_buttons"); OnPropertyChanged("_pieces"); } if (_promotionSquare < 0) { playerMove = false; _color = !_color; resetChessboardButtons(); } }
public override int GetHashCode() => RequestLength.GetHashCode() ^ PieceIndex.GetHashCode() ^ StartOffset.GetHashCode();
public override int GetHashCode() { return(PieceIndex.GetHashCode()); }
/// <summary> /// Returns the hash code for this HaveMessage instance. /// </summary> /// <returns>An integer representing the hash code of this instace of the HaveMessage class.</returns> public override int GetHashCode() { return(MessageLength.GetHashCode() ^ Id.GetHashCode() ^ PieceIndex.GetHashCode()); }