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

u64 implementation #1

Open
Incompleteusern opened this issue Dec 11, 2023 · 1 comment
Open

u64 implementation #1

Incompleteusern opened this issue Dec 11, 2023 · 1 comment

Comments

@Incompleteusern
Copy link

Currently, the grid used for searching

type Grid = [[u8; 4]; 4];

is stored as an array of u8s.

In normal 2048, the max score is $2^{17}$. An adversarial opponent can likely guarantee that even $2^{16}$ is unobtainable, so its possible to reduce the grid to being one u64 to halve memory usage as it stands right now.

This also allows for replacing the array calls with bit manipulations, which is probably also faster.

@howard36
Copy link
Owner

Yeah, this is a good optimization.

But FYI, I'm not actively working on this project at the moment, so don't expect any changes for a while. For now I'll add it to my todo list that keeps growing

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

2 participants