-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from GamesCrafters/dev
Release 0.3.0
- Loading branch information
Showing
47 changed files
with
1,631 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[report] | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# configuration related to pull request comments | ||
comment: no # do not comment PR with the result | ||
|
||
coverage: | ||
range: 70..80 # coverage lower than 50 is red, higher than 90 green, between color code | ||
|
||
status: | ||
project: # settings affecting project coverage | ||
default: | ||
target: auto # auto % coverage target | ||
threshold: 5% # allow for 5% reduction of coverage without failing | ||
|
||
# do not run coverage on patch nor changes | ||
patch: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Server Introduction | ||
GamesmanPuzzles provides a Web API to display values of puzzles. This guide will adapt our puzzle from the previous steps into a format which can be displayed onto the Web API. | ||
|
||
You can manually run the server by running | ||
```python | ||
python -m puzzlesolver.server | ||
``` | ||
and accessing [http://localhost:9001](http://localhost:9001). You can explore the Web API using the documentation (to do soon). | ||
|
||
## Prerequisites | ||
|
||
After this guide, you should able to display a puzzle in a test application. | ||
|
||
Begin by importing all the extra dependencies in our Hanoi puzzle that we made before | ||
```python | ||
from puzzlesolver.puzzles import ServerPuzzle | ||
``` | ||
|
||
Change the class we inherit from Puzzle to ServerPuzzle | ||
|
||
```python | ||
class Hanoi(ServerPuzzle): | ||
``` | ||
|
||
The next steps would be implementing extra functions: | ||
[Next Step: PuzzleID](08_PuzzleID.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Puzzle ID | ||
``` | ||
GET puzzles/<puzzle_id> | ||
``` | ||
The first part of our url is the identification of our puzzle. This is a class variable and can be used to access the variants (next section). | ||
|
||
Define it inside your class: | ||
```python | ||
class Hanoi(ServerPuzzle): | ||
puzzleid = 'hanoi' | ||
``` | ||
|
||
[Next Step: Variants](09_Variants.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Variants Introduction | ||
|
||
``` | ||
GET puzzles/<puzzle_id>/<variant_id> | ||
``` | ||
|
||
Sometimes we want our puzzle to support multiple versions of itself. For example, in Hanoi we can support puzzles with more than just three discs. To support this, we introduce **Variants**. | ||
|
||
## Variants | ||
A **variant** is a modified version of a puzzle (i.e. more pieces, different orientation). Each puzzle variant is independent of each other, defined to be that there is no position in one variant that can exist in another variant. | ||
|
||
Each initialized puzzle will have a different variant, so we need to modify the `__init__()` and `generateSolutions()` functions to support different variant (size) numbers. | ||
|
||
#### **`__init__()`** | ||
```python | ||
def __init__(self, size=3, **kwargs): | ||
self.stacks = [ | ||
list(range(size, 0, -1)), | ||
[], | ||
[] | ||
] | ||
``` | ||
|
||
#### **`generateSolutions()`** | ||
```python | ||
def generateSolutions(self, **kwargs): | ||
newPuzzle = Hanoi(size=int(self.variant)) | ||
newPuzzle.stacks = [ | ||
[], | ||
[], | ||
list(range(int(self.variant), 0, -1)) | ||
] | ||
return [newPuzzle] | ||
``` | ||
|
||
We also need a property to get the current variant of the puzzle. (`@property` is a tag that we use to defined the function as a property of the function, such as `Hanoi().variant`) | ||
```python | ||
@property | ||
def variant(self): | ||
size = 0 | ||
for stack in self.stacks: | ||
size += len(stack) | ||
return str(size) | ||
``` | ||
Our server requires that we define a dictionary with variant ids as the keys as well as different Solver classes as the values. *Note: The reason for this is that different variants may use different solvers.* | ||
|
||
Just for these purposes, lets consider only variants up to 3 as well as using the GeneralSolver as the main solver. | ||
```python | ||
variants = { | ||
str(i) : GeneralSolver for i in range(1, 4) | ||
} | ||
``` | ||
[Next Step: Positions](10_Positions.md) |
Oops, something went wrong.