Skip to content

Commit 1b87124

Browse files
authored
Documenting folders architecture (#66)
* documented new folder layout that respects chess layers * renaming files to suit the latest needs
1 parent 5df1655 commit 1b87124

31 files changed

+343
-17
lines changed

include/bitbishop/attacks/attackers_to.hpp

Whitespace-only changes.

include/bitbishop/attacks/bishop_attacks.hpp

Whitespace-only changes.

include/bitbishop/attacks/queen_attacks.hpp

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# About the `attacks/` directory
2+
3+
## The core rule
4+
5+
Lookups = immutable, compile-time geometry
6+
7+
Attacks = runtime logic that depends on board state
8+
9+
## What exactly goes into `attacks/`
10+
11+
### Definition
12+
13+
attacks/ contains functions that:
14+
15+
- consume lookup tables
16+
- take runtime state (occupied)
17+
- compute attack bitboards dynamically
18+
19+
### Examples (good)
20+
21+
```cpp
22+
// attacks/bishop_attacks.cpp
23+
Bitboard bishop_attacks(Square from, Bitboard occupied);
24+
25+
// attacks/attackers_to.cpp
26+
Bitboard attackers_to(Square sq, const Board&, Color);
27+
```
28+
29+
### Examples (bad — belongs elsewhere)
30+
31+
```cpp
32+
constexpr Bitboard KING_ATTACKS[64]; // ❌ data only
33+
generate_legal_moves(...) // ❌ rules layer
34+
```

include/bitbishop/attacks/rook_attacks.hpp

Whitespace-only changes.

include/bitbishop/engine/readme.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# About the `engine/` directory
2+
3+
## The core rule
4+
5+
Engine = decision making
6+
7+
This layer decides which move to play, not which moves are legal.
8+
9+
## What exactly goes into `engine/`
10+
11+
### Definition
12+
13+
engine/ contains logic that:
14+
15+
- searches the game tree
16+
- evaluates positions
17+
- selects the best move
18+
19+
This layer may:
20+
21+
- call generate_legal_moves()
22+
- make/unmake moves on the Board
23+
- maintain search state
24+
25+
This layer must not:
26+
27+
- implement chess rules
28+
- generate attacks directly
29+
- contain UI or protocol code
30+
31+
Typical responsibilities
32+
33+
- search algorithms:
34+
- Minimax
35+
- Alpha-Beta
36+
- MCTS
37+
- evaluation functions
38+
- move ordering
39+
- transposition tables
40+
- time management (search side)
41+
42+
### Examples (good)
43+
44+
```cpp
45+
// engine/search.cpp
46+
Move search_best_move(Board&, SearchLimits);
47+
48+
// engine/eval.cpp
49+
int evaluate(const Board&);
50+
```
51+
52+
### Examples (bad — belongs elsewhere)
53+
54+
```cpp
55+
void generate_legal_rook_moves(...); // ❌ movegen
56+
constexpr Bitboard ROOK_RAYS[64][4]; // ❌ lookups
57+
void uci_loop(); // ❌ interface
58+
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# About the `interface/` directory
2+
3+
## The core rule
4+
5+
Interface = communication with the outside world
6+
7+
This layer translates between the engine and humans or GUIs.
8+
9+
## What exactly goes into interface/
10+
11+
### Definition
12+
13+
interface/ contains logic that:
14+
15+
- parses input commands
16+
- formats output
17+
- manages clocks and sessions
18+
- interacts with GUIs or users
19+
20+
This layer may:
21+
22+
- call engine entry points
23+
- read/write text or UI events
24+
25+
This layer must not:
26+
27+
- implement search logic
28+
- implement chess rules
29+
- manipulate bitboards directly
30+
31+
Typical responsibilities
32+
33+
- UCI / CECP protocol handling
34+
- GUI hooks
35+
- command parsing
36+
- time control management
37+
- logging
38+
39+
### Examples (good)
40+
41+
```cpp
42+
// interface/uci.cpp
43+
void uci_loop();
44+
45+
// interface/cli.cpp
46+
void run_cli();
47+
```
48+
49+
### Examples (bad — belongs elsewhere)
50+
51+
```cpp
52+
Bitboard attackers_to(...); // ❌ attacks
53+
int alpha_beta(...); // ❌ engine
54+
generate_legal_moves(...); // ❌ movegen
55+
```
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)