Conversational Variable Collection
What It Is
A system for maintaining a set of numeric variables using plain-language commandsStatus
Last Reviewed:
I did use this in a weird POC involving a text adventure game and Opti’s SaaS CMS. Otherwise, this was just a theory I wanted to prove.
Details
An CVC allows you to store and modify a list of labeled numbers, and ask questions of it to make decisions.
(Honestly, this probably isn’t going to make a lot of sense until you watch the video at this link. That’s what will put it into context for you.)
Visually, your variable collection might look something like this (this is just a visualization for your sake – it’s a data construct, and doesn’t actually have a visual representation).
AGE: 52
NUMBER_OF_CHILDREN: 3
PERCENT_CLUELESS: 100It’s quite simple: each variable consists of a label (a “name”) which has a numeric value.
Your variable collection starts off with nothing in it. Type this:
showNothing should display. Because, like we said, there’s nothing in it to start.
To create a value enter this command:
set AGE to 52AGE is the name of the variable. It can be any combination of letters, numbers, underscores, and dashes. If you enter anything else, it will be automatically corrected by the system.
I put it in uppercase here to highlight it, but the names aren’t case-sensitive: age and AGE are the same thing.
52 is the numeric value we want to set the variable to.
Now type this to display what’s in the collection:
showIt should display something like this:
AGE: 52When I have a birthday, you can increase my age by using this command:
increase AGE by 1You can say increase or decrease, and use any number.
(If the variable doesn’t exist, it will be automatically created at 0. So increase a non-existent variable by one will create it as 0, then increment it, leaving it at 1 by the end of the operation.)
Now your variable collection looks like this:
AGE: 53You can store more than one variable at a time by simply setting another variable just like you set the first one:
set NUMBER_OF_CHILDREN to 3Now your variable collection looks like this:
AGE: 53
NUMBER_OF_CHILDREN: 3You can “ask questions” of your variable collection. For example, any of these questions will return true or false:
is AGE more than 50
is NUMBER_OF_CHILDREN equal to 2
is AGE between 20 and 80(Again, case does not matter. I only capitalized the variable name so it sticks out a little more. It’s a pretty good convention to follow.)
If a variable doesn’t exist, every question will return false.
Instead of a question, you can ask for the same information declaratively, like this:
AGE is more than 50
NUMBER_OF_CHILDREN is equal to 2
AGE is between 20 and 80
In this sense, you're making a statement, and asking the collection to confirm it (`true`) or deny it (`false`).
To find out if a variable exists (or doesn't), you can ask this:
does AGE exist(Remember that a value of 0 is still a value, so if you have something with a value of 0, and you ask if it exists, it will return true.)
As noted above, you can also ask this declaratively:
AGE exists
AGE does not existCheat Sheet
Here are all the possible commands.
show
set [NAME] to [NUMBER]
remove [NAME]
what is [NAME]
increase [NAME] by [NUMBER]
decrease [NAME] by [NUMBER]
increment [NAME]
decrement [NAME]
does [NAME] exist
[NAME] exists
is [NAME] equal to [NUMBER]
[NAME] is equal to [NUMBER]
is [NAME] not equal to [NUMBER]
[NAME] is not equal to [NUMBER]
is [NAME] more than [NUMBER]
[NAME] is more than [NUMBER]
is [NAME] less than [NUMBER]
[NAME] is less than [NUMBER]
is [NAME] between [NUMBER] and [NUMBER]
[NAME] is between [NUMBER] and [NUMBER]
is [NAME] at least [NUMBER] and [NUMBER]
[NAME] is at least [NUMBER] and [NUMBER]
is [NAME] no more than [NUMBER] and [NUMBER]
[NAME] is no more than [NUMBER] and [NUMBER]