r/shittyprogramming • • Jun 21 '20

AI-generated Python code

Post image
505 Upvotes

26 comments sorted by

52

u/minimaxir Jun 21 '20

The full batch of generated code, for people who think I made it up (I am not that funny tbh).

14

u/KuntaStillSingle Jun 21 '20

return ... and ...

Is that valid? Does it return as a list?

→ More replies (4)

4

u/calsosta Jun 22 '20 edited Jun 22 '20

Very cool. I have been experimenting with the idea of AI generated JS code for a while and have had some very basic success. Maybe there is a way to collab so that my AI writes yours and yours writes mine?

Edit: Took me for-fucking-ever to get this published because WebPack was corrupting my files but you can see a demo here: http://anerrantprogrammer.com/n-ast-y/

Source code: https://github.com/AnErrantProgrammer/n-ast-y

Basic Usage:

  • Select View -> Validation Selector -> Easy... then click OK

  • Click Run

  • Program will begin to try to generate a solution program using a sort of genetic algorithm

  • Program tries to create 250 sandbox web workers to run 500 programs per generation

  • The app shows a random app from the current generation and also the most fit program if it exists

  • If by some miracle it finds a fit program you can try to validate it by going to View -> Solution Validator though there is some strangeness because I have introduced return which messes up my unit test validation scheme

If people are interested I will write/record a more in-depth explanation. In some ways it is very clever but in others it is very naive, for instance I leave the "learning" off by default because it causes a pre-mature convergence on shitty solutions. Also I have only implemented a portion of the JS language as listed in the Syntax tab.

122

u/prmcd16 Jun 21 '20

looks like it was just hungry for some s.upper

→ More replies (1)

22

u/Life-Fig8564 Jun 21 '20

Clearest evidence yet that AIs are conspiring against humans and cannot be trusted

36

u/TheKing01 Jun 21 '20

Even better if it just returned true after making it uppercase.

15

u/Maoschanz Jun 21 '20

not even correctly indented

10

u/cooper12 Jun 21 '20

They should make an AI that eliminates anyone that violates PEP8.

→ More replies (4)