# CLE

**CLE**, aka "Color Laser Esolang", is a 2D, multi-threaded esolang that simulates color "beams" bouncing around a board of mirrors and other objects. At the moment it is *not* Turing-complete due to the fact that there is no way to allocate more memory than provided on the board. It was designed by User:Not_applicable and the GitHub repository can be found at https://github.com/aouwt/CLE.

# Syntax

The "program" is made as a grid of "cells." Each cell has five (or six) attributes:

- Operation,
- Colors of beams going up, down, left, and right,
- (optionally) "State" color (currently this is only applicable to the tofu and temporary tofu operations; see below.)

"Beams" are continuously moving light segments. Left-going beams get shifted left every cycle, right-going beams get shifted right, etc..

## Colors

Each beam has a 24-bit RGB color which can be set using a "light source." These are operations that just emit continuous beams of light of a specific color. These colors are:

`R`

for red (#FF0000)`G`

for green (#00FF00)`B`

for blue (#0000FF)`C`

for cyan (#00FFFF)`M`

for magenta (#FF00FF)`Y`

for yellow (#FFFF00)`W`

for white (#FFFFFF)

In addition to these 8, if you use the *lowercase* version of each of the operations they will only emit one beam before being "destroyed"/removed from the board.

### Shades

To achieve more than just 8 colors, you can mix them together and use the "shade" (`#`

) operation to cut the red, green, and blue values in half. For example, if we have a red beam going to the shade, then the red (#FF0000) turns into a darker red (#7F0000) after passing through the shade:

R FF0000 -> # -> 7F0000

## Direction control

The beam can change directions using the following operations:

`/`

reflects a left-going beam up, right-going beam down, and vice-versa`\`

reflects a left-going beam down, right-going beam up, and vice-versa`^`

makes a copy of a beam and points that upwards (keeping the previous beam)`v`

makes a copy of a beam and points that downwards (keeping the previous beam)`<`

makes a copy of a beam and points that leftwards (keeping the previous beam)`>`

makes a copy of a beam and points that rightwards (keeping the previous beam)`|`

destroys any beam that is going left or right`-`

destroys any beam that is going up or down`[`

destroys any beam that is going left only`]`

destroys any beam that is going right only`_`

destroys any beam that is going up only`(`

reflects a left-going beam right, and ignores all other beams.`)`

reflects a right-going beam left, and ignores all other beams.`@`

reflects a left-going beam right, an upwards-going beam down, and vice-versa.

Examples:

R -> v -> | v

R -> \ | v

^ R -> | ^ G -> /

R -> ] G -> [ ->

R -> ( -> G -> <- )

R -> <- @ -> <- G

## Empty cell operations

If there is no operation on a cell, ie. there's no data there or there is a space there, then CLE performs a series of operations to manage beams.

### Beam combination

If there are two beams going opposite directions from each other, ie. one going left and one going right, or one going up and one going down, then CLE "mixes" the beams together by adding each of the channels of both beams together. This can be better summarized with the following formula:

Where and are the two beams, and is what will replace and .

Example:

R FF0000 -> FFFF00 <- FFFF00 G

### Filter

If two beams intersect at a 90° angle, then they are both filtered. The filter's algorithm is described below:

Where is the filter color, is the unfiltered beam's color, and is the filtered beam's color, which will replace .

This is run twice. One where the unfiltered vertical beam acts as the filter for the unfiltered horizontal beam, and one where the unfiltered horizontal beam acts as the filter for the unfiltered vertical beam.

Examples:

R FF0000 v G 00FF00 -> beam is destroyed

R FF0000 v Y FFFF00 -> -> FF0000

R FF0000 v W FFFFFF -> -> FF0000

## Tofu

The tofu operation, represented by `?`

, is a stand-in for any color. It's name is derived from the food, that is known to "absorb" flavors. At the moment, the tofu and the temporary tofu (below) are the only operations that have states.

When the tofu touches a beam, it sets the tofu's state to whatever that color is. If multiple beams hit it at the same time, they are merged (see Merging beams).

When the tofu's state is set, then it emits beams of that color in every direction, every cycle. If the tofu touches a beam that is not zero and not equal to its current state, then it sets it's state to that beam's color, and emits that instead.

### Temporary tofu

The temporary tofu, represented by `!`

, is exactly the same as the normal tofu except one cycle after the state is set, it is reverted back to normal.

## Desaturators

Desaturators, represented by `{`

and `}`

, "remove" the color from a beam. It does this by finding the average of the red, green, and blue channels and outputting that number in the red, green, and blue channels. This can be represented by the following equation:

Where is the input beam, and is the outputted beam.

# Sample programs

Note that `:`

is a placeholder for an *input*, and `;`

is a placeholder for an *output*. These are *not* valid operations in CLE.

## Cat

:;

## Truth machine

:v \ - - | C| | R| - - - |>v) \ / \ > ; -