Thief, Police and the Building

From Esolang
Jump to navigation Jump to search

Thief, Police and the Building is a newly invented programming language but it isn't started to use by programmers, possibly because it's not so convenient.

The expanation of the commands are written in natural language. Here is the list:

Code

Init (You must write these)

  • A thief on [number]/F : It means that there is a thief on [number] /F, especially, when [number] is G , it means that the thief is on the ground floor. When [number] is a negative number, it means the thief is in the basement.
  • Set SoE -> [number]F/s : Set the speed of elevator to [number] floors per second.
  • Set SoS -> [number]F/s : Set the speed of climbing stairs to [number] floors per second.
  • top: [number]-th floor : Claim that the top floor is [number] -th floor.([number] >0 or [number] = G)
  • btm: [number]-th floor : Claim that the bottom floor is [number] -th floor. ([number] <0 or [number] = G)
[n/F char 1] [n/F char 2] [n/F char 3] ... [n/F char m]
[n-1/F char 1] [n-1/F char 2] [n-1/F char 3] ... [n-1/F char m]
[n-2/F char 1] [n-2/F char 2] [n-2/F char 3] ... [n-2/F char m]
...
[1/F char 1] [1/F char 2] [1/F char 3] ... [1/F char m]
G/F [G/F char 1] [G/F char 2] [G/F char 3] ... [G/F char m]
[-1/F char 1] [-1/F char 2] [-1/F char 3] ... [-1/F char m]
[-2/F char 1] [-2/F char 2] [-2/F char 3] ... [-2/F char m]
...
[-t/F char 1] [-t/F char 2] [-t/F char 3] ... [-t/F char m]

These bunch of things means all rooms from the n-th floor to basement t-th floor. Each floor has m rooms. Each room is a char.

Movement

  • He gets into the elevator and gets [string(up/down)]: The thief gets into the elevator and gets [string(up/down)].
  • He stays in the elevator for [number]s: The thief stays in the elevator for [number] seconds. In other words, he gets up/down [number] * SoE floors.
  • He gets into the stair room and gets [string(up/down)]: The thief gets into the elevator and gets [string(up/down)].
  • He stays in the stair room for [number]s: The thief stays in the stair room for [number] seconds. In other words, he gets up/down [number] * SoS floors.
  • He gets out: The thief gets out from the elevator/stair room.
  • He climbs into [number]-th room and steals: The thief steals the [number]-th room on the floor. So a char was in his bag. This char is the same as the char in the Init part you just read:
  • The police have come: Print all the chars in the thief's bag in the order that he steals, then terminate the program.

Commands and Program States

A command's validity constitutes a dependency upon the current preceding actions, which ultimately delineates an underlying state machine for the thief's options at any instant.

The program incorporates a quadruple of possible states, each either obtained from the thief's location or the police as a parhedral actor:

State Role
in floor The thief roams freely in the building.
in elevator The thief has entered the elevator.
in stair room The thief has entered the stair room.
in custody The police have arrived.

A concomitant to the states, a septuple tally of events serves in the state machine's completion, any among these corresponding to a Thief, Police and the Building command:

Command Event
He gets into the elevator and gets … enter elevator
He gets into the stair room and gets … enter stair room
He stays in the elevator for … operate elevator
He stays in the stair room for … climb stair room
He gets out leave
He climbs into …-th number and steals rob room
The police have come encounter police

The following UML state diagram serves in the dependencies' visual replication:

Examples

Hello, World!

A thief on G/F
Set SoE -> 3F/s
Set SoS -> 1F/s
top: G-th floor
btm: -3-th floor
G/F H e l l o ,
a b c d e f
2 3 j k l m
W o r l d !
He climbs into 1-th room and steals
He climbs into 2-th room and steals
He climbs into 3-th room and steals
He climbs into 4-th room and steals
He climbs into 5-th room and steals
He climbs into 6-th room and steals
He gets into the elevator and gets down
He stays in the elevator for 1s
He gets out
He climbs into 1-th room and steals
He climbs into 2-th room and steals
He climbs into 3-th room and steals
He climbs into 4-th room and steals
He climbs into 5-th room and steals
He climbs into 6-th room and steals
The police have come

Kiwiscript

This program utilizes a difference in the elevator's and stair room's celerity, producing a rather tortuous negotiation across the premise, in the pursuit to print the message “kiwi”:

A thief on -1/F
Set SoE -> 2F/s
Set SoS -> 1F/s
top:  3-th floor
btm: -1-th floor
q w e r t y u i o p
a s d f g h j k l ]
z x c v b n m , . !
G/F 0 1 2 3 4 5 6 7 8 9
_ _ _ _ _ _ _ _ _ _
He gets into the elevator and gets up
He stays in the elevator for 2s
He gets out
He gets into the stair room and gets down
He stays in the stair room for 1s
He gets out
He climbs into 8-th room and steals
He gets into the stair room and gets down
He stays in the stair room for 1s
He gets out
He gets into the elevator and gets up
He stays in the elevator for 1s
He gets out
He climbs into 8-th room and steals
He climbs into 2-th room and steals
He climbs into 8-th room and steals
The police have come

Interpreter

  • Common Lisp implementation of the Thief, Police and the Building programming language.

See also