Skip to content

Commit a753f03

Browse files
committed
avoid bigint literals
1 parent 550c535 commit a753f03

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

components/visuals/bitboards/components.tsx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ const whitePawnAttacks: { codeLines: string[], steps: BitboardStep[] } = {
1212
"pawn_attacks = attacks_left | attacks_right;",
1313
],
1414
steps: (() => {
15-
const FILE_A = 0x0101010101010101n
16-
const FILE_H = 0x8080808080808080n
17-
const white_pawns = 0x000000000000ff00n
18-
const attacks_left = (white_pawns & ~FILE_A) << 7n
19-
const attacks_right = (white_pawns & ~FILE_H) << 9n
15+
const FILE_A = BigInt("0x0101010101010101")
16+
const FILE_H = BigInt("0x8080808080808080")
17+
const white_pawns = BigInt("0x000000000000ff00")
18+
const attacks_left = (white_pawns & ~FILE_A) << BigInt(7)
19+
const attacks_right = (white_pawns & ~FILE_H) << BigInt(9)
2020
const pawn_attacks = attacks_left | attacks_right
2121

2222
return [
@@ -44,29 +44,29 @@ const knightAttack: { codeLines: string[], steps: BitboardStep[] } = {
4444
" (KNIGHT_POS >> 6n & NOT_GH_FILE);",
4545
],
4646
steps: (() => {
47-
const KNIGHT_POS = 0x0000000004000000n
48-
const NOT_AB_FILE = ~0x0303030303030303n // Correct mask for files A and B
49-
const NOT_GH_FILE = ~0xc0c0c0c0c0c0c0c0n // Correct mask for files G and H
47+
const KNIGHT_POS = BigInt("0x0000000004000000")
48+
const NOT_AB_FILE = ~BigInt("0x0303030303030303") // Correct mask for files A and B
49+
const NOT_GH_FILE = ~BigInt("0xc0c0c0c0c0c0c0c0") // Correct mask for files G and H
5050

51-
const attacks = (KNIGHT_POS << 17n) |
52-
(KNIGHT_POS << 15n) |
53-
(KNIGHT_POS << 10n & NOT_AB_FILE) |
54-
(KNIGHT_POS << 6n & NOT_GH_FILE) |
55-
(KNIGHT_POS >> 17n) |
56-
(KNIGHT_POS >> 15n) |
57-
(KNIGHT_POS >> 10n & NOT_AB_FILE) |
58-
(KNIGHT_POS >> 6n & NOT_GH_FILE)
51+
const attacks = (KNIGHT_POS << BigInt(17)) |
52+
(KNIGHT_POS << BigInt(15)) |
53+
(KNIGHT_POS << BigInt(10) & NOT_AB_FILE) |
54+
(KNIGHT_POS << BigInt(6) & NOT_GH_FILE) |
55+
(KNIGHT_POS >> BigInt(17)) |
56+
(KNIGHT_POS >> BigInt(15)) |
57+
(KNIGHT_POS >> BigInt(10) & NOT_AB_FILE) |
58+
(KNIGHT_POS >> BigInt(6) & NOT_GH_FILE)
5959

6060
return [
6161
{ highlightLines: [2], board: KNIGHT_POS },
62-
{ highlightLines: [3], board: KNIGHT_POS << 17n },
63-
{ highlightLines: [4], board: KNIGHT_POS << 15n },
64-
{ highlightLines: [5], board: KNIGHT_POS << 10n & NOT_AB_FILE },
65-
{ highlightLines: [6], board: KNIGHT_POS << 6n & NOT_GH_FILE },
66-
{ highlightLines: [7], board: KNIGHT_POS >> 17n },
67-
{ highlightLines: [8], board: KNIGHT_POS >> 15n },
68-
{ highlightLines: [9], board: KNIGHT_POS >> 10n & NOT_AB_FILE },
69-
{ highlightLines: [10], board: KNIGHT_POS >> 6n & NOT_GH_FILE },
62+
{ highlightLines: [3], board: KNIGHT_POS << BigInt(17) },
63+
{ highlightLines: [4], board: KNIGHT_POS << BigInt(15) },
64+
{ highlightLines: [5], board: KNIGHT_POS << BigInt(10) & NOT_AB_FILE },
65+
{ highlightLines: [6], board: KNIGHT_POS << BigInt(6) & NOT_GH_FILE },
66+
{ highlightLines: [7], board: KNIGHT_POS >> BigInt(17) },
67+
{ highlightLines: [8], board: KNIGHT_POS >> BigInt(15) },
68+
{ highlightLines: [9], board: KNIGHT_POS >> BigInt(10) & NOT_AB_FILE },
69+
{ highlightLines: [10], board: KNIGHT_POS >> BigInt(6) & NOT_GH_FILE },
7070
{ highlightLines: [3, 4, 5, 6, 7, 8, 9, 10], board: attacks },
7171
]
7272
})(),

next-env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
/// <reference types="next/navigation-types/compat/navigation" />
43

54
// NOTE: This file should not be edited
65
// see https://nextjs.org/docs/basic-features/typescript for more information.

0 commit comments

Comments
 (0)