We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
‘a pit-crystal’
Jump to navigation
Jump to search
A pit-crystal ("pitxtal") is a target language for evaluating Crystal-complete thupits.
Interpreter
pitxtal.py
cat pitxtal.py
#!/usr/bin/env python3
import random
import sys
# --- semantics ---------------------------------------------------------
# Per-state behaviour: does this state consume, and what base string does it produce?
STATE_BEHAVIOR = {
# examples – tweak freely
'a': {'consume': True, 'produce': ''},
'b': {'consume': False, 'produce': 'n'},
'c': {'consume': True, 'produce': 'G'},
'd': {'consume': False, 'produce': 'GG'},
'e': {'consume': True, 'produce': '0'},
'f': {'consume': True, 'produce': 'nG'},
'g': {'consume': False, 'produce': '1'},
'h': {'consume': True, 'produce': 'n'},
'i': {'consume': False, 'produce': ''},
'j': {'consume': True, 'produce': 'G0'},
'k': {'consume': False, 'produce': 'n0'},
'l': {'consume': True, 'produce': 'F'},
'm': {'consume': False, 'produce': 'E'},
'n': {'consume': True, 'produce': 'G1'},
'o': {'consume': False, 'produce': 'n1'},
'p': {'consume': True, 'produce': '2'},
'q': {'consume': False, 'produce': '3'},
'r': {'consume': True, 'produce': 'n'}, # “classic r”
's': {'consume': True, 'produce': ''},
't': {'consume': True, 'produce': ''},
'u': {'consume': False, 'produce': 'G'}, # “classic uG” growth
'v': {'consume': False, 'produce': ''},
'w': {'consume': False, 'produce': 'nG'},
'x': {'consume': True, 'produce': '9'},
'y': {'consume': False, 'produce': '8'},
'z': {'consume': True, 'produce': 'nnG'},
}
# Per-symbol behaviour: class tags for rewrite logic
OBJECT_BEHAVIOR = {
# inert-ish
**{c: {'class': 'inert'} for c in "ABCDEF"},
'G': {'class': 'productive'},
**{c: {'class': 'digit'} for c in "0123456789"},
'n': {'class': 'inert'},
}
# --- flavour text (optional) -------------------------------------------
ADJ = [
'lesbian', 'gay', 'bisexual', 'trans', 'queer',
'intersex', 'asexual', '2-spirit', 'nonbinary',
]
THING = ['right', 'left', 'wrong']
def nongrill(n: int) -> str:
random.seed(n)
return f'{random.choice(ADJ)} {random.choice(THING)}'
def indef(s: str, upper: int = 0) -> str:
eu = 'n' if s and s[0] in 'aeiou' else ''
return f'{"aA"[upper]}{eu} {s}'
# --- core semantics ----------------------------------------------------
def rewrite(state: str, symbol: str) -> str:
"""Combined state+symbol production."""
s = STATE_BEHAVIOR.get(state, {'consume': False, 'produce': ''})
o = OBJECT_BEHAVIOR.get(symbol, {'class': 'inert'})
base = s['produce']
if o['class'] == 'productive':
# productive symbol: keep it alive
return base + 'G'
if o['class'] == 'digit':
# increment digit mod 10
d = (int(symbol) + 1) % 10
return base + str(d)
if o['class'] == 'inert':
return base
# fallback
return base
def run(pit_state: str, objects: str, max_steps: int | None = None) -> None:
adj = 0
object_ptr = 0
pit_ptr = 0
steps = 0
print(f'Bliss Pit (generalized) state-cycle: {pit_state}')
print('Needs:', ', '.join(
'right' if OBJECT_BEHAVIOR.get(obj, {'class': 'inert'})['class'] == 'productive'
else nongrill(i)
for i, obj in enumerate(objects)
))
print('#' * 18)
while object_ptr < len(objects):
if max_steps is not None and steps >= max_steps:
print('\n[step limit reached – assuming non-halting]')
break
steps += 1
state = pit_state[pit_ptr % len(pit_state)]
symbol = objects[object_ptr]
name = 'right' if OBJECT_BEHAVIOR.get(symbol, {'class': 'inert'})['class'] == 'productive' else nongrill(object_ptr)
verb = 'need' if adj == 'the same' else 'are'
thing = indef(name) if not adj else f'{adj} {name}'
print(f'\nThe people {verb} {thing}.')
prod = rewrite(state, symbol)
if prod:
objects += prod
if STATE_BEHAVIOR.get(state, {'consume': False})['consume']:
if OBJECT_BEHAVIOR.get(symbol, {'class': 'inert'})['class'] == 'productive':
print(f'The people are {name}.')
else:
print(f'The {name} people cry.')
object_ptr += 1
adj = 'a new'
else:
print(f'The people cannot be {name}. They riot.')
adj = 'the same'
pit_ptr += 1
if object_ptr >= len(objects):
print('Trans Rights!')
else:
print('\nTrans Wrong.')
def main() -> None:
if len(sys.argv) < 3:
print(f'Usage: {sys.argv[0]} PIT_STATE OBJECTS [MAX_STEPS]', file=sys.stderr)
sys.exit(1)
pit_state = sys.argv[1]
objects = sys.argv[2]
max_steps = int(sys.argv[3]) if len(sys.argv) > 3 else None
run(pit_state, objects, max_steps=max_steps)
if __name__ == '__main__':
main()
~ $
Computational class
This is a work in progress. It is supposed to target Crystal-complete so it should be abld to bd proven without a successor language notwithstanding Thupit.