Skip to content

Instantly share code, notes, and snippets.

@quantumjim
Created September 17, 2018 06:44
Show Gist options
  • Save quantumjim/d5b463c95cfa07900c6de3090822fb32 to your computer and use it in GitHub Desktop.
Save quantumjim/d5b463c95cfa07900c6de3090822fb32 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome to Quantum tic tac toe!\n",
"At each turn choose if to make one or two moves.\n",
"Playing one move at a time is a classic tic tac toe game.\n",
"At each turn the game state is printed;\n",
"X3 is the third move, played by X. When a move is made in a super position,\n",
"You will see its label, say X3, appear in several places.\n",
"This means your move is in a superposition of two classical moves!\n",
"You can make a move in a possibly occupied spot.\n",
"Then the new move will be anti-correlated with the move already in that spot.\n",
"And so the game branches out into many possible states.\n",
"The outcome is then computed by simulation...\n",
"so don't make too many quantum moves or it will take long to compute!\n",
"Enter 'q' at any time to quit\n",
"Enter 'end' to end the game, and compute the winner(s).\n",
"Good luck!\n",
"PLAYER 0:\n",
"Play in 1 or 2 cells?1\n",
"x index:0\n",
"y index:0\n",
"[['X1' '' '']\n",
" ['' '' '']\n",
" ['' '' '']]\n",
"PLAYER 1:\n",
"Play in 1 or 2 cells?1\n",
"x index:2\n",
"y index:2\n",
"[['X1' '' '']\n",
" ['' '' '']\n",
" ['' '' 'O2']]\n",
"PLAYER 0:\n",
"Play in 1 or 2 cells?1\n",
"x index:0\n",
"y index:1\n",
"[['X1' 'X3' '']\n",
" ['' '' '']\n",
" ['' '' 'O2']]\n",
"PLAYER 1:\n",
"Play in 1 or 2 cells?1\n",
"x index:1\n",
"y index:2\n",
"[['X1' 'X3' '']\n",
" ['' '' 'O4']\n",
" ['' '' 'O2']]\n",
"PLAYER 0:\n",
"Play in 1 or 2 cells?1\n"
]
}
],
"source": [
"run q_tic_tac_toe.py"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment