~johanvandegriff/games.johanv.net

0d07fcc471b788a38641c5094921989852a8230a — Johan Vandegriff 1 year, 7 months ago b98c836
added "Dr. Hornswiggle's Trancendental Ideations Generator"
M games.py => games.py +16 -0
@@ 6,6 6,7 @@ from flask import Flask, request, render_template, url_for
import os, re, sys

import CARL, boggle, boggle_old
import hornswiggle
from nav import nav
import profanity_test



@@ 150,6 151,21 @@ def carl_page():
    )
#END CARL

#START HORNSWIGGLE
@app.route("/hornswiggle_api", methods=["GET", "POST"])
def hornswiggle_api():
    return hornswiggle.generate()

@app.route("/hornswiggle", methods=["GET", "POST"])
def hornswiggle_page():
    return render_template(
        "hornswiggle.html",
        nav=nav,
        active="Dr. H",
        item=hornswiggle.generate()
    )
#END HORNSWIGGLE

if __name__ == "__main__":
    # app.run()
    app.run(host= '0.0.0.0') # for local testing

A hornswiggle.py => hornswiggle.py +216 -0
@@ 0,0 1,216 @@
#!/usr/bin/python
import random

"""
Dr. Hornswiggle's Trancendental Ideation Generator

person's X
person's X with X
person's X without X
person's X and X
X = noun
X = adj noun
X = adv adj noun
X = adv adj (and) adj noun
X = adv adj (and) adj descriptor
X = adv adj (and) adj noun descriptor
"""

raw = {
  "possessives":"""
Dr. Hornswiggle's
Dr. Hornswoggle's
Prof. Boomquaggle's
Sir Birdzobble's
Madam Drumdrooble's
Mr. Lensfoggle's
Mrs. Cangrooble's
Ms. Rocktobble's
Mx. Ferntibble's
""",
  "adverbs":"""
Aesthetically
Dimensionally
Intergalactically
Organically
Entirely
Absolutely
Magnificently
Aesthetically
Superficially
Seldom
Periodically
Pragmatically
Fully
Very
Extremely
Extraordinarily
""",
  "prefixes":"""
Anti-
Non-
Pre-
Post-
Semi-
Super-
""",
  "adjectives":"""
Fantabulous
Quintessential
Hypothetical
Pre-Owned
Alchemical
Null-Terminated
Skull-Shaped
Automagical
Forgettable
Non-Fungible
Inflammible
Inedible
5-Wheeled
Vacuum-Packed
Benign
Terrible
Supernatural
Quizzical
Cantankerous
Spontaneous
Maritime
Extraordinary
Royal
Alphabetical
Dapper
Dubious
Devious
Non-Binary
Grayscale
Momentous
Trancendental
Additional
Namby-Pamby
Solemn
""",
  "nouns":"""
Calvacade
Cavalcade
Wibblewobble
Album
Albatross
Bean
Artifact
Pantaloon
Composure
Zeitgeist
Object of Interest
Meal Concept
Tincture
Acid
Abomination
Submarine
Telegraph
Vessel
Potion
Butter
Consciousness
Bounty Hunter
Swag
Cumquat
Ringtone
Ideation
Superposition
Machination
Cacophony
Brouhaha
Flibbertigibbet
Malarkey
Codswallop
Rigmarole
Shenanigan
Technobabble
Pandemonium
Tardigrade
Phantasm
""",
  "descriptors":"""
Box
Generator
Sweeper
Transmogrifier
Grafter
Defragmenter
Governor
Facility
Game
Sandwich
Simulator
Parade
Festival
Contraption
Prototype
""",
  "conjunctions":"""
, and
, Containing
, Lacking One
, Sans One
, Fused with
, with Part of One
, with Optional
, with Bonus
""",
  "rare postfix":"""
& Knuckles
, Featuring Dante from the Devil May Cry Series
"""
}

lists = {}
for category in raw:
  lists[category] = [item for item in raw[category].split("\n") if item != ""]

def automagicalSuperposition(chance):
  return random.random() > 1-chance/100

class TrancendentalIdeationGenerator():
  def __init__(self):
    self.words = []
  def add(self, category):
    self.words.append(random.choice(lists[category]))
  def getStr(self):
    return " ".join(self.words).replace("- ", "-").replace(" ,", ",")

  def addDimensionallyHypotheticalObjectOfInterest(self):
    if automagicalSuperposition(95):
      if automagicalSuperposition(40):
        self.add("adverbs")
      if automagicalSuperposition(25):
        self.add("adjectives")
        if automagicalSuperposition(80):
          self.words.append("and")
      if automagicalSuperposition(15):
        self.add("prefixes")
      self.add("adjectives")
    if automagicalSuperposition(80):
      self.add("nouns")
      if automagicalSuperposition(20):
        self.add("descriptors")
        if automagicalSuperposition(25):
          self.add("descriptors")
    else:
      self.add("descriptors")
    if automagicalSuperposition(15):
      self.add("conjunctions")
      self.addDimensionallyHypotheticalObjectOfInterest()

  def generate(self):
    self.add("possessives")
    self.addDimensionallyHypotheticalObjectOfInterest()
    if automagicalSuperposition(2):
      self.add("rare postfix")
      if automagicalSuperposition(5):
        self.add("rare postfix")

def generate():
  words = TrancendentalIdeationGenerator()
  words.generate()
  return words.getStr()

M nav.py => nav.py +2 -1
@@ 6,5 6,6 @@ nav = [
    ["maze", "/maze"],
    ["whack", "/whack.pl"],
    ["math", "/math"],
    ["chem", "/chem"]
    ["chem", "/chem"],
    ["Dr. H", "/hornswiggle"]
]

M requirements.txt => requirements.txt +2 -1
@@ 17,4 17,5 @@ scipy==1.6.0
numpy~=1.19.2
#tensorflow==2.4.1
#https://git.sr.ht/~johanvandegriff/tensorflow-custom-build/blob/master/tensorflow-2.4.1-cp36-cp36m-linux_x86_64.whl
https://git.sr.ht/~johanvandegriff/tensorflow-custom-build/blob/master/tensorflow-2.4.1-cp38-cp38-linux_x86_64.whl
#https://git.sr.ht/~johanvandegriff/tensorflow-custom-build/blob/master/tensorflow-2.4.1-cp38-cp38-linux_x86_64.whl
tensorflow==2.6.0
\ No newline at end of file

M static/boggle.css => static/boggle.css +0 -40
@@ 73,46 73,6 @@ p.scale {
}


.greenButton, .purpleButton, .redButton, .blueButton, .grayButton {
  font-size: 1em;
  height: 2em;
  /* background: #10ee10; */
  /* text-align: center; */
  /* margin: 0 auto; */
  border-radius: 0.3em;
  border: 2px solid black;
  /* display: inline-block; */
}

.bigButton {
  font-size: 1.2em;
  margin: 3px;
}

input[type="submit"].greenButton{
  background: #10ee10;
}

input[type="submit"].purpleButton {
  background: #631fa3;
  color: white;
}

input[type="submit"].redButton {
  background: #f00;
  color: white;
}

input[type="submit"].blueButton {
  background: #9af;
  /* color: white; */
}

input[type="submit"].grayButton {
  background: #ccc;
}


.underlineText {
  font-size: 0.8em;
  margin: 1em auto;

M static/style.css => static/style.css +39 -0
@@ 195,6 195,45 @@ footer {
    font-family: 'Monospace', sans-serif;
}

.greenButton, .purpleButton, .redButton, .blueButton, .grayButton {
  font-size: 1em;
  height: 2em;
  /* background: #10ee10; */
  /* text-align: center; */
  /* margin: 0 auto; */
  border-radius: 0.3em;
  border: 2px solid black;
  /* display: inline-block; */
}

.bigButton {
  font-size: 1.2em;
  margin: 3px;
}

input[type="submit"].greenButton{
  background: #10ee10;
}

input[type="submit"].purpleButton {
  background: #631fa3;
  color: white;
}

input[type="submit"].redButton {
  background: #f00;
  color: white;
}

input[type="submit"].blueButton {
  background: #9af;
  /* color: white; */
}

input[type="submit"].grayButton {
  background: #ccc;
}

#navToggle {
  position: absolute;
  left: 0;

A templates/hornswiggle.html => templates/hornswiggle.html +26 -0
@@ 0,0 1,26 @@
{% include 'header.html' %}

<script>
function newItem() {
    var list = document.getElementById("list");

    let xhr = new XMLHttpRequest();
    xhr.open('get', "/hornswiggle_api");
    xhr.send();

    xhr.onload = function () {
        var newItem = document.createElement("li");
        newItem.textContent = xhr.response;
        list.appendChild(newItem);
    };
}
</script>

<h1>Dr. Hornswiggle's Trancendental Ideations Generator</h1>
<input type="submit" value="Additional Ideation" class="purpleButton" onclick="newItem()">

<ul id="list">
    <li>{{ item }}</li>
</ul>

{% include 'footer.html' %}

M templates/index.html => templates/index.html +1 -0
@@ 8,6 8,7 @@
<li><a href="/whack.pl">Whack-A-Mole</a> - another perl game</li>
<li><a href="/math">Math</a> - a math worksheet (also perl)</li>
<li><a href="/chem">Stoichiometry</a> - a chemical equation solver (written in Java)</li>
<li><a href="/hornswiggle">Dr. Hornswiggle's Trancendental Ideations Generator</a> - hmmm... You'd better just see for yourself.</li>
</ul>

<br/>