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

Implement Transposition Table #17

Open
mateusz2173 opened this issue May 14, 2024 · 8 comments · Fixed by #28
Open

Implement Transposition Table #17

mateusz2173 opened this issue May 14, 2024 · 8 comments · Fixed by #28
Assignees

Comments

@mateusz2173
Copy link
Collaborator

mateusz2173 commented May 14, 2024

Read https://www.chessprogramming.org/Transposition_Table
Transposition Table is a cache table for search.
Implement transposition table which can store 3 types of scores:

  1. EXACT - exact value found during search. We should store it every time we found exact value,
    that is when alpha < score < beta
  2. BETA - should be stored when search fails high, that is when alpha < beta <= score
  3. ALPHA - should be stored when search fails low, that is when neither 1 or 2 happened. (score <= alpha)

Along with scores we should also store:

  • depth (on which we write entry to transposition table)
  • move associated with found score

If entry already exists for the position, replace it only if current_depth > old_entry_depth

Add reading transposition table to the beginning of the search (before we jump into searching moves):
In case we've found cache entry for the position and depth_entry >= current_depth then we can return cached score.

Let's make cache size = 16MB for now
Index the table using zobryist hashes (they are implemented in our base - chess.hpp)
entry = table[position.hash % table_size]

@mateusz2173
Copy link
Collaborator Author

Should be done after this: #10

@DomiKoPL
Copy link
Collaborator

I will start working on this today.

@DomiKoPL DomiKoPL reopened this May 27, 2024
@mateusz2173
Copy link
Collaborator Author

mateusz2173 commented May 29, 2024

One more thing:

Operations on TT (write, read entry) should be safe to use with multiple threads.

We'll rely on it later.

One can do it with atomics or lockless tricks (like here https://www.chessprogramming.org/Shared_Hash_Table#Lockless) or whatever you consider good enough

@DomiKoPL
Copy link
Collaborator

Ohhhh, that changes things a bit. Sure I will change it.

@mateusz2173
Copy link
Collaborator Author

Thx and sorry for the confusion

@DomiKoPL
Copy link
Collaborator

I should come up with some solution by the EOW.

@DomiKoPL
Copy link
Collaborator

@mateusz2173 Should TT also include age?

@mateusz2173
Copy link
Collaborator Author

If it doesnt require a lot of effort, let's include it.

@Gustav2137 Gustav2137 linked a pull request Jun 17, 2024 that will close this issue
@DomiKoPL DomiKoPL reopened this Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants