1
\$\begingroup\$

The goal is to write a program that learns from its own mistakes, and improves itself based on it. This means, that later attempts at the problem should be either faster or more accurate, than earlier ones.

To deny trivial solutions, here is a set of rules (they are rather obvious):

  • you can choose the problem to be solved, but your choice will be voted upon.
  • the program should read input, this means the problem must have input variables, and its output should depend on that input.
  • later runs of the algorithm should be better (at least after a certain number of runs) than the previous ones. Better can mean faster, or more optimal, or more accurate.
  • the improvement must be real, and not just the disabling of purposefully introduced inhibitors like if (never_run_before()) sleep(100);
  • the improvement must be caused by your program, and not external factors (like the OS giving faster access to a resource, if it was already opened or more often accessed before)
  • the iterations can be either successive runs of the program while you save knowledge to a non-volatile storage, or you can have an interactive program which reads input again and again for successive runs of the algorithm.
  • there should be improvement besides the situation where the algorithm runs faster given the exact same input data. (just storing previous results and doing nothing else would be too cheap). This means, there should be some improvement even if there is no repetition in the input data, for example if the task is to solve a maze, the input maze might be different each time.
  • the algorithm must be part of your program, so the use of existing machine-learning tools is not allowed (otherwise it would be a too easy win for Matlab and its built-in neural network)

The score is: number of characters - 5 * score form votes. It can be negative. Smallest wins. Winner will be selected not sooner than 10 days after the first valid solution, and has to have a positive vote score.

For voters: the golfing is already an independent part of the score, so pleas don't vote based on the amount of golfing, but on the cleverness of the solution and the hardness and originality of the chosen problem (a program playing a game against the user should worth more than a program calculating the digits of pi)

\$\endgroup\$
2
  • 8
    \$\begingroup\$ I think the task is way too unspecified. There is no basis to judge an attempt with respect to size (which is what code-golf is about). And since you can only up- or downvote you cannot effectively score distinct answers. \$\endgroup\$
    – Howard
    Jul 20, 2012 at 14:32
  • 1
    \$\begingroup\$ The task may be unspecified, deliberately, but the scoring is unambiguous. You might suggest a more limiting factor for the task if you wish, before the first solution is posted. I wanted to give the solvers some freedom, as in a number of other open-ended quests, like this one: codegolf.stackexchange.com/questions/2922/… It was not stated what the program must do. \$\endgroup\$
    – vsz
    Jul 20, 2012 at 14:36

2 Answers 2

12
\$\begingroup\$

GNU Octave / MATLAB, 14

f=@(n)n+sin(n)

You don't generally take a standard input with Octave programs, so this is a function which gives an improved estimate of pi after every call on its previous output. Sample run:

octave> f=@(n)n+sin(n);
octave> format 'long'
octave> n = 1;
octave> n = f(n)
n =  1.84147098480790
octave> n = f(n)
n =  2.80506170934973
octave> n = f(n)
n =  3.13527633289972
octave> n = f(n)
n =  3.14159261159065
octave> n = f(n)
n =  3.14159265358979
\$\endgroup\$
8
\$\begingroup\$

Python, 12

This program golfs itself, improving its own score for this challenge. It takes two iterations to fully optimize itself.

initial program

print'print'

first output / second program

print

second output / third program: newline

third output / fourth program: empty

all subsequent programs: empty

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Quite a cheeky one, I like it. But doesn't it fall foul of the "program should read input" rule? \$\endgroup\$
    – Griffin
    Jul 22, 2012 at 0:50
  • \$\begingroup\$ @Griffin, you're right... dang \$\endgroup\$
    – boothby
    Jul 22, 2012 at 23:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.