diff --git a/examples/quantum_chinese_chess/README.md b/examples/quantum_chinese_chess/README.md new file mode 100644 index 00000000..badb4c69 --- /dev/null +++ b/examples/quantum_chinese_chess/README.md @@ -0,0 +1,7 @@ +# How to use the game + +After cloning the Unitary library you can use command line flags to run the game: + +``` +python -m examples.quantum_chinese_chess.chess +``` diff --git a/unitary/examples/quantum_chinese_chess/__init__.py b/examples/quantum_chinese_chess/__init__.py similarity index 100% rename from unitary/examples/quantum_chinese_chess/__init__.py rename to examples/quantum_chinese_chess/__init__.py diff --git a/unitary/examples/quantum_chinese_chess/board.py b/examples/quantum_chinese_chess/board.py similarity index 98% rename from unitary/examples/quantum_chinese_chess/board.py rename to examples/quantum_chinese_chess/board.py index ce77b851..87170f9a 100644 --- a/unitary/examples/quantum_chinese_chess/board.py +++ b/examples/quantum_chinese_chess/board.py @@ -14,7 +14,7 @@ import numpy as np from typing import List, Tuple import unitary.alpha as alpha -from unitary.examples.quantum_chinese_chess.enums import ( +from .enums import ( SquareState, Color, Type, @@ -22,8 +22,8 @@ MoveVariant, TerminalType, ) -from unitary.examples.quantum_chinese_chess.piece import Piece -from unitary.examples.quantum_chinese_chess.move import Jump +from .piece import Piece +from .move import Jump # The default initial state of the game. diff --git a/unitary/examples/quantum_chinese_chess/board_test.py b/examples/quantum_chinese_chess/board_test.py similarity index 97% rename from unitary/examples/quantum_chinese_chess/board_test.py rename to examples/quantum_chinese_chess/board_test.py index 20b64f13..93649056 100644 --- a/unitary/examples/quantum_chinese_chess/board_test.py +++ b/examples/quantum_chinese_chess/board_test.py @@ -12,16 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from unitary.examples.quantum_chinese_chess.enums import ( +from .enums import ( Language, Color, Type, SquareState, TerminalType, ) -from unitary.examples.quantum_chinese_chess.board import Board -from unitary.examples.quantum_chinese_chess.piece import Piece -from unitary.examples.quantum_chinese_chess.test_utils import ( +from .board import Board +from .piece import Piece +from .test_utils import ( locations_to_bitboard, assert_samples_in, assert_sample_distribution, diff --git a/unitary/examples/quantum_chinese_chess/chess.py b/examples/quantum_chinese_chess/chess.py similarity index 99% rename from unitary/examples/quantum_chinese_chess/chess.py rename to examples/quantum_chinese_chess/chess.py index e0c35ebe..34543f6e 100644 --- a/unitary/examples/quantum_chinese_chess/chess.py +++ b/examples/quantum_chinese_chess/chess.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. from typing import Tuple, List -from unitary.examples.quantum_chinese_chess.board import Board -from unitary.examples.quantum_chinese_chess.enums import ( +from .board import Board +from .enums import ( Language, GameState, Type, @@ -22,7 +22,7 @@ MoveVariant, TerminalType, ) -from unitary.examples.quantum_chinese_chess.move import ( +from .move import ( Jump, SplitJump, MergeJump, diff --git a/unitary/examples/quantum_chinese_chess/chess_test.py b/examples/quantum_chinese_chess/chess_test.py similarity index 98% rename from unitary/examples/quantum_chinese_chess/chess_test.py rename to examples/quantum_chinese_chess/chess_test.py index ba307107..50f08c30 100644 --- a/unitary/examples/quantum_chinese_chess/chess_test.py +++ b/examples/quantum_chinese_chess/chess_test.py @@ -14,16 +14,16 @@ import pytest import io import sys -from unitary.examples.quantum_chinese_chess.test_utils import ( +from .test_utils import ( set_board, assert_sample_distribution, locations_to_bitboard, assert_samples_in, ) from unitary import alpha -from unitary.examples.quantum_chinese_chess.chess import QuantumChineseChess -from unitary.examples.quantum_chinese_chess.piece import Piece -from unitary.examples.quantum_chinese_chess.enums import ( +from .chess import QuantumChineseChess +from .piece import Piece +from .enums import ( Language, Color, Type, diff --git a/unitary/examples/quantum_chinese_chess/enums.py b/examples/quantum_chinese_chess/enums.py similarity index 100% rename from unitary/examples/quantum_chinese_chess/enums.py rename to examples/quantum_chinese_chess/enums.py diff --git a/unitary/examples/quantum_chinese_chess/enums_test.py b/examples/quantum_chinese_chess/enums_test.py similarity index 95% rename from unitary/examples/quantum_chinese_chess/enums_test.py rename to examples/quantum_chinese_chess/enums_test.py index 2f77c6e4..2dd047d4 100644 --- a/unitary/examples/quantum_chinese_chess/enums_test.py +++ b/examples/quantum_chinese_chess/enums_test.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from unitary.examples.quantum_chinese_chess.enums import Type, Color, Language +from .enums import Type, Color, Language def test_type_of(): diff --git a/unitary/examples/quantum_chinese_chess/move.py b/examples/quantum_chinese_chess/move.py similarity index 99% rename from unitary/examples/quantum_chinese_chess/move.py rename to examples/quantum_chinese_chess/move.py index f1fddcfa..6f602612 100644 --- a/unitary/examples/quantum_chinese_chess/move.py +++ b/examples/quantum_chinese_chess/move.py @@ -15,8 +15,8 @@ import cirq from unitary import alpha from unitary.alpha.quantum_effect import QuantumEffect -from unitary.examples.quantum_chinese_chess.piece import Piece -from unitary.examples.quantum_chinese_chess.enums import MoveType, MoveVariant, Type +from .piece import Piece +from .enums import MoveType, MoveVariant, Type # TODO(): now the class is no longer the base class of all chess moves. Maybe convert this class diff --git a/unitary/examples/quantum_chinese_chess/move_test.py b/examples/quantum_chinese_chess/move_test.py similarity index 99% rename from unitary/examples/quantum_chinese_chess/move_test.py rename to examples/quantum_chinese_chess/move_test.py index ec901de5..27e38273 100644 --- a/unitary/examples/quantum_chinese_chess/move_test.py +++ b/examples/quantum_chinese_chess/move_test.py @@ -11,20 +11,22 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from unitary.examples.quantum_chinese_chess.move import * -from unitary.examples.quantum_chinese_chess.board import Board -from unitary.examples.quantum_chinese_chess.piece import Piece +from typing import List + import pytest from unitary import alpha -from typing import List -from unitary.examples.quantum_chinese_chess.enums import ( + +from .move import * +from .board import Board +from .piece import Piece +from .enums import ( MoveType, MoveVariant, SquareState, Type, Color, ) -from unitary.examples.quantum_chinese_chess.test_utils import ( +from .test_utils import ( locations_to_bitboard, assert_samples_in, assert_sample_distribution, diff --git a/unitary/examples/quantum_chinese_chess/piece.py b/examples/quantum_chinese_chess/piece.py similarity index 97% rename from unitary/examples/quantum_chinese_chess/piece.py rename to examples/quantum_chinese_chess/piece.py index fc6736e8..801a0c75 100644 --- a/unitary/examples/quantum_chinese_chess/piece.py +++ b/examples/quantum_chinese_chess/piece.py @@ -13,7 +13,7 @@ # limitations under the License. from typing import Optional from unitary.alpha import QuantumObject -from unitary.examples.quantum_chinese_chess.enums import ( +from .enums import ( SquareState, Language, Color, diff --git a/unitary/examples/quantum_chinese_chess/piece_test.py b/examples/quantum_chinese_chess/piece_test.py similarity index 94% rename from unitary/examples/quantum_chinese_chess/piece_test.py rename to examples/quantum_chinese_chess/piece_test.py index 650960ea..e5a94139 100644 --- a/unitary/examples/quantum_chinese_chess/piece_test.py +++ b/examples/quantum_chinese_chess/piece_test.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from unitary.examples.quantum_chinese_chess.enums import ( +from unitary.alpha import QuantumWorld + +from .enums import ( SquareState, Language, Color, Type, ) -from unitary.examples.quantum_chinese_chess.piece import Piece -from unitary.alpha import QuantumWorld +from .piece import Piece def test_symbol(): diff --git a/unitary/examples/quantum_chinese_chess/test_utils.py b/examples/quantum_chinese_chess/test_utils.py similarity index 96% rename from unitary/examples/quantum_chinese_chess/test_utils.py rename to examples/quantum_chinese_chess/test_utils.py index 8f4c6f24..a4033a58 100644 --- a/unitary/examples/quantum_chinese_chess/test_utils.py +++ b/examples/quantum_chinese_chess/test_utils.py @@ -11,14 +11,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from unitary.alpha import QuantumObject, QuantumWorld -from unitary.examples.quantum_chinese_chess.enums import SquareState, Type, Color -from unitary.examples.quantum_chinese_chess.board import Board -from unitary.examples.quantum_chinese_chess.piece import Piece -from unitary import alpha from typing import List, Dict from collections import defaultdict + from scipy.stats import chisquare +from unitary import alpha +from unitary.alpha import QuantumObject, QuantumWorld + +from .enums import SquareState, Type, Color +from .board import Board +from .piece import Piece _EMPTY_FEN = "9/9/9/9/9/9/9/9/9/9 w---1" diff --git a/examples/quantum_rpg/README.md b/examples/quantum_rpg/README.md index 0fbd5bc2..bc96d2c9 100644 --- a/examples/quantum_rpg/README.md +++ b/examples/quantum_rpg/README.md @@ -23,7 +23,7 @@ The second part explains the rules and principles behind the Quantum RPG. In order to run the game, clone the github repo, make sure that any requirements are installed with a command such as `pip install -r requirements.txt` -then run `python -m examples.quantum_rpg.main_loop` + * [ ] then run `python -m examples.quantum_rpg.main_loop` (you may need to make sure that the Unitary library is in your PYTHONPATH). If you do not have a python environment handy or are not familiar with setting diff --git a/examples/tic_tac_toe/README.md b/examples/tic_tac_toe/README.md index 56719dfb..29012645 100644 --- a/examples/tic_tac_toe/README.md +++ b/examples/tic_tac_toe/README.md @@ -1,7 +1,7 @@ # How to use the game -This is a command line game. After cloning the Unitary library, change the directory into `examples/`. You can use command line flags to run the game: +After cloning the Unitary library you can use command line flags to run the game: ``` -python -m tic_tac_toe.tic_tac_toe +python -m examples.tic_tac_toe.tic_tac_toe ```