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

Adding algorithm TD Learning with N-Tuple Networks for 2048 #1107

Merged
merged 12 commits into from
Sep 12, 2023

Conversation

Jazeem
Copy link
Contributor

@Jazeem Jazeem commented Aug 9, 2023

An algorithm that can win at 2048 without using tree search or hand crafted state evaluator functions.

Currently the code is somewhat coupled with 2048. It is possible to decouple it, if that is valuable for open_spiel. Will have to find a way to move n_tuples into game.

Have modified the game 2048 to consider a move that doesn't change the board as invalid

Implementation is similar to https://github.com/moporgic/TDL2048-Demo

@lanctot
Copy link
Collaborator

lanctot commented Aug 9, 2023

Cool! We had quite a big refactor committed to the master branch yesterday. Could you pull changes from master and commit the merge (or rebase)?

We basically just moved all the games into subdirectories.

I cannot run the tests while there are conflicts.

@Jazeem
Copy link
Contributor Author

Jazeem commented Aug 10, 2023

Sure. Rebased now 👍🏻

Copy link
Collaborator

@lanctot lanctot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you lint your code by following Step 9 in the Adding a New Game on this page? https://github.com/deepmind/open_spiel/blob/master/docs/developer_guide.md

It greatly reduced the load on our end to have the code formatted as required by Google python standards.

E.g. indentation should be two spaces, not four. Etc.

open_spiel/python/examples/2048_td_n_tuple_network.py Outdated Show resolved Hide resolved
open_spiel/python/examples/2048_td_n_tuple_network.py Outdated Show resolved Hide resolved
open_spiel/python/examples/2048_td_n_tuple_network.py Outdated Show resolved Hide resolved
open_spiel/python/examples/2048_td_n_tuple_network.py Outdated Show resolved Hide resolved
@Jazeem
Copy link
Contributor Author

Jazeem commented Sep 1, 2023

@lanctot

  • Used pylint and formatted the code
  • Introduced a class NTupleNetwork and added a brief description about what N-Tuples are and a citation to a IEEE paper that this implementation is based on
  • The output of the code is very straightforward similar to breakthrough_dqn.py in that for every 1000 runs; the code prints what's the average score reached, max score and largest tile that was unlocked. Running the code you can see the average scores increasing indicating that learning is happening. Once the 2048 tile is unlocked, the agent is able to win the game

@lanctot
Copy link
Collaborator

lanctot commented Sep 5, 2023

Hi @Jazeem,

Can you respond to the conversations above (or resolve them now if they are resolved)

@Jazeem
Copy link
Contributor Author

Jazeem commented Sep 7, 2023

@lanctot

Have resolved them

@lanctot lanctot added imported This PR has been imported and awaiting internal review. Please avoid any more local changes, thanks! merged internally The code is now submitted to our internal repo and will be merged in the next github sync. labels Sep 7, 2023
@lanctot lanctot merged commit 2847cef into google-deepmind:master Sep 12, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported This PR has been imported and awaiting internal review. Please avoid any more local changes, thanks! merged internally The code is now submitted to our internal repo and will be merged in the next github sync.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants