Skip to content

Commit a8280f5

Browse files
committed
Reword intro
1 parent a753f03 commit a8280f5

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

components/visuals/bitboards/bitboard-visualizer.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ export default function BitboardVisualizer({ codeLines, steps, stepDelay = 2000
130130
}
131131
132132
.visualizer-content {
133-
display: flex;
134-
flex-direction: column;
133+
display: block;
135134
}
136135
137136
.code-line.highlighted {
@@ -160,10 +159,7 @@ export default function BitboardVisualizer({ codeLines, steps, stepDelay = 2000
160159
161160
.square {
162161
position: relative;
163-
display: flex;
164-
flex-direction: column;
165-
align-items: center;
166-
justify-content: center;
162+
display: block;
167163
border: 1px solid #e5e7eb;
168164
}
169165
@@ -182,9 +178,7 @@ export default function BitboardVisualizer({ codeLines, steps, stepDelay = 2000
182178
.bit-overlay {
183179
position: absolute;
184180
inset: 0;
185-
display: flex;
186-
align-items: center;
187-
justify-content: center;
181+
display: block;
188182
transition: opacity 0.5s;
189183
background-color: rgba(59, 130, 246, 0.5);
190184
opacity: 0;
@@ -213,9 +207,7 @@ export default function BitboardVisualizer({ codeLines, steps, stepDelay = 2000
213207
.bitboard-info {
214208
margin-top: 0.25rem;
215209
margin-bottom: 0.25rem;
216-
display: flex;
217-
flex-direction: column;
218-
gap: 0.25rem;
210+
display: block;
219211
font-family: "IBM Plex Mono", monospace;
220212
font-size: 0.875rem;
221213
width: 100%;
@@ -228,6 +220,7 @@ export default function BitboardVisualizer({ codeLines, steps, stepDelay = 2000
228220
padding: 0.5rem;
229221
background-color: #f9fafb;
230222
border-radius: 0.25rem;
223+
margin-bottom: 0.25rem;
231224
}
232225
233226
.info-item.binary {

posts/visualizing-chess-bitboards.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ tags: ["javascript"]
55
description: "Brief introduction to chess bitboards and move generation with animations."
66
---
77

8-
Bitboards are an efficient way to store game state in (usually) 64-bit integers. There are 64 positions on a chess board so we can use each bit as an on/off switch.
8+
When simulating board games on a computer, one of the challenges is keeping track of the game pieces. Bitboards are an efficient way to store game state in (usually) 64-bit integers. There are 64 positions on a chess board so we can use each bit as an on/off switch.
99

10-
I want to describe a board where `f5` is occupied. We can use `67108864`.
10+
Let's say I want to describe a board where `f5` is occupied. For that, we can use the number `67108864`. In decimal notation, it doesn't seem much like a chessboard. In hex, we can see that there's some structure: `0x0000000004000000`.
1111

12-
This number doesn't really scream that `f5` is occupied though.
13-
14-
I'll show it represented as a binary number with 64 digits.
12+
For me, it starts to make more sense when representated as a binary number with 64 digits.
1513

1614
```text
1715
0 0 0 0 0 0 0 0 I've added a line break
@@ -24,8 +22,6 @@ I'll show it represented as a binary number with 64 digits.
2422
0 0 0 0 0 0 0 0
2523
```
2624

27-
In my examples, I'll use hex representation. In this case that would be `0x0000000004000000`.
28-
2925
We can't pack an _entire_ game's state into a number (e.g. piece color, piece type, castling rights) so we use groups of numbers.
3026

3127
We can use _bitwise_ operations on these numbers to manipulate individual bits using operators like `AND`, `OR`, `XOR`, `NOT`, and bit shifts. These operations are fast (they're directly executed by the CPU in a single clock cycle with no need for complex computation or memory access).
@@ -60,7 +56,7 @@ Two numbers will probably stick out; `7` and `9`. If you picture that long row o
6056

6157
<div className="bitboards" id="whitePawnAttacks"></div>
6258

63-
Without bitboards, a program has to perform many more (magnitudes more!) instructions. The equivalent code, without bitwise operations, would look something like this.
59+
Without bitboards, a program has to perform many more (magnitudes more!) instructions. The equivalent code, without bitwise operations, would look something like this:
6460

6561
```js
6662
attacks = [];

0 commit comments

Comments
 (0)