←back to thread

296 points reverseCh | 1 comments | | HN request time: 0.456s | source

I recently came across the concept of "useless" programs - pieces of code that serve no practical purpose but are fun, creative, or challenging to write. These could be anything from elaborate ASCII art generators to programs that solve imaginary problems. I'm curious to hear about the most interesting or creative "useless" programs the HN community has written. What was your motivation? What unexpected challenges did you face? Did you learn anything valuable from the experience? Some examples to get the ball rolling: 1. A program that prints the lyrics of "99 Bottles of Beer" in binary. A text-based game where you play as a semicolon trying to find its way to the end of a line of code. A script that translates English text into Shakespearean insults. Share your creations, no matter how quirky or impractical. Let's celebrate the joy of coding for coding's sake!
1. TacticalCoder ◴[] No.41927208[source]
I wrote many. One I remember is writing a little piece of code that'd pick "optimal" starting positions in the board game The Settlers of Catan. Now by "optimal" I don't mean it was actually the absolute best position possible according to the complete rules of the game but the system would use a few heuristics to determine an optimal position according to simplified rules.

Then each "player" (well computer player really) would pick it's starting position in an optimal way according to these rules.

It's fun because the set up of the game begins like this (say there are three players):

    p1 puts his first village and one road
    p2 puts his first village and one road
    p3 puts his two villages and two roads at once
    p2 puts his last village and one road
    p1 puts hist last village and one road
The idea being that p1 is so advantaged by the fact that he picked the best spot, that he then gets to put his second village only after the other players have put everything in place.

So it's cute from an game theory point of view to find the "optimal" (according to my rules at least). It's just recursion. Each player knows that the next player is going to play optimally too and they all pick their spot(s) accordingly after having evaluated all possible positions.

> What was your motivation?

Just having fun.