CHAZZ

From Esolang
Jump to navigation Jump to search

CHAZZ

Logo of CHAZZ

CHAZZ is an esoteric programming language or more precisely its interpreter link to repository.

Table of Contents

Introduction

This interpreter was created for the Computermusic and Multimedia class at IEM Graz. The basic guidelines were to implement a Turing complete programming language's interpreter.

Usage

After compiling chazz.c, call the interpreter with any pre-created `.fen` file as follows. Try out the given examples:

<syntaxhighlight lang="bash"> ./chazz ./examples/tutorial.fen </syntaxhighlight>

A flag can be set to display the chess board as HTML:

<syntaxhighlight lang="bash"> ./chazz ./examples/tutorial.fen true </syntaxhighlight>

Horizontally Relative Increment/Decrement

Pawns are interpreted as either increment (P) or decrement (p) of their horizontal position's binary value. A line of pawns on the traditional 8×8 chess board PPPPPPPP is equal to 11111111 and represents 255. Note: binary is interpreted from left to right (2^0 … 2^7).

Manual

Logic of a program is based on placing chess pieces on the chess board represented by a .FEN file. Most recent updates remove the restriction to 8×8 boards.

.FEN explained

FEN (Forsyth-Edwards Notation) is a standard notation for describing a chessboard position. A single line of FEN provides all necessary information to reconstruct a board state.

Structure of FEN

FEN consists of six fields, separated by spaces. CHAZZ does not require FEN to be "valid" in the classical sense.

<syntaxhighlight lang="text"> <Piece Placement> <Active Color> <Castling Rights> <En Passant Target Square> <Halfmove Clock> <Fullmove Number> </syntaxhighlight>

1. Piece Placement: Placement from 8th rank to 1st, `/` separates ranks. Uppercase: white (`K,Q,R,B,N,P`), lowercase: black (`k,q,r,b,n,p`), numbers = empty squares.

  Example: `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR`

2. Active Color: `w` or `b`. Example: `w`

3. Castling Rights: `KQkq` or `-`. Example: `KQkq`

4. En Passant Target: `e3` or `-`

5. Halfmove Clock: number of halfmoves since last pawn move or capture

6. Fullmove Number: total moves, increments after Black's move

Utilized .FEN fields

  • Piece Placement: majority of information for CHAZZ commands
  • Active Color: determines which color to interpret first

All other fields are ignored.

Chess pieces/commands

Command Piece Description
P white Pawn increment binary value relative to current horizontal position
N white Knight pointer increment
R white Rook write to stdout
B white Bishop begin loop
Q white Queen push memory value to buffer
K white King set 1
p black Pawn decrement binary value relative to current horizontal position
n black Knight pointer decrement
r black Rook read from stdin
b black Bishop end loop
q black Queen pop buffer content
k black King set 0

An Example

Tutorial file: `examples/tutorial.fen`

<syntaxhighlight lang="text"> 4PPQ1/PR6/qPR5/q1PR4/q2PR3/N2PBn2/pRN5/pbKBrRkb w </syntaxhighlight>

Interpretation

  • Active Color: `w`
  • Piece Placement:
 - `4PP` → ASCII '0', pushed/popped to/from buffer with `Q` and `q`  
 - `PR6`, `qPR5`, `q1PR4`, `q2PR3` → binary values interpreted from pawn horizontal positions  
 - `N` → pointer increment for loop counter  
 - Loop with `B`…`b` executes pointer decrements, pawns, and output with `R`  
 - Input with `r` and output with `R`, loop controlled with `K`/`k`

Step by Step Explanation

Step Piece(s) Operation Memory cell Content/Action
0.0 initial state 0 0
0.1 4PP +2^5 +2^6 0 48
0.2 Q push buffer: 48
0.3 P +2^0 0 49
0.4 R print '1'
0.5 q pop 0 48
0.6 P +2^1 0 50
0.7 R print '2'

FAQ

  • Why doesn't `chazz` output '3' for `PPR5/8/8/8/8/8/8/8 w`?
 - CHAZZ writes ASCII characters to stdout; '3' must be 51.
  • Why doesn't `r7/4PPR1/8/8/8/8/8/8 w` accept input?
 - Active color is white, interpreter ignores black pieces until first white piece.

Outlook/Possible Additions

  • [ ] Add build/run routines (shell script, Makefile, CMake)
  • [x] Add flag to enable/disable graphical output
  • [ ] GUI for creating .FEN by drag-and-drop

GitHub Repository