mirror of https://github.com/dirtbags/moth.git
Pull out puzzle.py puzzles.
Since these depend on stuff I'm about to yank out (and John is about to fork into a new "moth" Python library), they no longer belong in this source tree.
This commit is contained in:
parent
23adea7df5
commit
522e5dbf6c
|
@ -1,6 +1,12 @@
|
|||
Author: neale
|
||||
Summary: Making excellent puzzles
|
||||
Answer: moo
|
||||
---
|
||||
pre:
|
||||
authors:
|
||||
- neale
|
||||
debug:
|
||||
summary: Making excellent puzzles
|
||||
answers:
|
||||
- moo
|
||||
---
|
||||
|
||||
Making Excellent Puzzles
|
||||
====================
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import io
|
||||
|
||||
def make(puzzle):
|
||||
puzzle.author = 'neale'
|
||||
puzzle.summary = 'crazy stuff you can do with puzzle generation'
|
||||
|
||||
puzzle.body.write("## Crazy Things You Can Do With Puzzle Generation\n")
|
||||
puzzle.body.write("\n")
|
||||
puzzle.body.write("The source to this puzzle has some advanced examples of stuff you can do in Python.\n")
|
||||
puzzle.body.write("\n")
|
||||
|
||||
# You can use any file-like object; even your own class that generates output.
|
||||
f = io.BytesIO("This is some text! Isn't that fantastic?".encode('utf-8'))
|
||||
puzzle.add_stream(f)
|
||||
|
||||
# We have debug logging
|
||||
puzzle.log("You don't have to disable puzzle.log calls to move to production; the debug log is just ignored at build-time.")
|
||||
puzzle.log("HTML is <i>escaped</i>, so you don't have to worry about that!")
|
||||
|
||||
puzzle.answers.append('coffee')
|
||||
answer = puzzle.make_answer() # Generates a random answer, appending it to puzzle.answers too
|
||||
puzzle.log("Answers: {}".format(puzzle.answers))
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import io
|
||||
import categorylib # Category-level libraries can be imported here
|
||||
|
||||
def make(puzzle):
|
||||
import puzzlelib # puzzle-level libraries can only be imported inside of the make function
|
||||
puzzle.authors = ['donaldson']
|
||||
puzzle.summary = 'more crazy stuff you can do with puzzle generation using Python libraries'
|
||||
|
||||
puzzle.body.write("## Crazy Things You Can Do With Puzzle Generation (part II)\n")
|
||||
puzzle.body.write("\n")
|
||||
puzzle.body.write("The source to this puzzle has some more advanced examples of stuff you can do in Python.\n")
|
||||
puzzle.body.write("\n")
|
||||
puzzle.body.write("1 == %s\n\n" % puzzlelib.getone(),)
|
||||
puzzle.body.write("2 == %s\n\n" % categorylib.gettwo(),)
|
||||
|
||||
puzzle.answers.append('tea')
|
||||
answer = puzzle.make_answer() # Generates a random answer, appending it to puzzle.answers too
|
||||
puzzle.log("Answers: {}".format(puzzle.answers))
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
"""This is an example of a puzzle-level library.
|
||||
|
||||
This library can be imported by sibling puzzles using `import puzzlelib`
|
||||
"""
|
||||
|
||||
def getone():
|
||||
return 1
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
pre:
|
||||
authors:
|
||||
- neale
|
||||
answers:
|
||||
- YAML
|
||||
- yaml
|
||||
debug:
|
||||
summary: YAML Metadata
|
||||
post:
|
||||
objective: Understand how YAML metadata can be used in a `.moth` file
|
||||
success:
|
||||
acceptable: Enter the answer and move on
|
||||
mastery: Create a `.md` file using YAML metadata and serve it through the devel server.
|
||||
---
|
||||
|
||||
You can also provide metadata in YAML format.
|
||||
This puzzle's `.md` file serves as an example.
|
|
@ -1,24 +0,0 @@
|
|||
#! /bin/sh
|
||||
|
||||
cat <<EOD
|
||||
{
|
||||
"pre": {
|
||||
"authors": ["neale"],
|
||||
"body": "\
|
||||
<h1>Writing Your Own Generator<h1>\
|
||||
<p>\
|
||||
You can output the JSON puzzle format if you want.\
|
||||
See the source of this puzzle for an example!\
|
||||
</p>\
|
||||
"
|
||||
},
|
||||
"debug": {
|
||||
"log": [
|
||||
"There are many fields you can specify, aside from those in this file.",
|
||||
"See puzzle.moth for the full spec.",
|
||||
"MOTH_PUZZLE_SEED=$MOTH_PUZZLE_SEED"
|
||||
]
|
||||
},
|
||||
"answers": ["JSON"]
|
||||
}
|
||||
EOD
|
|
@ -1,7 +0,0 @@
|
|||
"""This is an example of a category-level library.
|
||||
|
||||
This library can be imported by child puzzles using `import categorylib`
|
||||
"""
|
||||
|
||||
def gettwo():
|
||||
return 2
|
|
@ -13,18 +13,26 @@ function prettify(key, val) {
|
|||
// devel_addin drops a bunch of development extensions into element e.
|
||||
// It will only modify stuff inside e.
|
||||
function devel_addin(e) {
|
||||
let h = document.createElement("h2")
|
||||
e.appendChild(h)
|
||||
h.textContent = "Development Options"
|
||||
let h = e.appendChild(document.createElement("h2"))
|
||||
h.textContent = "Developer Output"
|
||||
|
||||
let g = document.createElement("p")
|
||||
e.appendChild(g)
|
||||
g.innerText = "This section will not appear for participants."
|
||||
let log = window.puzzle.Debug.Log || []
|
||||
if (log.length > 0) {
|
||||
e.appendChild(document.createElement("h3")).textContent = "Log"
|
||||
let le = e.appendChild(document.createElement("ul"))
|
||||
for (entry of log) {
|
||||
le.appendChild(document.createElement("li")).textContent = entry
|
||||
}
|
||||
}
|
||||
|
||||
e.appendChild(document.createElement("h3")).textContent = "Puzzle object"
|
||||
|
||||
let hobj = JSON.stringify(window.puzzle, prettify, 2)
|
||||
let d = e.appendChild(document.createElement("pre"))
|
||||
d.classList.add("object")
|
||||
d.innerHTML = hobj
|
||||
|
||||
e.appendChild(document.createElement("p")).textContent = "This debugging information will not be available to participants."
|
||||
}
|
||||
|
||||
// Hash routine used in v3.4 and earlier
|
||||
|
|
Loading…
Reference in New Issue