gavmor / dunmanifestin Goto Github PK
View Code? Open in Web Editor NEWA verisimilitude generator.
A verisimilitude generator.
We should come up with a more general solution for phrase templating that will let us handle plurals and agreement.
I think the best way to handle this is for phrases to be objects. A phrase's to_s
method will interpolate some other to_s
ed phrases into a string, like:
class Phrase
def method_missing meth, *args, &block
instance_variable_get "@#{meth}" or
instance_variable_set "@#{meth}", meth.capitalize.constantize.new(*args)
end
def initialize with_string
@__string__ = with_string
end
def to_s
@__string__.to_s
end
end
class Denizen < Phrase
def to_s
"#{name}, a #{race} with a bunch of #{item.pluralize}"
end
end
A phrase can have other methods like pluralize
that may delegate to subphrases.
class Item < Phrase
def to_s
"#{adjective} #{baseItem} #{description}"
end
def pluralize
baseItem.pluralize
end
end
The default pluralization is just to to_s
yourself and add "s"
class Phrase
def pluralize
Phrase.new "#{self}s"
end
def article
if self.to_s =~ /^[aeiou]/i
Phrase.new "an #{self}"
else
Phrase.new "a #{self}"
end
end
end
Users should be able to generate output like this:
charcter:
name: Domi Erkthan
race: dwarf
profession: bodyguard
hometown: Raaldeep
str: 12
int: 10
wis: 11
con: 10
dex: 9
cha: 8
From input like this:
name:
- [humanNameGenerator]
- [dwarfNameGenerator]
- [elfNameGenerator]
race:
- human
- dwarf
- elf
profession:
- adventurer
- farmer
- miner
- aristocrat
- warrior
- bodyguard
hometown:
- Almodel
- Korvo
- Raaldeep
stats:
- str:
mean: 10
stddev: 2
min: 3
max: 18
- int:
mean: 10
stddev: 2
min: 3
max: 18
- wis:
mean: 10
stddev: 2
min: 3
max: 18
- con:
mean: 10
stddev: 2
min: 3
max: 18
- dex:
mean: 10
stddev: 2
min: 3
max: 18
- cha:
mean: 10
stddev: 2
min: 3
max: 18
dwarf -> mean str +1, mean con +1, stddev con -1
elf -> mean wis +1, mean int +1, mean dex +1, mean con -1
dwarf -> profession: miner +1, farmer -1
elf -> profession: aristocrat +1
dwarf -> hometown: Raaldeep +1
hometown: Raaldeep -> race: dwarf +1
elf -> hometown: Almodel +1
hometown: Almodel -> race: elf +1
human -> hometown: Korvo +1
hometown: Korvo -> race: human +1
The DSL needs some work... if the user wants to, for, example, change the name of a town, they also have to change all correlation rules that reference the name. There's also no obvious way to express two-way dependencies, e.g. dwarves are more likely to be miners, and miners are more likely to be dwarves. We basically need a GUI to manage this stuff... or a smarter DSL.
We're currently feeling a need to have phrases recur more often than they do by random chance. Recurrence would be useful because it would let us generate worlds with characters and places that reappear over and over, rather than being mentioned only once.
I propose the following two-part syntax to allow users to define the "population" of a palette.
|character*20
[name.capitalize] the [epithet.capitalize]
Used by itself, this syntax would have no effect on the generated output. But it would govern the probability with which characters
would recur, when referenced with the syntax below....
|gossip
[recur:character] likes [recur:character]!
Here, recur:
says explicitly that we want characters we've seen before to be reused. It's necessary to have this syntax because if we apply recurrence blindly, we'll end up generating identical characters when we want to have unique ones.
What *20
means in the character*20
definition is that when we generate a recur:character
, the probability of using someone we've seen before will be POP / (POP + 20)
, where POP
is the population of characters that currently exist. If we'd chosen a number larger than 20, the world would seem bigger (because characters would recur less often), and if we'd chosen a smaller number, the world would seem smaller.
@gavmor what do you think? Does this seem okay, at least in outline?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.