You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/taking_a_joke_to_an_extreme.md
+18-19Lines changed: 18 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,34 +10,34 @@ author: "DolphyWind"
10
10
---
11
11
12
12
[Code Guessing](https://codeguessing.gay/index) is an online social deduction game. On each round there are two phases: the writing phase and the guessing phase. At the beginning of the
13
-
writing phase, players are given a spec and expected to write code, that in some shape or form adheres to it. The writing phase, if no extension happens, lasts for a week, and is followed by the guessing phase.
14
-
Before the guessing phase, all entries are shuffled and made public. During the guessing phase, each player guesses which piece of code is written by which player. At the end of the guessing phase, players earn 1 point for
13
+
writing phase, players are given a specification and expected to write code, that in some shape or form adheres to it. The writing phase, if no extension happens, lasts for a week and after that, all entries are shuffled
14
+
and made public. The guessing phase comes after the writing phase, in it each player guesses which entry is written by which player. At the end of a round, players earn 1 point for
15
15
each player they guessed correctly and lose 1 point for each player that guessed them correctly. The winner of a round determines the next challenge.
16
16
17
17
There are all kinds of players: Some get too competitive and impersonate others, pay attention to every single detail of other submissions. Some don't care about the guessing phase and the point system and just focus on solving
18
18
the challenge. Some try to write code that is aesthetically pleasing. Players are very well encouraged to show their creativity during the writing phase otherwise it would be a very boring ripoff of leetcode.
19
19
20
20
My code guessing submissions usually are impersonations (though I stopped doing that once I became less competitive), implementations of algorithms I wanted to try but previously had no reason to, silly jokes or occasional
21
-
boring entries. Code guessing offers challenges of every kind. So there is always something to learn.
21
+
boring entries. Code guessing offers challenges of every kind. So there is always something different to try.
22
22
23
23
There are many interesting stories to tell about code guessing. From the time there was a malicious JavaScript entry (the kind that steals your guesses and sends them to a remote server) to the time it turned out the owners
24
-
of each code were present in the HTML code and no one noticed it for 58 rounds. On this blogpost I am going to talk about me taking an in-joke to an extreme.
24
+
of each code were present in the HTML code of the page and no one noticed it for 58 rounds. On this blogpost I am going to talk about me taking an in-joke to an extreme.
25
25
26
26
## CG 53: Box Drawing
27
-
It was a normal round. The challenge was, given a string of unicode characters, called "drawing", figuring out whether it follows the given criterias or not. I submitted a buggy python code, as the
27
+
It was an average round. The challenge was, given a string of unicode characters, named "drawing", figuring out whether it follows the given criterias or not. I submitted a buggy python code, as the
28
28
challenge was not that interesting for me. But during the guessing phase, an entry piqued my interest. It was a PICO-8 game cartridge, submitted by olus2000.
29
29
[PICO-8](https://www.lexaloffle.com/pico-8.php) is a fantasy console by Lexaloffle. Here's the said entry:
Yes that png file **is** the cartridge. Anyway, at the moment I thought I found the perfect person to impersonate next round...
33
33
34
34
## CG 54: 3D Rendering
35
-
CG 54's challenge is still one of my favorites to this day, not just because it started it all but because I genuinely had fun coding it. The challenge was to implement 3D rendering. To impersonate olus2000, I decided to
36
-
get a copy of PICO-8 and solve the challenge in it.
35
+
CG 54's challenge is still one of my favorites to this day, not just because it started it all but because I genuinely had so much fun coding it. The challenge was to implement 3D rendering. To impersonate olus2000,
36
+
I decided to get a copy of PICO-8 and solve the challenge in it.
37
37
38
38
I decided to have a simple 3D cube on the screen and have 3D camera controls. To implement it, I used the MVP matrix method. How it works is, to find the on-screen coordinate of a given vertex, we multiply it with three special
39
-
$4\times4$ matrices, namely, Model ($M$), View ($V$) and Projection ($P$). "Well, aren't we in 3D? Why are those matrices $4\times 4$?" you might ask, while it is technically possible, turns out they can be represented as a
40
-
matrix with the help of [Homogeneous Coordinates](https://en.wikipedia.org/wiki/Homogeneous_coordinates) and easily computed with GPU hardware.
39
+
$4\times 4$ matrices, namely, Model ($M$), View ($V$) and Projection ($P$). "Well, aren't we in 3D? Why are those matrices $4\times 4$?" you might ask, while it is technically possible, turns out each can be represented as a
40
+
single $4\times 4$ matrix with the help of [Homogeneous Coordinates](https://en.wikipedia.org/wiki/Homogeneous_coordinates) and easily processed with GPU hardware.
41
41
42
42
To put it simply, a point in euclidian 3D space with coordinates $(\frac{x}{w}, \frac{y}{w}, \frac{z}{w})$ can be represented as the homogeneous coordinate $(x, y, z, w)$. Usually we care about the case when $w=1$, when it is
43
43
"normalized". In short, **model matrix** takes an object from its local coordinate space to world (global) space, the **view matrix** then transforms the scene such that the camera is in the origin, looking along the $z$-axis
@@ -46,13 +46,13 @@ To put it simply, a point in euclidian 3D space with coordinates $(\frac{x}{w},
46
46
It turned out to be a bit heavy for the PICO-8 due to rasterization being compute-heavy, but it works well and looks cool in general.
47
47

48
48
49
-
To my surprise, another player, named **kimapr**, has also thought of impersonating olus2000 and submitted a spinning cube in PICO-8.
49
+
To my surprise, another player, **kimapr**, has also thought of impersonating olus2000 and submitted a spinning cube in PICO-8.
50
50

51
51
52
52
What makes it funnier is that olus2000 did not participate in this round, so we had two impersonators without the impersonatee being present. Impersonating her became an in-joke for a short while.
53
53
54
54
## CG 56: Reverse Engineer a Regex
55
-
The challenge was, given an expression that recognizes a regular language, find a string that is recognized by the given expression. I made a simple recursive descent parser in C but I did not submit that directly.
55
+
The challenge was, given an expression that recognizes a regular language, find a string that is recognized by it. I made a simple recursive descent parser in C but I did not submit that directly.
56
56
57
57
You see, I *really* liked that in-joke, so I wanted to continue it. In C, there is a feature called "macros". It is essentially a piece of code that gets substituted in the preprocessor pass, before the actual compilation happens.
58
58
They are commonly used to get rid of magic numbers but they are much powerful than that. Macros are defined using the `#define` directive and since it is a simple text substitution, they can make your code appear like something
@@ -130,11 +130,11 @@ place and having my challenge be the next one.
130
130
## More..?
131
131
The C code above is already on another level. But I had an idea, what if **everything** was olus2000. So I did what any reasonable person would do, began creating a programming language named olus2000.
132
132
133
-
Because she loves concatenative languages, and especially [Forth](https://en.wikipedia.org/wiki/Forth_(programming_language)), I wanted my language to be a Forth-like language. This decision freed me from focusing on syntax
134
-
and wasting my time on stupid decisions.
133
+
Because she loves concatenative languages, and especially [Forth](https://en.wikipedia.org/wiki/Forth_(programming_language)), I wanted my language to be Forth-like. This decision freed me from focusing on the general structure
134
+
of the syntax and wasting my time on stupid decisions.
135
135
136
136
For a Forth-like language, I needed instructions, better known as "words". Since the characters `0`, `o` and `O` look similar (up to an arbitrary measure of similarity), I wanted each posible
137
-
alteration of last three characters of "olus2000" to correspond to a different instruction. This gives us a total of 27 words, which is enough.
137
+
alteration of last three characters of "olus2000" to correspond to a different word. This gives us a total of 27 words, which is enough.
138
138
139
139
Numbers are represented in a special ternary-based encoding. First, to begin entering a number you need to switch to either "Number Mode" or "Negative Number Mode" by putting "0lus2000!" or "0lus2ooo!", respectively.
140
140
(Looking back at it, the use of the exclamation mark at the end could've been avoided by employing other encoding schemes). When you are in either mode, each term of the form "olus2xyz" represents a group of trits `xyz`, where
@@ -151,7 +151,7 @@ be to do?
151
151
Torth is a Forth-like esoteric programming language. It stands for "Ternary Forth". It exclusively allows ternary numbers in its syntax. Wait a second, what does this have to do with the language above again?
152
152
153
153
When I ended the paragraph with "It seems like I have only two options" I wasn't being honest. Because in the past, people have already solved a similar problem. When machine code was too hard to program by hand, people created
154
-
assembly languages and assemblers. When it was too hard to deal with, they created modern programming languages. I'm sure you start to see where this is heading to. To remedy the core issue of olus2000, I created another language,
154
+
assembly languages and assemblers. When that was too hard to deal with, they created modern programming languages. I'm sure you start to see where this is heading to. To remedy the core issue of olus2000, I created another language,
155
155
Torth, that is purposefully kept as similar to olus2000 as possible, but at the same time, it makes sense and transpiles to olus2000. Here's a simple 99 bottles of beer on the wall program in Torth:
156
156
```
157
157
: WRITE_9 IF DROP "ERROR" ELSE DROP "9" THEN ;
@@ -237,7 +237,7 @@ I started off by implementing the challenge in Torth.
237
237
(Print the look and say sequence indefinitely) 1 WHILE DROP STEP 1 THEN
238
238
```
239
239
240
-
Then transpiled it to olus2000 and shaped it up and ended up with this:
240
+
Then transpiled it to olus2000, gave it a nice shape and ended up with this:
The name of the file is, of course, `olus2000.olus2000`. Actual code occupys the first few lines, the rest is a one giant comment. You can view the specification of [olus2000](https://esolangs.org/wiki/Olus2000) and [Torth](https://esolangs.org/wiki/Torth)
271
+
The name of the file is, of course, `olus2000.olus2000`. Actual code occupies the first few lines, the rest is a one giant comment. You can view the specification of [olus2000](https://esolangs.org/wiki/Olus2000) and [Torth](https://esolangs.org/wiki/Torth)
272
272
by clicking the respective links. And for the implementation of Torth, click [here](https://github.com/DolphyWind/esoteric/tree/master/torth).
273
273
274
274
I tried to make it look like someone is impersonating me by creating a new [esolangs.org](https://esolangs.org/) account and naming it "Dolphy" (my main account is named "DolphyWind"). It didn't work at all, even though I guessed
275
-
six people correctly that round, four other people have guessed me and I ended the round with a total of $2$ points.
276
-
275
+
six people correctly that round, four other people have guessed me and I ended the round with a total of $2$ points. I don't really care about it, what I did satisfied me enough.
0 commit comments