750b16970f
[board] Create const arrays for Shape that return &'static to its enum cases
2023-12-31 11:44:47 -08:00
878d771d86
[board] Replace Moves' separate properties with a Vec of Iterators
...
This makes iteration easier. Move to the next iterator if the current one returns None.
No tests for Moves yet though.
2023-12-31 11:44:47 -08:00
c2c0af20fb
[board] Extend the Move type with two builder-style methods for capturing and promotion
...
These two methods replace self with one that has a populated capture or promotion field.
2023-12-31 09:28:21 -08:00
adc2f76e00
[board] Change the type of BitScanner.shift form u32 to usize
2023-12-31 09:27:16 -08:00
1cc8b4520f
[board] Return copies of rank and file bitboards from static lists
2023-12-31 09:26:20 -08:00
e30bcb3105
[board] Implement BitBoard::file and fmt::Display for BitBoard
...
BitBoard::file returns a BitBoard representing the 0-indexed file.
fmt::Display prints a grid of bits in the standard orientation (white on bottom, left to right)
Add asserts to the rank and file constructors to catch out of bounds arguments.
2023-12-30 10:26:37 -08:00
c280258780
[board] Remove an unused local variable from pieces.rs
2023-12-29 16:34:26 -08:00
53dc80b6bb
[board] Implement BitAndAssign and BitOrAssign on BitBoard
2023-12-29 16:34:11 -08:00
808222eef1
[board] Clean up the formatting of BitBoards
...
Use debug_tuple in the fmt::Debug implementation.
Implement fmt::Binary, fmt::UpperHex, and fmt::LowerHex by delegating to u64's version.
2023-12-29 15:37:38 -08:00
41421dddbb
[board] Clean up interfaces of pieces and square structs
2023-12-29 09:17:33 -08:00
301fe1a4f4
[board] Remove a pile of debug printing from pieces.rs
2023-12-29 09:03:51 -08:00
164122a140
[board] Implement a simple Move struct
2023-12-29 09:03:36 -08:00
852b7a848f
[board] Implement PawnMoveGenerator
...
It generates pawn moves with bitboard bit operations!
2023-12-29 09:03:02 -08:00
65a7bec5f9
[board] Implement Position::move_generator
2023-12-29 08:59:13 -08:00
90db9b194f
[board] Implement BitBoard::shift_east
2023-12-29 08:58:34 -08:00
1a986e4c27
[board] Implement Position::occupied_squares and Position::empty_squares
...
These methods return bitboards marking the occupied and empty squares, made by ORing the two pieces_per_color bitboards.
2023-12-29 08:58:34 -08:00
2296be23cc
[board] Rename BitBoard::from_bit_field → ::new
2023-12-28 21:42:18 -07:00
af53eb932c
[board] Populate the color bitboards when placing pieces
2023-12-28 21:41:55 -07:00
e1e27fc668
[board] Implement TryFrom<&str> for Shape
...
Convert a string to a Shape using the first character in the string.
Rename TryFromCharError → TryFromError
2023-12-28 19:50:02 -07:00
72dabfe73f
[board] A couple small changes to support the explorer crate
...
- DiagramFormatter::new
- Make board::position public
2023-12-28 15:11:57 -07:00
f340578cf2
[explorer] A REPL-style command line app to fiddle with chess boards
...
Build a REPL that enables placing pieces on a chess board. Nothing else so far!
2023-12-28 15:09:15 -07:00
4c9e6a51fc
[board] Move all the BitBoard shift code to a new bitboard::shifts module
2023-12-28 12:14:30 -07:00
5a08a4477e
[board] Implement BitBoard::shift_south
2023-12-28 12:10:39 -07:00
5039d657ae
[board] Some test helpers that produce Squares from algebraic notiation and assert their validity
2023-12-28 12:08:44 -07:00
5e47d37aa3
[board] Add a negative test for BitBoard::is_empty()
...
Remove a stray println!
2023-12-27 10:28:44 -07:00
61448d437f
[board] Implement a BitBoard::rank constructor
...
Also implement BitBoard::shift_north() to support rank().
2023-12-27 10:04:02 -07:00
dda4cd8a5a
[board] Add a MoveGenerator struct
2023-12-27 10:02:37 -07:00
51a265172b
[board] Implement an infix_op! macro for generating BitBoard operator traits
2023-12-27 10:00:30 -07:00
50a6be2f72
[board] Pass piece argument to Position::bitboard_for_piece() by value instead of by reference
2023-12-27 08:31:02 -07:00
4bec1538a1
[board] Add the missing trailing } to fmt::Debug for Position
2023-12-27 08:01:44 -07:00
b9ba2629c4
[board] Fix the King's position in the Position::starting()
...
I wrote a test of the starting position for DiagramFormatter and discovered that Position::starting() was placing the king incorrectly. Fixed it!
2023-12-27 08:01:44 -07:00
ff59799add
[board] Move neighbor::Direction → square::Direction
2023-12-27 08:01:44 -07:00
19c48b9816
[board] Implement a DiagramFormatter that writes a graphical diagram of a Position
...
Remove fmt::Display from Position and move display to a DiagramFormatter type that implements that trait and writes a position to a formatter.
2023-12-26 21:37:22 -07:00
8d06cbf0f8
[board] Make the piece module public and remove the crate-level export of Color and Piece
2023-12-26 21:36:38 -07:00
17511e9d63
[board] Implement a rather dumb Position::piece_on_square
...
This method does an iteration over all piece colors and shapes to find the piece on a given square.
2023-12-26 21:34:01 -07:00
49c5a0b51d
[board] Implement fmt::Display for Piece
2023-12-26 21:33:00 -07:00
ecc1ee85d4
[board] Remove an unintentional recursion in fmt::Display for piece::Shape
2023-12-26 21:31:44 -07:00
8e9da6aeff
[board] Implement helpful piecewise constructors on Piece
2023-12-26 21:31:05 -07:00
371d37f688
[board] Implement TryFrom<char> and Into<char> for piece::Shape
2023-12-26 13:57:36 -07:00
a963cee1e7
Merge branch 'main' into pretty-print-position
2023-12-26 13:28:55 -07:00
9d0761f8c6
[board] Rename from_algebraic_string → from_algebraic_str
2023-12-26 13:28:25 -07:00
758a3d95fc
[board] Reorganize bitboard and position modules and export some symbols from the crate
...
Move position.rs to the position module and create a mod.rs.
Do the same for bitboard.rs in the bitboard modules.
Export Color, Piece, Position, and Square and use crate::Thing directly instead of referring to the symbol in the nested modules.
2023-12-26 11:25:27 -07:00
d2d33a4915
[board] Add Position::color_to_move defaulting to White
2023-12-26 11:22:40 -07:00
cc793fdad6
[board] Pretty print a board with rank and file notations but no pieces
2023-12-26 11:21:01 -07:00
1575c83d31
[board] Rename PiecePlacementError::PieceExistsOnSquare → ExistsOnSquare
2023-12-26 11:20:01 -07:00
80b78a8fef
[board] Remove Default derivation from BitBoard
2023-12-26 11:19:13 -07:00
32c562e405
[board] Implement Color::other() that swaps the color for the other
2023-12-26 11:13:44 -07:00
fac98735e3
[board] Implement a Pieces iterator
...
This type iterates the pieces in a Position using the BitScanner struct to iterate all the occupied squares of the position's bitboards.
2023-12-26 09:19:38 -07:00
18d9a845e6
[board] Implement a custom Debug for Position
...
Newlines help a lot!
2023-12-26 09:17:57 -07:00
e23c20486e
[board] Build error and warning fixes
...
- Remove unused import from bit_scanner.rs
- Rename PieceShape → Shape in the Position tests
2023-12-26 09:16:55 -07:00