-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(connect-four): add board evaluation #228
Merged
Merged
Commits on May 12, 2024
-
Configuration menu - View commit details
-
Copy full SHA for aa7f522 - Browse repository at this point
Copy the full SHA aa7f522View commit details -
Configuration menu - View commit details
-
Copy full SHA for 142bfe8 - Browse repository at this point
Copy the full SHA 142bfe8View commit details
Commits on May 13, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 13f8bb9 - Browse repository at this point
Copy the full SHA 13f8bb9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5932eb5 - Browse repository at this point
Copy the full SHA 5932eb5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4b707c9 - Browse repository at this point
Copy the full SHA 4b707c9View commit details -
Configuration menu - View commit details
-
Copy full SHA for d611caf - Browse repository at this point
Copy the full SHA d611cafView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2c1fbd8 - Browse repository at this point
Copy the full SHA 2c1fbd8View commit details -
refactor: better
evaluate_window
mask creationFrom 1 SSE2 and a jump, to 2 SSE instructions and no jump
Configuration menu - View commit details
-
Copy full SHA for 187388b - Browse repository at this point
Copy the full SHA 187388bView commit details -
Configuration menu - View commit details
-
Copy full SHA for d69b50f - Browse repository at this point
Copy the full SHA d69b50fView commit details
Commits on May 14, 2024
-
Configuration menu - View commit details
-
Copy full SHA for e665c82 - Browse repository at this point
Copy the full SHA e665c82View commit details -
Configuration menu - View commit details
-
Copy full SHA for f4ee0bb - Browse repository at this point
Copy the full SHA f4ee0bbView commit details
Commits on May 16, 2024
-
Co-authored-by: Tyler J Russell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 336abaa - Browse repository at this point
Copy the full SHA 336abaaView commit details -
perf: improve
evaluate_window
's performance even furtherThe code prior to this commit was already quite fast, at 37 instructions. For this commit, I did two things: 1. I read all the indexes once per line instead of once per window, this allowed the code to read the values as a sequence of contiguous `u8` values instead of a sequence that jumps around in memory. This by itself allows the `evaluate_window` function to use a slice rather than having to create a new array per window. This change reduced the number of instructions in `evaluate_window` from 37 to 23. 2. I changed `ConnectFour` to add a `score_player_mask` field containing the `Simd<u8, 4>` value, rather than having to make a new one on every `evaluate_window` call. This change reduced the number of instructions in `evaluate_window` from 23 to 19. The final x86 assembly code for `evaluate_window` is as follows: ```asm ; fn evaluate_window(&self, player: Player, window: &[u8; 4]) -> i32 { movdqa xmm0, xmmword, ptr, [rdx] pxor xmm1, xmm1 movdqa xmm2, xmm0 pcmpeqb xmm2, xmm1 xorps xmm3, xmm3 movss xmm3, xmm2 pmovmskb eax, xmm3 ; match mask.to_bitmask() { movzx eax, al pcmpeqb xmm0, xmmword, ptr, [rcx] lea rcx, [rip, +, switch.table._ZN8skyra_ai5games12connect_four11ConnectFour15evaluate_window17hbe62da8767e17f32E] movss xmm1, xmm0 pmovmskb edx, xmm1 movzx edx, dl lea r8, [rip, +, switch.table._ZN8skyra_ai5games12connect_four11ConnectFour15evaluate_window17hbe62da8767e17f32E.300] movzx edx, byte, ptr, [rdx, +, r8] ; let mask: u8 = (player_pieces << 3) | empty_pieces; or dl, byte, ptr, [rax, +, rcx] movsx rax, dl ; match mask { lea rcx, [rip, +, switch.table._ZN8skyra_ai5games12connect_four11ConnectFour15evaluate_window17hbe62da8767e17f32E.299] mov eax, dword, ptr, [rcx, +, 4*rax, -, 4] ; } ret ```
Configuration menu - View commit details
-
Copy full SHA for 78e92d8 - Browse repository at this point
Copy the full SHA 78e92d8View commit details
Commits on May 20, 2024
-
ci: use
NPM_PUBLISH_TOKEN
instead ofNPM_TOKEN
That's the name of the token we use for publish
Configuration menu - View commit details
-
Copy full SHA for 086237b - Browse repository at this point
Copy the full SHA 086237bView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.