Skip to content

Commit

Permalink
moved Chinese chess
Browse files Browse the repository at this point in the history
  • Loading branch information
solodov committed May 22, 2024
1 parent 39a725c commit ced46d0
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 35 deletions.
7 changes: 7 additions & 0 deletions examples/quantum_chinese_chess/README.md
Original file line number Diff line number Diff line change
@@ -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
```
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
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,
Language,
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -22,7 +22,7 @@
MoveVariant,
TerminalType,
)
from unitary.examples.quantum_chinese_chess.move import (
from .move import (
Jump,
SplitJump,
MergeJump,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/quantum_rpg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/tic_tac_toe/README.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit ced46d0

Please sign in to comment.