Skip to content

Commit

Permalink
Merge pull request #192 from solodov/main
Browse files Browse the repository at this point in the history
Moved all examples out of the package directory into the top level examples directory
  • Loading branch information
dstrain115 authored Jun 20, 2024
2 parents db8743f + 02ec75e commit 0013a84
Show file tree
Hide file tree
Showing 63 changed files with 304 additions and 298 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import pytest

import unitary.examples.fox_in_a_hole.fox_in_a_hole as fh
from . import fox_in_a_hole as fh


def test_classical_game_basics():
Expand Down
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
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 unitary.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
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import enum
import io
import sys
from typing import List, Optional, Set

import unitary.examples.quantum_rpg.game_state as game_state
import unitary.examples.quantum_rpg.input_helpers as input_helpers
from unitary.examples.quantum_rpg.qaracter import Qaracter
from unitary.examples.quantum_rpg.xp_utils import EncounterXp
from . import game_state, input_helpers
from .qaracter import Qaracter
from .xp_utils import EncounterXp

# Size of the player side of battle status,
# for text alingment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
# limitations under the License.

import io
import unitary.examples.quantum_rpg.battle as battle
import unitary.examples.quantum_rpg.classes as classes
import unitary.examples.quantum_rpg.game_state as game_state
import unitary.examples.quantum_rpg.npcs as npcs

from . import battle
from . import classes
from . import game_state
from . import npcs


def test_battle():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import random
import re

from unitary.examples.quantum_rpg.game_state import GameState
from unitary.examples.quantum_rpg.item import EXAMINE, TALK, Item
from unitary.examples.quantum_rpg.world import Direction, Location
from .game_state import GameState
from .item import EXAMINE, TALK, Item
from .world import Direction, Location


_WORDS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
import io

import pytest
import unitary.examples.quantum_rpg.bb84 as bb84
import unitary.examples.quantum_rpg.game_state as game_state
import unitary.examples.quantum_rpg.input_helpers as input_helpers
import unitary.examples.quantum_rpg.main_loop as main_loop
import unitary.examples.quantum_rpg.world as world

from . import bb84
from . import game_state
from . import input_helpers
from . import main_loop
from . import world


def test_to_bin():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any, Callable, Dict
from typing import Callable, Dict

from unitary import alpha
from unitary.examples.quantum_rpg import qaracter

from . import qaracter


class Engineer(qaracter.Qaracter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
# limitations under the License.

import unitary.alpha as alpha
import unitary.examples.quantum_rpg.classes as classes
import unitary.examples.quantum_rpg.enums as enums
import unitary.examples.quantum_rpg.qaracter as qaracter

from . import classes
from . import enums
from . import qaracter


def test_engineer():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

import random

import unitary.examples.quantum_rpg.battle as battle
import unitary.examples.quantum_rpg.game_state as game_state
import unitary.examples.quantum_rpg.qaracter as qaracter
import unitary.examples.quantum_rpg.xp_utils as xp_utils
from typing import Sequence
from . import battle
from . import game_state
from . import qaracter
from . import xp_utils


class Encounter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import io

import unitary.alpha as alpha
import unitary.examples.quantum_rpg.battle as battle
import unitary.examples.quantum_rpg.classes as classes
import unitary.examples.quantum_rpg.encounter as encounter
import unitary.examples.quantum_rpg.game_state as game_state
import unitary.examples.quantum_rpg.npcs as npcs
import unitary.examples.quantum_rpg.xp_utils as xp_utils

from . import battle
from . import classes
from . import encounter
from . import game_state
from . import npcs
from . import xp_utils


def test_trigger():
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
# limitations under the License.
import unitary.alpha as alpha

from unitary.examples.quantum_rpg.classes import Engineer
from unitary.examples.quantum_rpg.encounter import Encounter
from unitary.examples.quantum_rpg.exceptions import UntimelyDeathException
from unitary.examples.quantum_rpg.game_state import GameState
from unitary.examples.quantum_rpg.final_state_preparation.monsters import (
from ..classes import Engineer
from ..encounter import Encounter
from ..exceptions import UntimelyDeathException
from ..game_state import GameState
from .monsters import (
green_foam,
blue_foam,
red_foam,
)
from unitary.examples.quantum_rpg.item import EXAMINE, TALK, Item
from unitary.examples.quantum_rpg.world import Direction, Location
from ..item import EXAMINE, TALK, Item
from ..world import Direction, Location

RICHARD = Item(
keyword_actions=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# limitations under the License.
"""Module to combine all the zones of the RPG world into one list."""

import unitary.examples.quantum_rpg.final_state_preparation.classical_frontier as classical_frontier
import unitary.examples.quantum_rpg.final_state_preparation.oxtail_university as oxtail_university
import unitary.examples.quantum_rpg.final_state_preparation.hadamard_hills as hadamard_hills
import unitary.examples.quantum_rpg.final_state_preparation.quantum_perimeter as quantum_perimeter
from . import classical_frontier
from . import oxtail_university
from . import hadamard_hills
from . import quantum_perimeter


WORLD = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import pytest
import io

import unitary.examples.quantum_rpg.classes as classes
import unitary.examples.quantum_rpg.exceptions as exceptions
import unitary.examples.quantum_rpg.game_state as game_state
import unitary.examples.quantum_rpg.final_state_preparation.final_state_world as final_state
from unitary.examples.quantum_rpg.world import Direction, World
from .. import classes
from .. import exceptions
from .. import game_state
from ..final_state_preparation import final_state_world as final_state
from ..world import Direction, World


OPPOSITE_DIR = {
Expand Down
Loading

0 comments on commit 0013a84

Please sign in to comment.