dwavesystems / demos

WARNING: This repo is obsolete. For D-Wave Ocean code examples, go to the `dwave-examples` GitHub account.
https://github.com/dwave-examples
Apache License 2.0
37 stars 36 forks source link

tetris demo #112

Closed Astromitch closed 4 years ago

Astromitch commented 4 years ago

added a D-Wave tetris demo base off of a Tetronimo clone

m3ller commented 4 years ago

Hi @Astromitch, thank you for making a pull request to the D-Wave Demos repo!

I had made a pull of your demos master branch, and was not able to successfully run the Tetris game. Following your instructions, I set up the Jupyter notebook and ran the code. The Tetromino game popped up, and after placing the first piece, a few other pieces would get placed down by the computer before the game would stall. Is this something you anticipated or am I doing something wrong on my end?

m3ller commented 4 years ago

Here is my pip freeze. Note that I had installed jupyter notebook by hand as there is some incompatibilities in the tetris requirements.txt for jupyter notebook.

backcall==0.1.0
bleach==3.1.0
certifi==2019.9.11
chardet==3.0.4
Click==7.0
cycler==0.10.0
decorator==4.4.0
defusedxml==0.6.0
dimod==0.8.14
dwave-cloud-client==0.5.4
dwave-hybrid==0.3.1
dwave-neal==0.5.1
dwave-networkx==0.8.0
dwave-ocean-sdk==1.4.0
dwave-qbsolv==0.2.10
dwave-system==0.7.5
dwave-tabu==0.2.0
dwavebinarycsp==0.0.10
entrypoints==0.3
homebase==1.0.1
idna==2.8
ipykernel==4.8.2
ipython==6.4.0
ipython-genutils==0.2.0
ipywidgets==7.2.1
jedi==0.15.1
Jinja2==2.10.1
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.3.3
jupyter-console==5.2.0
jupyter-core==4.4.0
jupyterlab==0.32.1
jupyterlab-launcher==0.10.5
kiwisolver==1.1.0
MarkupSafe==1.1.1
matplotlib==3.0.3
minorminer==0.1.7
mistune==0.8.4
nbconvert==5.6.0
nbformat==4.4.0
networkx==2.3
notebook==6.0.1
numpy==1.15.4
pandocfilters==1.4.2
parso==0.5.1
penaltymodel==0.15.4
penaltymodel-cache==0.3.3
pexpect==4.7.0
pickleshare==0.7.5
plucky==0.4.3
prometheus-client==0.7.1
prompt-toolkit==1.0.16
ptyprocess==0.6.0
pygame==1.9.4
Pygments==2.4.2
pyparsing==2.4.2
pyqubo==0.4.0
PySocks==1.7.1
python-dateutil==2.8.0
pyzmq==18.1.0
qtconsole==4.5.5
requests==2.22.0
Send2Trash==1.5.0
simplegeneric==0.8.1
six==1.12.0
terminado==0.8.2
testpath==0.4.2
tornado==6.0.3
traitlets==4.3.2
urllib3==1.25.6
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.2.1
Astromitch commented 4 years ago

Sorry for the delayed response.

This is a bug I am aware of and I think it was introduced when I used the grid height(y) in the calculations of the biases(h) so the lower grid points are more likely to be filled. I tried to make it work by varying the temperature parameter beta in order to try and prevent it from getting stuck which you can see in the Tetris.py file. Maybe a better solution would be to normalize y to the height of filled spaces in the column so the probability of flipping isn’t still really low when the bottom grid points are filled. Overall the calculation of the h biases and the J couplings could be greatly improved. This was just a first attempt but unfortunately I won’t be updating it with improvements. Below is the relevant section. If you play around with the h.update hopefully you can get to a place where it won't stall.

h={}
for x in range(max_width):
    for y in range(max_height):
         if isinstance(board_[x][y],str):
                h.update({f'{x}_{y}':-y/max_height})
m3ller commented 4 years ago

I pulled your new commits in and tried running the game again. Unfortunately, the game is still stalling.

Since you had mentioned that you won't be updating this PR with improvements and since we cannot accept this PR in its current state, unfortunately, we will have to close this pull request at this time. Please feel free to re-open this PR if you have time to work on it in the future.