Skip to content

Instantly share code, notes, and snippets.

@bbqbaron
bbqbaron / Test.elm
Last active August 29, 2015 14:18
Elm History?
module Test where
import Html(..)
import Html.Attributes(..)
import Html.Events(..)
import List(..)
import Maybe(..)
import Signal(..)
port initialLocation : String
@bbqbaron
bbqbaron / util.re
Created February 10, 2018 16:03
Dump of some random Reason utility functions I found myself wanting
/***
* the util file I banged together while working on a project.
* as a result, it's organic, not systematic.
* some are so trivial as not to really need defining.
* i think i'm used to Clojure where a lack of currying
* means that sometimes aliasing trivial partial functions
* is helpful.
*/
/***
; https://gist.github.com/munificent/b1bcd969063da3e6c298be070a22b604
(ns dgn)
(def H 40)
(def W 80)
(def TV " ")
(def TF ".")
(def TW "#")
(def TC "!")
(def TOD "\\")
(defn pick [doors]
(assoc-in doors
[(rand-int 3) :picked] true))
(defn monty [doors]
(let [first-goat (first (filter
(comp (every-pred
(comp #(= :goat %) :contents)
(comp not :picked))
#(nth doors %))
; this isn't to throw shade at the dev; i just felt java had a lot of incidental complexity and wanted to understand what the code does
(defn fragmentize-chunk [chunk]
(set (map #(take % chunk) [1 2 3])))
(defn fragmentize-word [word]
(->> (range (count word))
(map #(drop % word))
(mapcat fragmentize-chunk)
(map clojure.string/join)))
Possible optional rules to make touch spells interesting. These are not written to keep combat balanced, as I don't enjoy powergaming and basically reject the core activity of D&D :|
* They can be kept coherent and passed between people before being deployed. Doing so taxes the caster. HP? Some other cost?
* This implies that they could perhaps be imbued in objects, temporarily, as traps
* They are somehow intimate; you're messing about in someone's aura space. You can get a bonus to the attack if you tell the target a memory of yours, which passes to them with the spell.
* As an unpleasant corollary, some types of curse are transmissible by touch spells
* Certain spell types are conducted by certain materials. Necromancy=bones? Etc etc. This could affect their deployment in certain environments.
* Or worse they're insulated by certain materials
* You can use touch un-spells to steal enchantments from other people
;; i freely admit that i don't holistically grok this; i just transcribed the algorithm into something slightly more clojurish
"
Algorithm: Vose's Alias Method
Initialization:
Create arrays Alias and Prob, each of size n.
Create two worklists, Small and Large.
Multiply each probability by n.