Cheß

From Esolang
Jump to navigation Jump to search

Cheß, pronounced "Cheb" for the purposes of both making a 'quirky' language name and also pissing off Germans, is technically a three dimensional language given that it is typed in one dimension, and then interpreted into two. Much like the language idea Chess or the completed language InfChessPro, Cheß is a chess based programming language. Much to the dismay of every reader, I will now explain how Cheß is more similar to Brainfuck than these other chess based examples.

Sorry, but I haven't made an implementation yet.

Language overview

Cheß has four core fundementals: The code, the board, the pieces, and the cursor.

The code

Unlike similar languages, Cheß is not written as the state of the board but is instead interpreted into it at runtime and that board state is then executed. Cheß is written instead as game instructions such as "A2 to A4".

There are only two instructions in Cheß, "MOVE" and "UNTIL", with the exceptions being "END" to finalize an UNTIL codeblock, and "//" to begin either an in-line or single line comment. Any move which is not legal will throw an error. Additionally you play as both white and black, taking turns between the two after every MOVE. If it is whites turn you may only MOVE a white piece, if it is blacks turn you may only MOVE a black piece. Standard to the rules of chess you may not pass a turn, and are required to perform a move every time.

A2 to A4 // Location to location, only legal moves in the standard interval of white to black, beginning with white.
UNTIL 32 // A number OR location, the value of said location as input. The loop will operate until the value the cursor is on matches the given value (tested upon the completion of each white move)
 // Perform moves
END

The meager 'while' users cringe at the sight of a righteous and proper loop. Until is a superior counter-part in every imaginable way.

Understanding how to write Cheß code is the easy part, the difficult part is understanding the board and the cursor.

The board

Every Cheß program will create a standard 8x8 chess board grid and will place every piece in it's beginning position. Each piece is a command and standard to the rules of chess each grid location may hold one piece. Instructions which attack pieces are allowed and the code may even play like a normal game; However, a checkmate is not the goal of your program and will terminate the execution.

While acting as locations for the pieces to move to, each grid slot also behaves as a location in memory, they may each hold a single 8-bit integer value which may increment and decrement. Going above 255 will wrap the location to 0, and going below 0 will wrap the location to 255.

Each piece holds a command which pertains to either writing or reading the values in these locations, and will do so to the location it resides once the cursor lands on said location.

The cursor

Unlike many other languages which host a cursor and memory scheme the cursor in Cheß is not controlled by the programmer, it will act on it's own dictated by the rules of each piece it lands on. The cursor will move once in the direction it is dictated after every completed black move, and will only consider the direction dictated by the piece which was initially underneath after the previous move.

The cursor will remember it's previous direction, and should it not land on a piece at all it will continue in the direction it was previously instructed until landing on a new piece. If the cursor leaves the board it will wrap around to the opposite location it left.

The cursor will move at exactly half the speed which the programmer does given the programmer may give two instructions for both white and black pieces before the cursor moves itself. This obviously means that, while definitely winnable, the programmer is expected to compete in a race with the cursor as they write their instructions.

The cursors initial direction is north, and begins on the white king.

Piece instructions

Standard to chess, Cheß hosts six pieces: The pawn, rook, knight, bishop, queen, and king. Each of these pieces holds two things, an instruction and a direction.

King: The cursor begins the program at the king, and terminates when landing on the king again. The cursor will complete once landing on a king.

Queen: When the cursor is on a queen, the value in the spot it's on is printed as an ascii character. The cursor goes east if it's a white piece, and west if it's a black piece.

Bishop: When the cursor is on a bishop, input is taken from the user, an 8 bit integer, and places that value in the spot it's on, yielding the program for the users input. The cursor goes south if it's a white piece, and north if it's a black piece.

Knight: When the cursor is on a knight, the spot it is on is decremented. The cursor goes west if it's a white piece, and east if it's a black piece.

Rook: When the cursor is on a rook, a random 8 bit integer number is input into the spot it is on. The direction the cursor goes is dictated by the value, mod the value by 4: 0 is north, 1 is east, 2 is south, 3 is west.

Pawn: When the cursor is on a pawn, the spot it is on is incremented. When the value of the spot the piece is on is under 255: The cursor goes north if it's a white piece, and south if it's a black piece. When the value of the spot the piece is on is equal to 255: The cursor goes south if it's a white piece, and north if it's a black piece.

Examples

Cat

A Cat program writes its input directly to its output.

D2 to D4
D7 to D6
C1 to F4
E8 to C6
F4 to D6
D8 to D7
B1 to D2
C6 to C5
A2 to A3
D7 to C6
// User Input
D6 to E5
C5 to D6
A3 to A4
A7 to A6
A4 to A5
A8 to A7
// Print Input
A1 to A2
A7 to A8
// Terminate