Skip to content
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

Not optimal Position.compute_winning_position #27

Closed
yurkovas opened this issue Sep 19, 2021 · 1 comment
Closed

Not optimal Position.compute_winning_position #27

yurkovas opened this issue Sep 19, 2021 · 1 comment

Comments

@yurkovas
Copy link

yurkovas commented Sep 19, 2021

I'm removed (commented) the possibly unnecessary code in Position.compute_winning_position:

//horizontal
position_t p = (position << (HEIGHT + 1)) & (position << 2 * (HEIGHT + 1));
r |= p & (position << 3 * (HEIGHT + 1));
// r |= p & (position >> (HEIGHT + 1));
p = (position >> (HEIGHT + 1)) & (position >> 2 * (HEIGHT + 1));
// r |= p & (position << (HEIGHT + 1));
r |= p & (position >> 3 * (HEIGHT + 1));

//diagonal 1
p = (position << HEIGHT) & (position << 2 * HEIGHT);
r |= p & (position << 3 * HEIGHT);
// r |= p & (position >> HEIGHT);
p = (position >> HEIGHT) & (position >> 2 * HEIGHT);
// r |= p & (position << HEIGHT);
r |= p & (position >> 3 * HEIGHT);

//diagonal 2
p = (position << (HEIGHT + 2)) & (position << 2 * (HEIGHT + 2));
r |= p & (position << 3 * (HEIGHT + 2));
// r |= p & (position >> (HEIGHT + 2));
p = (position >> (HEIGHT + 2)) & (position >> 2 * (HEIGHT + 2));
// r |= p & (position << (HEIGHT + 2));
r |= p & (position >> 3 * (HEIGHT + 2));

@yurkovas
Copy link
Author

I was wrong. compute_winning_position works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant