HZCode or HZC is perhaps the first 2-Dimensional esolang based on Chinese characters. It is invented by User:None1. It is inspired by Aheui, and derives a lot of commands from Befunge. Like Aheui, it doesn't have self-modifying.
HZ comes from 汉字, the Chinese word meaning Chinese characters (Hanzi), so it should be pronounced /'hɑːnzkəud/, but saying the H and Z as individual English letters is fine.
It uses two stacks containing unbounded unsigned integers, and a queue containing instruction pointers. There is an instruction pointer that points to the top-left and faces to the right initially, and the stacks are empty. Popping from an empty stack returns 0. Subtraction from 0 returns 0 and division or modulo by 0 returns 0.
Unlike Befunge-93, it has no restriction on code size.
From now on, when we mention IP, we mean the instruction pointer at the queue front.
- Read the character at the IP.
- Execute the character.
- Pop the IP, move it in its direction (up/down/left/right) and push into the queue back, then repeat 1.
Moving out of bounds wraps around.
|Set IP direction to up
|Set IP direction to down
|Set IP direction to left
|Set IP direction to right
|Do nothing, usually used to make the code prettier
|Rotate IP 90 degrees clockwise if top of first stack isn't 0, otherwise rotate 90 degrees counterclockwise
|Rotate IP 180 degrees if top of first stack isn't 0
|Pop b and a from first stack, jump to coordinate (a,b) (means (b+1)-th character from the left in (a+1)-th row from the top)
|Nothing executed until next 移 (like Funge-98's semicolons)
|Pop c, b and a from first stack, create an instruction pointer at (a,b) that faces the direction of c modulo 4 (0:right 1:down 2:left 3:up) and push it into queue back
|Pop the IP out of queue, if the queue is empty after this operation, the program stops
|Pop first stack and push it into the second stack
|Pop second stack and push it into the first stack
|Swap the content of the first stack with the second stack
|Input as integer and push into first stack
|Output the top of first stack as integer
|Input as Unicode and push into first stack
|Output the top of first stack as Unicode
|Increment top of first stack
|Decrement top of first stack
|Pop b and a from first stack, push a+b onto first stack
|Pop b and a from first stack, push a-b onto first stack
|Pop b and a from first stack, push a×b onto first stack
|Pop b and a from first stack, push a÷b (floor division) onto first stack
|Pop b and a from first stack, push a mod b onto first stack
|Push a random number between 0 and 1 onto first stack
Push 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 10000, 100000000, 1000000000000 onto the first stack respectively.
Other characters are NOPs.
下空右说停空 右听分下空左 空空右右说上
The original IP creates another IP at (1,0), facing right, then prints
d, then the IP created by the original IP prints
o (it prints after the original IP because the original IP hits 写 first).
Fork bomb simulator
The original IP creates another IP at (0,0), facing right, then the original IP and the IP it created create other IPs.
Since HZCode doesn't use real threads, one IP is created per run, so it is not as dangerous as real fork bombs.
Currently, there are none, but I will make one, you can make your own, too.