-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The WebAssembly build now depends only on win_contributions, rotations, and reflections, which together take up only 19KB. This shrinks mid.wasm from 450,525 to 47,908 bytes. This required making non-table-based versions of various functions. Most such as pack/unpack were called few times, and sufficiently fast versions were easy. The hard function was halfsuper_wins, which went from depending only the very large superwin_info table to the much smaller win_contribution table, but got significantly slower as a result. Fortunately, I noticed that midengine was calling halfsuper_wins more times than necessary, and better caching made the final version faster than before this commit: 11.4 s to 10.9 s for `unit.js mid`.
- Loading branch information
Showing
15 changed files
with
238 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ cc_tests( | |
"all_boards_test", | ||
"pentago_test", | ||
"super_test", | ||
"slow_test", | ||
], | ||
deps = [ | ||
":base", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "pentago/base/board.h" | ||
#include "pentago/base/symmetry.h" | ||
#include "gtest/gtest.h" | ||
namespace pentago { | ||
namespace { | ||
|
||
TEST(slow, board) { | ||
Random random(7); | ||
for (int i = 0; i < 256; i++) { | ||
const auto board = random_board(random); | ||
const auto side0 = unpack(board, 0); | ||
const auto side1 = unpack(board, 1); | ||
const auto [slow0, slow1] = slow_unpack(board); | ||
ASSERT_EQ(side0, slow0); | ||
ASSERT_EQ(side1, slow1); | ||
ASSERT_EQ(board, slow_pack(side0, side1)); | ||
ASSERT_EQ(count_stones(board), slow_count_stones(board)); | ||
for (const int turn : range(2)) | ||
ASSERT_EQ(flip_board(board, turn), slow_flip_board(board, turn)); | ||
} | ||
} | ||
|
||
TEST(slow, transform_board) { | ||
Random random(7); | ||
for (int i = 0; i < 256; i++) { | ||
const auto s = random_symmetry(random); | ||
const auto board = random_board(random); | ||
ASSERT_EQ(transform_board(s, board), slow_transform_board(s, board)); | ||
} | ||
} | ||
|
||
} // namespace | ||
} // namespace pentago |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.