Module quickpython.examples.eightpuzzle
/games/eightpuzzle.py
Copyright (c) 2019 ShineyDev
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 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.
View Source
"""
/games/eightpuzzle.py
Copyright (c) 2019 ShineyDev
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
"""
__authors__ = [("shineydev", "contact@shiney.dev")]
__maintainers__ = [("shineydev", "contact@shiney.dev")]
__version_info__ = (0, 0, 1, "alpha", 0)
__version__ = "{0}.{1}.{2}{3}{4}".format(
*[str(n)[0] if (i == 3) else str(n) for (i, n) in enumerate(__version_info__)]
)
import os
import pyfiglet
class EightPuzzle:
def __init__(self):
"""
initializes an `EightPuzzle` object
"""
pass
def game(self):
"""
starts the game
"""
pass
def start(self):
"""
calls `self.game` in a 'would you like to play again?' loop
"""
choice = "y"
while choice.startswith("y"):
cls()
print(pyfiglet.figlet_format("Eight Puzzle"))
print()
input("enter to play\nctrl + c to quit to main menu\n\n")
self.game()
choice = input("\nwould you like to play again?\n> ").strip()
if __name__ == "__main__":
game = EightPuzzle()
game.start()
Classes
EightPuzzle
class EightPuzzle(
)
View Source
class EightPuzzle:
def __init__(self):
"""
initializes an `EightPuzzle` object
"""
pass
def game(self):
"""
starts the game
"""
pass
def start(self):
"""
calls `self.game` in a 'would you like to play again?' loop
"""
choice = "y"
while choice.startswith("y"):
cls()
print(pyfiglet.figlet_format("Eight Puzzle"))
print()
input("enter to play\nctrl + c to quit to main menu\n\n")
self.game()
choice = input("\nwould you like to play again?\n> ").strip()
Methods
game
def game(
self
)
starts the game
View Source
def game(self):
"""
starts the game
"""
pass
start
def start(
self
)
calls self.game
in a 'would you like to play again?' loop
View Source
def start(self):
"""
calls `self.game` in a 'would you like to play again?' loop
"""
choice = "y"
while choice.startswith("y"):
cls()
print(pyfiglet.figlet_format("Eight Puzzle"))
print()
input("enter to play\nctrl + c to quit to main menu\n\n")
self.game()
choice = input("\nwould you like to play again?\n> ").strip()