Aheui

From Esolang
Jump to navigation Jump to search
Note: This article contains special characters.

Aheui (아희 in Korean language) is the first esoteric programming language ever to be designed for Hangul, the Korean alphabet, designed by User:Puzzlet Chung.

Many of the Aheui's concept is derived from Befunge-93, except the fact that it has no instruction for self-modifying, and that it has 26 stacks and one queue.


Execution

A program is a grid of characters(it doesn't need to be a rectangle). If the cursor arrives at a boundary of the grid, it wraps around to the other side of the grid but maintains the same momentum. Complete Hangul characters(they are commands) are made of three parts:

  1. initial consonant
  2. vowel
  3. final consonant

The initial consonants are:

ㄱ,ㄲ,ㄴ,ㄷ,ㄸ,ㄹ,ㅁ,ㅂ,ㅃ,ㅅ,ㅆ,ㅇ,ㅈ,ㅉ,ㅊ,ㅋ,ㅌ,ㅍ,ㅎ

The vowels are:

ㅏ,ㅐ,ㅑ,ㅒ,ㅓ,ㅔ,ㅕ,ㅖ,ㅗ,ㅘ,ㅙ,ㅚ,ㅛ,ㅜ,ㅝ,ㅞ,ㅟ,ㅠ,ㅡ,ㅢ,ㅣ

And the final consonants are:

(no consonant),ㄱ,ㄲ,ㄳ,ㄴ,ㄵ,ㄶ,ㄷ,ㄹ,ㄺ,ㄻ,ㄼ,ㄽ,ㄾ,
ㄿ,ㅀ,ㅁ,ㅂ,ㅄ,ㅅ,ㅆ,ㅇ,ㅈ,ㅊ,ㅋ,ㅌ,ㅍ,ㅎ

The examples of complete Hangul characters: 한, 가, 응. Incomplete Hangul(ㄱ, ㅇ, ㅑ, ㅟ) and non-Hangul characters are treated as comments. The commands are executed as follows:

  1. Process the consonants(they specify the actual instruction). Update the momentum if required by the consonants.
  2. Set the momentum of the cursor based on the current momentum and the vowel(it changes the momentum).
  3. Move the cursor based on the current momentum.

Instruction pointer starts at the top left corner([0;0]) and is moving down(it has a [1;0] momentum).

Instructions

Vowels

In Aheui, the following vowels have no use (although they can still be included in valid programs):

ㅐ,ㅒ,ㅖ,ㅘ,ㅙ,ㅚ,ㅝ,ㅞ,ㅟ

Other vowels change momentum as follows:

Vowel Momentum
[0;1](right)
[0;-1](left)
[-1;0](up)
[1;0](down)
[0;2]
[0;-2]
[-2;0]
[2;0]
current momentum reflected vertically.
current momentum reflected horizontally.
current momentum reflected both vertically and horizontally.

Consonants

When reading a character, the initial consonant specifies the action to be performed. If the action takes in some parameter, the final consonant (or lack thereof) is used as the value for the parameter. If there is less values than needed in the current storage, instructions only reverse the momentum. The functionality of the consonants can be broken down into the following groups:

The "ㅇ" group:
Consonant Description
Nop
Terminate the program.

(If the current storage is non-empty, the program pops from the storage and returns the result. If the current storage is empty, the program returns 0.)

The final consonant is not used.

The "ㄷ" group (arithmetic operations):
Consonant Description
Pops two values from the current storage and pushes their sum.
Pops two values from the current storage and pushes their product
Pops two values from the current storage,

performs integer division and pushes the result.

Pops two values from the current storage,

subtracts the 1st value from the 2nd and pushes the result.

Pops two values from the current storage,

performs modulo(second%first) and pushes the result.

Pops two values from the current storage,

performs integer division and pushes the result.

All of the "ㄷ" group ingnores the final consonant.

The "ㅁ" group(storage manipulation):
Consonant Description
Pops the value from the current storage.

If the final consonant is "ㅇ": Print it as an integer. If it is "ㅎ": Print as the unicode(UTF-8) character. Otherwise do nothing with the value.

If the final consonant is "ㅇ":
 Pushes an integer from the input to the current storage.

If it is "ㅎ": Pushes the value of the unicode(UTF-8) character from the input to the current storage. Otherwise, pushes the number of strokes required to draw the consonant to the current storage:

ㄱ:2 ㄴ:2 ㄷ:3 ㄹ:5 ㅁ:4 ㅂ:4 ㅅ:2 ㅈ:3 ㅊ:4 ㅋ:3 ㅌ:4 ㅍ:4 ㄲ:4 ㄳ:4 ㄵ:5 ㄶ:5 ㄺ:7 ㄻ:9 ㄼ:9 ㄽ:9 ㄾ:9 ㄿ:9 ㅀ:8 ㅄ:6 ㅆ:4 (no consonant):0

DUP
SWAP
The "ㅅ" group:
Consonant Description
Current storage is changed by the final consonants.
The current storage is popped and the returned value is pushed into the storage mapped to by the final consonant.
Pops 2 values from the current storage. If the latter value is greater than or equal to the former value(first≥second), pushes 1 to the current storage, pushes 0 otherwise.
Pops a value from current storage. If the value is zero, reverses the current momentum. Else, do nothing.

The final consonants are mapped to the storages as follows:

The stacks: none, ㄱ, ㄴ, ㄷ, ㄹ, ㅁ, ㅂ, ㅇ, ㅅ, ㅈ, ㅊ, ㅋ, ㅌ, ㅍ, ㅎ, ㄲ, ㄳ, ㄵ, ㄶ, 
ㄺ, ㄻ, ㄼ, ㄽ, ㄾ, ㄿ, ㅀ, ㅄ, or ㅆ.
The queue: ㅇ.
The extension protocol: ㅎ.

Computational class

Unlike Befunge-93, Aheui does not specify limit of codespace; however, Aheui does not use codespace as a storage. Aheui has additional stacks instead. Since a pair of unbounded stacks can be used to simulate the unbounded tape of a Turing machine, it is likely that Aheui is Turing-complete. Partial proof.

Examples

Hello world

This code prints "Hello, world!":

밤밣따빠밣밟따뿌
빠맣파빨받밤뚜뭏
돋밬탕빠맣붏두붇
볻뫃박발뚷투뭏붖
뫃도뫃희멓뭏뭏붘
뫃봌토범더벌뿌뚜
뽑뽀멓멓더벓뻐뚠
뽀덩벐멓뻐덕더벅

Truth-machine

뱡먕뺘뼈처망희

Times table generator

Not available

Project Euler

Problem 1

This code is for Project Euler's Problem 1. It may still need reduction.

바싹밣발발발따따뚜
루벌루벋뻐터너벌벌
우뽀처빠쑥사빠아초희멍
처아아오삭도오어샥여오여

Problem 2

This program may need reduction.

바싹바발발나빠뱐주뱔뗘땨뼈뺘뗘뺘변따뗘
삭망희ㅇ루벅포뼈차
싹샥뼈댜챠사빠쑥
ㅇㅇㅇㅇ쌰석쇼뎌

Problem 5

발발나싹발밤따뿌망희
뿌석뻐서썬뻐석처속
사싹샥도루발나툐
빠쌱션속쳐볼서

Problem 6

바싹밤발발따뚜
투너벌벌뻐뻐뻐
따따싹삭두빠초
뭉뱔벌냐셔토삭
희

Special characters

This article contains special characters that fall in the Hangul Syllable area of the Unicode charset. You need an appropriate font for the browser to display it correctly. Because Aheui is a two-dimensional language, using a monospacial Hangul font is highly recommended. (e.g. UnDotum)

External resources