Book of Truth

From Esolang
Jump to navigation Jump to search

Book of Truth features that you use only a book & marks to compute. The esolang acts like game books. There're instructions on each page. The user flips between pages, sets, or removes bookmarks according to instructions of the current page, and recurse.

Though I would appreciate if someone could make a simulator, Book of Truth is meant to be run by a human, not a machine! The page count & bookmark amount should be limited to guarantee that the book can be printed and marks don't get a mess.

Pages

Contents in pages serve as ROM. Each page contains 3 parts: section, tokens and lines.

Section

Consecutive pages' edges are colored, divided into different sections. This information is referred when the program needs to navigate the bookmark in particular section.

Tokens

Each page has multiple different tokens. These information are referred as conditions.

Both the design of section and tokens are meant to downplay page numbers' role, and act as a substitution. Section takes the role of <> and tokens take the role of ==.

Bookmarks

All above do nothing to runtime data storage, and the only means of data storing is the current page number we're at. Thus bookmarks are introduced.

Bookmarks can be set or removed at any pages. Page doesn't keep multiple marks. The operation trying to set bookmark when the page already has one, or remove bookmark when the page doesn't have one, failed without triggering error.

The total amount of bookmarks are limited due to your Book of Truth. If you run out of them, error is thrown.

Lines

Lines are instructions. The user do the instructions in order, till there's a goto or halt

Instructions

You write instructions as lines. The phrases are not strict, you may use any other languages for instructions, as long as your human can understand them.

Instruction Description
goto <page_number> flip to the page & do the page's instructions
goto mark in <section_color> search for the mark in the section and flip to it.

If there's multiple valid marks, choose the one you like.

If there's no valid mark, scream and throw the book away.

If you can't find the color, then pretend you're not color-blind and go with your gut.

set mark [<x> page[s] earlier / later] set a mark at current page ("set mark" only) / x page(s) earlier / later.

If there's one already exists, then do nothing.

If you run out of mark, smash the book.

remove mark [<x> page[s] earlier / later] remove the mark at current page ("set mark" only) / x page(s) earlier / later.

If there's no mark, pretend that you remove an invisible mark which immediately dissolves into the air.

check if page <number> has [no] mark. If the page has a mark, do the next instruction.

If there're consecutive "check if" instruction, only when they're all satisfied can the following instruction be done.

check if there's [no] mark in <section_color> If you can't find the color, just randomly throw an answer
check if mark in <section_color> has [no] <token> If there're multiple valid marks, you are stuck into decidophobia and seal the book till the next day.

There's no circumstance where no valid marks exist. Maybe you just forgot about the invisible mark located in whatever you like.

If you can't find the color, go check if the printer is color-blind.

Examples

Addition

The program involves 25 pages and 3 bookmarks

This program starts at page 1. Red and Blue serve as 0 - 3 registers for inputs, mark to save data. Yellow is a 0 - 6 register for output. Black is a temp accumulator. Page 2 loops for halt.

P1

goto mark in Red

P2

goto 2

P3

You know what this page is useless.

P4

To comment or not to comment, that is a question.

P5 Black

remove mark
check if mark in Blue has Cross
set mark 16 pages later
check if mark in Blue has Cross
goto 2
set mark 1 page later
goto mark in Blue

P6-12 ibid.

P13 Red

goto 5

P14 Red

goto 6

P15 Red

goto 7

P16 Red

goto 8

P17 Blue Cross

goto mark in Black

P18 Blue

remove mark
set mark 1 page earlier
goto mark in Black

P19-20 ibid.

P21 Yellow


P22-27 ibid,