Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.2 #7

Open
wants to merge 113 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
21a873a
First part of new version guide
frantufro Apr 19, 2023
95fb3c8
Added explanation and examples related to reacting to state with cond…
frantufro Apr 19, 2023
16a95ec
palabritas parser first steps
loomstyla Apr 19, 2023
dede595
Some progress on the guide an examples.
frantufro Apr 20, 2023
6ee1e37
parser update + tests
loomstyla Apr 20, 2023
38b5231
Update palabritas.pest
loomstyla Apr 20, 2023
48fc740
named buckets must be snake_case
loomstyla Apr 21, 2023
2ff5df9
Identation update
loomstyla Apr 21, 2023
6e663d1
Parsing changes and first steps on reading logic
loomstyla May 10, 2023
e6c65d7
palabritas-common
loomstyla May 16, 2023
6433f38
palabritas parser update (WIP)
loomstyla May 18, 2023
7ab5d4b
tests and fixes
loomstyla May 22, 2023
69bee0c
compiler + parser update
loomstyla May 29, 2023
1408021
fmt + clippy
loomstyla May 29, 2023
285d22f
runtime + compiler (#8)
frantufro Jun 9, 2023
e21dd82
Added unique and tags to docs.
frantufro Jun 14, 2023
0f5c18b
Buckets support (#9)
loomstyla Jun 29, 2023
74d8b53
merge fixes
loomstyla Jun 29, 2023
ebcf906
divert fix
loomstyla Jun 29, 2023
f43aa63
Feedback cli + bug fixes
loomstyla Jun 29, 2023
953e5da
Modifier fix
loomstyla Jun 30, 2023
1068a64
set in cli + parser refactoring
loomstyla Jun 30, 2023
d9c5a0e
i18n refactor
loomstyla Jun 30, 2023
b56cbbe
varaible validations
loomstyla Jun 30, 2023
4751106
test fixes
loomstyla Jul 3, 2023
5d6251a
Section existance and invalid operators check
loomstyla Jul 3, 2023
5ced14c
Tests
loomstyla Jul 3, 2023
e7c1b81
Update parser.rs
loomstyla Jul 3, 2023
541263a
Update error.rs
loomstyla Jul 3, 2023
112ee3f
error messages refactor
loomstyla Jul 3, 2023
ff09c6d
runtime errors
loomstyla Jul 3, 2023
676f8b5
tests
loomstyla Jul 3, 2023
be77d9a
more parser errors
loomstyla Jul 4, 2023
8e52ef7
Bumped version of CLI
frantufro Jul 4, 2023
5dce035
set bool fix
loomstyla Jul 4, 2023
1bb6e6f
enum validates value
loomstyla Jul 4, 2023
7502609
compiler divert fixes
loomstyla Jul 4, 2023
8c28c42
Update cuentitos.toml
loomstyla Jul 4, 2023
98f67a0
Parser done, runtime wip
loomstyla Jul 4, 2023
7dd04b9
runtime
loomstyla Jul 5, 2023
61434a9
errors refactor
loomstyla Jul 5, 2023
48b4652
now prints sets in story
loomstyla Jul 5, 2023
edd4e97
? command
loomstyla Jul 5, 2023
3d685ed
subsections are now sections children
loomstyla Jul 6, 2023
8a064cd
runtime fix
loomstyla Jul 6, 2023
698c69d
make a choice error now prints text
loomstyla Jul 6, 2023
398e70d
update section fix
loomstyla Jul 6, 2023
92d89be
divert changes + some refactoring
loomstyla Jul 6, 2023
ecdc428
cli divert command now trims blank spaces
loomstyla Jul 6, 2023
c98df0a
boomerang divert
loomstyla Jul 6, 2023
fb277d7
boomerang divert test
loomstyla Jul 6, 2023
c85afef
print variables ordered
loomstyla Jul 7, 2023
2c80d49
cli changes
loomstyla Jul 7, 2023
78f64d3
errors refactoring + new errors
loomstyla Jul 7, 2023
963997e
Update main.rs
loomstyla Jul 7, 2023
aef940d
commands now support multiple empty lines inbetween
loomstyla Jul 7, 2023
e6e108e
wip
loomstyla Jul 10, 2023
7c54e19
fixes
loomstyla Jul 10, 2023
2a1b424
refactoring
loomstyla Jul 10, 2023
8778bcb
clippy
loomstyla Jul 10, 2023
96622dd
sections can have chances
loomstyla Jul 11, 2023
dbefaa1
cli fix
loomstyla Jul 11, 2023
44315f9
grep + cli refactor
loomstyla Jul 11, 2023
03268a5
empty lines fixes
loomstyla Jul 12, 2023
f6b94cb
Q command + boomerang command + commands test
loomstyla Jul 12, 2023
51cedcc
Errors print fix
loomstyla Jul 12, 2023
5db3642
subsections support indentation
loomstyla Jul 12, 2023
5f107f4
refactor wip
loomstyla Jul 12, 2023
19ae9f8
multiple levels of subsections
loomstyla Jul 12, 2023
b4719e7
fixes
loomstyla Jul 12, 2023
7618330
Update parser.rs
loomstyla Jul 13, 2023
1baafb2
Merge pull request #43 from hiddenpeopleclub/multiple-levels-of-subse…
loomstyla Jul 13, 2023
480d169
Merge pull request #42 from hiddenpeopleclub/cli-refactor-and-grep
loomstyla Jul 13, 2023
e031cc7
Merge pull request #41 from hiddenpeopleclub/runtime-output-refactor
loomstyla Jul 13, 2023
6a4b314
Merge pull request #40 from hiddenpeopleclub/duplicated-section-names…
loomstyla Jul 13, 2023
e9c28d0
Merge pull request #39 from hiddenpeopleclub/history
loomstyla Jul 13, 2023
890d971
Merge pull request #38 from hiddenpeopleclub/divert-changes
loomstyla Jul 13, 2023
fd6dc1b
Merge pull request #37 from hiddenpeopleclub/subsections-fix
loomstyla Jul 13, 2023
6e3358a
Merge pull request #33 from hiddenpeopleclub/full-state-print
loomstyla Jul 13, 2023
2d46796
Merge pull request #36 from hiddenpeopleclub/Feedback-cli-set
loomstyla Jul 13, 2023
972d813
Merge pull request #34 from hiddenpeopleclub/compiler-errors-prints-file
loomstyla Jul 13, 2023
2c8a823
Merge pull request #35 from hiddenpeopleclub/divert-rework
loomstyla Jul 13, 2023
f1777b7
Merge pull request #32 from hiddenpeopleclub/runtime-errors
loomstyla Jul 13, 2023
b46f7a1
Merge pull request #31 from hiddenpeopleclub/new-compiler-errors
loomstyla Jul 13, 2023
23af311
Merge pull request #30 from hiddenpeopleclub/i18n-refactor
loomstyla Jul 13, 2023
6d3057c
Merge pull request #29 from hiddenpeopleclub/set-cli
loomstyla Jul 13, 2023
a87bc89
Merge pull request #28 from hiddenpeopleclub/cli-feedback-and-bug-fixes
loomstyla Jul 13, 2023
cd21e0f
clippy
loomstyla Jul 13, 2023
1adaa91
Fixed divert bug
loomstyla Jul 13, 2023
f12e051
fixed output on choice pick + tests
loomstyla Jul 13, 2023
0efcf29
another divert fix
loomstyla Jul 13, 2023
315fa3e
Merge pull request #44 from hiddenpeopleclub/bug-fixes
loomstyla Jul 14, 2023
5abf0da
divert fixes and END changes
loomstyla Jul 19, 2023
db86ad1
Rustfmt fixes
frantufro Jul 21, 2023
95c2b27
Update palabritas.md
loomstyla Jul 21, 2023
685ca84
Unnamed buckets in sections
loomstyla Jul 21, 2023
4686a2c
Create cli.md
loomstyla Jul 21, 2023
d048c58
Update cli.md
loomstyla Jul 21, 2023
dcec7ca
documentation update
loomstyla Jul 24, 2023
06fd4ed
Update cli.md
loomstyla Jul 24, 2023
aa28c3c
Update cuentitos.toml
loomstyla Jul 24, 2023
834170f
Merge pull request #45 from hiddenpeopleclub/bug-fixes
loomstyla Jul 24, 2023
ede5667
new_compiler_errors
loomstyla Jul 26, 2023
9004e52
Crash fix
loomstyla Sep 6, 2023
0ed80be
buckets fix
loomstyla Oct 2, 2023
6cbd458
skip implementation
loomstyla Oct 2, 2023
715b40f
story_progress_style configuration
loomstyla Oct 5, 2023
007399b
Update cuentitos.toml
loomstyla Oct 5, 2023
d709e10
Merge pull request #46 from hiddenpeopleclub/skip-command
loomstyla Oct 5, 2023
9046002
skip on end fix
loomstyla Oct 6, 2023
b19889c
Update cuentitos.toml
loomstyla Oct 17, 2023
119035d
Revert "Update cuentitos.toml"
loomstyla Oct 17, 2023
83bc279
Update i18n.rs
loomstyla Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 243 additions & 0 deletions definitions/palabritas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
# Palabritas: cuentito's language

`cuentitos` is a narrative engine that includes its own language for writers to create dynamic storytelling: `palabritas`.

In this document I will introduce you to `palabritas`.

## Basics

You can start by writing small pieces of text. Each newline will prompt the user to continue.

```cuentitos
You've just arrived in the bustling city, full of excitement and anticipation for your new job.
The skyline reaches for the clouds, and the sounds of traffic and people surround you.
As you take your first steps in this urban jungle, you feel a mix of emotions, hoping to find your place in this new environment.
```

Now, you can add options after an event by indenting with two spaces and starting the line for each option with an asterisk `*`

```cuentitos
[...]
As you take your first steps in this urban jungle, you feel a mix of emotions, hoping to find your place in this new environment.
* I take a walk through a nearby park to relax and acclimate to the city.
* I visit a popular street market to experience the city's unique flavors and energy.
```

You can now start a new narrative path by indenting with 2 spaces and writing the next text bits.

```cuentitos
[...]
* I take a walk through a nearby park to relax and acclimate to the city.
As you stroll through the nearby park, the soothing sounds of rustling leaves and chirping birds help calm your senses.
You find a quiet bench to sit on, taking a moment to breathe deeply and gather your thoughts.
This serene oasis gives you the confidence to face the challenges ahead as you acclimate to your new life in the bustling city.
```

## Probabilistic One-Off's

An interesting feature of cuentitos is that you can use probability to render different things in the story. For example, in our case, we can use probability to have someone sitting on the bench or not.

```cuentitos
[...]
You find a quiet bench to sit on, taking a moment to breathe deeply and gather your thoughts.
(50%) A solitary figure sits on the bench, engrossed in a book, seemingly unfazed by the surrounding city noise.
This serene oasis gives you the confidence to face the challenges ahead as you acclimate to your new life in the bustling city.
[...]
```

This will make it so that half of the time the solitary figure is there sitting there, and half of the time, they're not. Whenever you have a one off text with probability, you can directly write said probability as a percentage. So in this case there is a `50%` chance that this text will be rendered. We call this the `one-off percentage notation`.

Another way is to use the `one-off probability notation`, that uses a range from 0 to 1 to determine how probable that event is. In this case, we'd have to use `0.5`.

```cuentitos
[...]
You find a quiet bench to sit on, taking a moment to breathe deeply and gather your thoughts.
(0.5) A solitary figure sits on the bench, engrossed in a book, seemingly unfazed by the surrounding city noise.
This serene oasis gives you the confidence to face the challenges ahead as you acclimate to your new life in the bustling city.
[...]
```


In practice, both notations are similar and it's mostly up to you which one to use, the only difference is the precission: percentage notation only supports integers, while probability notation supports real numbers (floats). You can't do `55.5%`, but you can do `0.555`.

You could add options on probabilistic branches, but let's keep going for now.

## Probabilistic Buckets

Another interesting feature is the ability to create `probabilistic buckets`.

A bucket is a set of probable paths that the engine will pick one every time is asked to render that bucket. Let's do a probabilistic bucket with the second option.

```cuentitos
* I visit a popular street market to experience the city's unique flavors and energy.
(50%) At the bustling street market, you discover a food stand offering mouthwatering delicacies.
As you sample the delicious fare, you strike up a conversation with the enthusiastic vendor.
It's a welcome distraction from the noise around you.
(20%) As you try to navigate the crowded market, you're drawn to the entrancing melody of a street musician.
The captivating sound creates a soothing bubble, momentarily transporting you away from the city's noise.
You take a moment to appreciate the beauty of the music, feeling a connection to the artist and the vibrant energy they bring to the urban landscape.
(30%) Wandering the market, you stumble upon a hidden alley adorned with vibrant street art.
Each colorful mural tells a different story, capturing your imagination and sparking your creativity.
This unexpected oasis of visual tranquility provides a respite from the chaos of the city, inspiring you to explore more of the urban canvas and the stories it holds.
```

In this example, we added an indentation from the option and ten added 3 narrative paths with probabilities expressed in percentage notation. Every time you indent and add probabilities you're effectively creating a bucket.

Notice that the sum of the probabilities is `100%`. This is a requirement if using `percentage notation` in a bucket, the compiler will fail if you have a different sum. The same will happen if you use `probability notation`, the sum has to be `1`, otherwise the compiler will throw an error.

There is another useful notation available on buckets that is called the `frequency notation`, where you can set the frequency of each event. The probability will be calculated as the frequency over the sum of the frequencies of all the events in the bucket. There is no requirement to keep a consistent sum of frequencies, the probability of all events will adjust as you add more or change the existing ones.

```cuentitos
* I visit a popular street market to experience the city's unique flavors and energy.
(50) At the bustling street market, you discover a food stand offering mouthwatering delicacies.
As you sample the delicious fare, you strike up a conversation with the enthusiastic vendor.
It's a welcome distraction from the noise around you.
(2) As you try to navigate the crowded market, you're drawn to the entrancing melody of a street musician.
The captivating sound creates a soothing bubble, momentarily transporting you away from the city's noise.
You take a moment to appreciate the beauty of the music, feeling a connection to the artist and the vibrant energy they bring to the urban landscape.
(500) Wandering the market, you stumble upon a hidden alley adorned with vibrant street art.
Each colorful mural tells a different story, capturing your imagination and sparking your creativity.
This unexpected oasis of visual tranquility provides a respite from the chaos of the city, inspiring you to explore more of the urban canvas and the stories it holds.

```
Given what we just said, which event is more probable of the three?

The hidden alley! Let's see why:

The sum of frequencies is `50 + 2 + 500 = 552`, then the probability of the deli stand is `50 / 552 ~= 0.09`, the probability of the musician is `2 / 552 ~= 0.003` and the probability of the hidden alley is `500 / 552 ~= 0.9`. So 9 out of 10 times we'll get the alley.

### Probability of Options

Probability can be applied to pretty much everything in `cuentitos`, including options. Let's explore that.

You can add a chance for an option to show up by adding the probability after the asterisk:

```cuentitos
[...]
You take a moment to appreciate the beauty of the music, feeling a connection to the artist and the vibrant energy they bring to the urban landscape.
* (50%) I leave two dollars to the artist.
The musician smiles and nods thanking you.
* I nod when the musician looks my way, to show I really enjoy the music.
[...]
```

If a choice doesn't have probability set, the probability of it showing up is 100%.

In this case there is a 50% chance the user will see the option to leave two dollars to the musician. So half of the times he'll support the artist economically, and half just nod.

#### Options bucket

If all the options in an indentation level are probabilistic, then a bucket is created.

This means that only one of those options will show up, respecting the probability rules.

```cuentitos
(500) Wandering the market, you stumble upon a hidden alley adorned with vibrant street art.
Each colorful mural tells a different story, capturing your imagination and sparking your creativity.
* (50%) I grab my phone and take pictures of the murals.
* (50%) I keep walking, even if the murals look good, the darkness of the alley is unsettling.
```

In this case, only one of the options will show up, each one with a 50% chance.

## Reacting to State

Up until this point, we've not used the game state to setup conditions. So let's do that now. We'll start writing from the root indentation level again. This texts will show up when the previous section is navigated until there is no more text to show. It will automatically backtrack to the root if no texts display in any indentation level.

```cuentitos
Feeling mentally and physically exhausted from the day's adventures, you decide it's time to head back to your hotel.
As you enter the peaceful sanctuary of your room, you take a deep breath, relieved to have a quiet space where you can recharge and prepare for the challenges ahead.

The sun shines bright through the window.
req time_of_day !night
The moonlight gives the room a peaceful tone.
req time_of_day night
```

In this case, we're putting conditions to these two lines of text. They will only show up if the `time_of_day` variable value satisfies the conditions. The first one will show if time of day is not `night`, the second one, will show when time of day is `night`.

Check the `Configuration` section to learn about variables.

In this case, the requirements are mutually exclusive, only one will show at a time. But that's not a requirement. You could have multiple lines with different requirements and have them show one after the other if the conditions are satisfied.

```cuentitos
The sun shines bright through the window.
req time_of_day !night
The moonlight gives the room a peaceful tone.
req time_of_day night
You start to think about all the stuff you need to do tomorrow.
req time_of_day_night
That makes you feel overwhelmed.
req time_of_day_night
req energy <10
```

These two new lines will only show at night, after `The moonlight gives...`. The last one only if the player is low on energy.

You can also add requirements to options.

```cuentitos
[...]
That makes you feel overwhelmed.
req time_of_day_night
req energy <10
* I make some tea
req item tea
A good cup of tea is always good to regulate after the sensory overload of the city.
* I go to bed
Feeling depleted of spoons, you go right back to bed.
* I call my parents
req energy >10
```

In this case, to make tea you need an `item` with identifier `tea` in the inventory.
You also need more than `10` points of energy to call your parents.

### Conditional probability changes

You can change the probability of a text of option if a given condition is met by using the `freq` command.

```cuentitos
[...]
* I call my parents
req energy >10
(30) The phone rings twice, and dad picks up.
req energy>20
(10) The phone rings twice, and mom picks up.
req energy>20
freq time_of_day night 100
(40) The phone rings ten times, nobody is at home.
```

Let's analyse this situation:

* If the player has `energy` between `11` and `20`, nobody picks up, because the condition of `energy>20` is not met, so mom and dad will not pickup.
* If `energy` is `21` or more and `time_of_day` is not `night`, there are more chances that dad will pick up than mom (frequency `30` for dad, vs `10` for mom).
* If `energy` is `21` or more and `time_of_day` is `night`, it is very likely that mom will pick up, because the frequency is `110` (vs `30` for dad, and `40` for no one).

In this way we can create very complex condition sets and frequency alterations that we can use to modify the behavior of our story. This is incredibly useful to create games that feel alive, in this example, the mother of the player works all day outside the house, while the dad takes care of the home during the day.

Conditions and probability modifications can be used to express rules of the world and its randomness to successfully represent a world that is more complex, alive and random than simple rule-based ones.

The `freq` command can take negative numbers too, to reduce the frequency instead of increasing it.

```cuentitos
(10) The phone rings twice, and mom picks up.
req energy>20
freq time_of_day !night -100
```

If the frequency ends up being 0 or less, the affected element will not be considered. In this case, mom would not pickup the phone at all unless it's night time.

## Changing State

## String interpolation

## Configuration
### Variables
#### Bool
#### Integer
#### Float
#### Enum
## Reputations
## Items
48 changes: 48 additions & 0 deletions examples/story-example.cuentitos
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
You've just arrived in the bustling city, full of excitement and anticipation for your new job.
The skyline reaches for the clouds, and the sounds of traffic and people surround you.
As you take your first steps in this urban jungle, you feel a mix of emotions, hoping to find your place in this new environment.
* I take a walk through a nearby park to relax and acclimate to the city.
As you stroll through the nearby park, the soothing sounds of rustling leaves and chirping birds help calm your senses.
You find a quiet bench to sit on, taking a moment to breathe deeply and gather your thoughts.
(50/100) A solitary figure sits on the bench, engrossed in a book, seemingly unfazed by the surrounding city noise.
This serene oasis gives you the confidence to face the challenges ahead as you acclimate to your new life in the bustling city.
* I visit a popular street market to experience the city's unique flavors and energy.
(50) At the bustling street market, you discover a food stand offering mouthwatering delicacies.
As you sample the delicious fare, you strike up a conversation with the enthusiastic vendor.
It's a welcome distraction from the noise around you.
(2) As you try to navigate the crowded market, you're drawn to the entrancing melody of a street musician.
The captivating sound creates a soothing bubble, momentarily transporting you away from the city's noise.
You take a moment to appreciate the beauty of the music, feeling a connection to the artist and the vibrant energy they bring to the urban landscape.
* (50%) I leave two dollars to the artist.
The musician smiles and nods thanking you.
* I nod when the musician looks my way, to show I really enjoy the music.
(500) Wandering the market, you stumble upon a hidden alley adorned with vibrant street art.
Each colorful mural tells a different story, capturing your imagination and sparking your creativity.
* (50%) I grab my phone and take pictures of the murals.
* (50%) I keep walking, even if the murals look good, the darkness of the alley is unsettling.
This unexpected oasis of visual tranquility provides a respite from the chaos of the city, inspiring you to explore more of the urban canvas and the stories it holds.

Feeling mentally and physically exhausted from the day's adventures, you decide it's time to head back to your hotel.
As you enter the peaceful sanctuary of your room, you take a deep breath, relieved to have a quiet space where you can recharge and prepare for the challenges ahead.
The sun shines bright through the window.
req time_of_day !night
The moonlight gives the room a peaceful tone.
req time_of_day night
You start to think about all the stuff you need to do tomorrow.
req time_of_day_night
That makes you feel overwhelmed.
req time_of_day_night
req energy <10
* I make some tea
req item tea
A good cup of tea is always good to regulate after the sensory overload of the city.
* I go to bed
Feeling depleted of spoons, you go right back to bed.
* I call my parents
req energy >10
(30) The phone rings twice, and dad picks up.
req energy>20
(10) The phone rings twice, and mom picks up.
req energy>20
freq time_of_day morning 100
(40) The phone rings ten times, nobody is at home.