notnil / chess

chess package for go
MIT License
508 stars 126 forks source link

Reimplement newBitboard to avoid string operations #105

Open bbars opened 2 years ago

bbars commented 2 years ago

Instead of building a string of "0"s and "1"s and then converting it, newBitboard now uses bit arithmetic to convert a map to a uint64. This avoids memory allocation and a bunch of string operations. Add test for this change.

Done by @tov Original PR: #75

notnil commented 2 years ago

My test is failing @bbars .

--- FAIL: TestBitboardNew (0.00s)
    bitboard_test.go:110: new bitboard from map[a1:true] expected 1000000000000000000000000000000010000000000000000000000000000000 but got 1000000000000000000000000000000000000000000000000000000000000000

Also I updated Github actions to run tests on PRs now (I believe).

bbars commented 2 years ago

@notnil, I'm sorry, it's my fault. There was a typo in the expectation. I've fixed it. Also we can see now, that test were run successfully on PR.