Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
DolphyWind committed Apr 24, 2024
1 parent ce1fd9e commit 261150e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ cmake --build . --config="Release"
```

# How Electra works?
Electra has three main components: Currents, Generators and Components. Electra uses a list of 64 stacks of doubles for its memory management.
(This implementation has a command line argument that lets you change the stack count)
Electra has Currents, Generators and Components. Electra uses a list of 64 stacks of double-precision floating-point numbers for its memory.
(This implementation has a command line argument that allow you to change the stack count)

## **Comments, Including Other Files and Extending Electra With C++**
In Electra, you can comment out your code using question marks.
Expand Down Expand Up @@ -96,7 +96,7 @@ Currents are instruction pointers in Electra. They all have a direction, a posit
A direction can take one of these eight values: East, Northeast, North, Northwest, West, Southwest, South, Southeast.
On each iteration of Electra's main loop, each current moves one step forward.
When a current touches a component, if the component supports a current coming from that direction,
component does its work and uses that current's stack pointer when doing stack manipulations.
component does its work and uses that current's stack pointer when doing stack manipulations. And after it has done its work, it either kills or clones that current.
A current can either be generated by a generator, or be cloned by other components.

## **Generators**
Expand Down Expand Up @@ -159,13 +159,13 @@ The current with direction north will die in the next iteration.
>**Eight Directional Cable (\*, ✱):** Supports all directions. Can be used to change direction of a current or clone it.
>**East One Directional Cable (}):** Only lets current flowing to east direction.
>**East One Directional Cable (}):** Only lets a current flowing to east direction to pass.
>**West One Directional Cable ({):** Only lets current flowing to west direction.
>**West One Directional Cable ({):** Only lets a current flowing to west direction to pass.
>**North One Directional Cable (n):** Only lets current flowing to north direction.
>**North One Directional Cable (n):** Only lets a current flowing to north direction to pass.
>**South One Directional Cable (U):** Only lets current flowing to south direction.
>**South One Directional Cable (U):** Only lets a current flowing to south direction to pass.
>**Other Cables (╰, └, ╯, ┘, ╭, ┌, ┐, ╮, ├ ,┤ ,┬ ,┴):** These cables are not special they just have no name. They flow current based on how they look like.
Expand All @@ -175,7 +175,7 @@ Printers print the value on top of the stack. They can print a variable either a
#### **Printer Types**
>**Number Printer (N):** Supports east, northeast, northwest, west, southwest and southeast directions. Pops the top value off the stack and prints it as number. If the stack is empty it does nothing.
>**Character Printer (P):** Supports east, northeast, north, northwest, west, and southwest directions. Pops the top value off the stack and prints it as a character. If the stack is empty it does nothing.
>**Character Printer (P):** Supports east, northeast, north, northwest, west, and southwest directions. Pops the top value off the stack, converts that number to a UTF-8 code point and prints it. If the stack is empty it does nothing.
### **Arithmetical Units**
Arithmetical units let Electra do arithmetical calculations. If there are less than two values on the stack, they do nothing.
Expand All @@ -189,10 +189,10 @@ Arithmetical units let Electra do arithmetical calculations. If there are less t
>**Divider (Q):** Supports east, north, west, south and southeast directions. Pops two values off the stack and pushes `first/second` back.
>**Modder (%):** Supports northeast and southwest directions. Pops two values off the stack and pushes `std::fmod(first, second)` back.
>**Modder (%):** Supports northeast and southwest directions. Pops two values off the stack and pushes `first%second` back where `%` is the fmod operation.
### **Constant Adders (I, D)**
Constant adders adds a constant value to the value that is on top of the stack.
Constant adders add a constant value to the value that is on top of the stack.

#### **Constant Adder Types**
>**Increaser (I):** Supports north and south directions. Pops the top value off the stack and adds one to it. Then pushes the result back. It does nothing if the stack is empty.
Expand All @@ -211,7 +211,7 @@ Readers, read user's input.
#### **Reader Types**
>**Number Reader (@):** Supports east, northeast, north, northwest, west, southwest and south directions. Takes an input from user as a number and pushes it onto the stack.
>**Character Reader (&):** Supports north, south, east, southeast and southwest directions. Takes an input from user as character and converts it to a number. Then pushes it onto the stack.
>**Character Reader (&):** Supports north, south, east, southeast and southwest directions. Takes a single UTF-8 code point from user as input, then converts it to its corresponding number value and pushes it onto the stack.
### **Swapper ($)**
Swapper, swaps the top two values on the stack. It supports north, south, northeast and southwest directions. There must be at least two values on the stack for swapper to work.
Expand Down Expand Up @@ -240,7 +240,7 @@ Stack checkers, check whether the current stack is empty or not.
>**Inverted Stack Checker( ) ):** Supports north and south directions. Lets the current flow if the stack is not empty.
### **Stack Switchers**
Stack switchers move the current's stack pointer forwards or backwards. Some of them pops the top value and moves it to the next stack.
Stack switchers move the current's stack pointer forwards or backwards. Some of them pops the top value and moves it to the next stack. Stack switchers do wrap around if a stack pointer ends up exceeding the limits.
They stack pointer wraps around if you try to move it out of bounds.

>**Forward Stack Switcher (F):** Supports east, northeast, north, northwest, west and southwest directions. Moves current's stack pointer forward. Does not move top value to the next stack.
Expand Down Expand Up @@ -288,11 +288,11 @@ Then writes that string to the file. It pushes zero on failure.
File closer pops the value on top of the stack and closes that file handler. It pushes zero on failure.

### **Portals**
Every other character in Electra is considered a portal. Portals support all eight directions.
Every other character in Electra is a portal. Portals support all eight directions.
They are used for teleporting currents. When Electra reads the source code, it marks the first instance of a portal as the original portal.
When you flow a current to an unoriginal portal, the portal gets pushed to that current's visited portals stack, and the current gets teleported
to the original portal. Flowing a current to the original portal teleports the current back to the last visited portal and pops it off the stack.
If the stack is empty, flowing a current to the original portal does nothing. Think of them like functions in other programming languages.
If the stack is empty, flowing a current to the original portal does nothing. They are somewhat analogous to functions in other programming languages.

# Examples
Here are some example programs written in Electra:
Expand Down

0 comments on commit 261150e

Please sign in to comment.