OpenAI Codex produces Life

OpenAI Codex produces Life!
More specifically – Conway’s Game Of Life.
This prompt should be reproducible, even taking in account the stochastic nature of floating point GPUs/TPUs. Please give feedback on how well this prompt works for you. It may take a couple of tries to generate this result, but it’s pretty stable :slight_smile:

gameoflife
(Looping GIF)

Prompt:

#Define a Python function which is “Conway’s Game Of Life”.
#Set field size to 800x600 and cell size to 10x10. Randomize the startup cells.
#Display game field using pygame library.

import pygame

Parameters:

Response length: 222
Temperature: 0
Top P: 1
Frequency penalty: 0.1
Presence penalty: 0.1
Best of: 1

Here is the “game” code produced by prompting Codex:

17 Likes

Well, pygame just plays the role of graphics display here, same as matplotlib, because we need to see the results somehow :slight_smile:
And, I’m not unlucky with the “stochastic” nature of GPUs, I was just referring to this discussion about determinism:

Great prompt by the way! Simple is better :+1:

1 Like

I know this is a bit tangential, but has me stuck. For JS, there are many great live web-based IDEs such as jsfiddle and codio to name two. What is there for python on a Mac (I’ve seen that visual studio can use multiple languages for the PC)? I have tried the “python sandbox” but it isn’t clear what I do when a module does not exist in that environment. I also have pycharm which I’ve toyed with. I am curious what you and others use.

2 Likes

I myself use the default OpenAI Playground for prompt design and code generation. At least for now, while I’m developing my own local sandbox.
As I am on a Linux system, I just launch the generated code from command line. If editing is needed I use nano text editor.
Python is very well equipped in Linux environment, and I tend to use native libraries anyway.
That said – today I wrote a little tool named CopyRun. It runs from command line and stays in background. Then it automatically runs any Python code that is copied in clipboard. From any source.
I just really don’t like pasting API keys in third party IDEs or sandboxes…
Here is the CopyRun code – read the manual, evaluate it and use, if You like it :slight_smile:

3 Likes

Inspired by your Python production. I went for a Javascript version as my first Codex attempt.

It took a little tweaking, but these were the prompts that I put into the sndbox:

#Define a Javascript function which is “Conway’s Game Of Life”.
#Set field size to 600x600 and cell size to 4x4. Randomize the startup cells.
#The background is black and the cells are yellow, set in a grid.
#The game runs on a loop at 12 frames per second.
#Remove scrollbars from the display field.
#After 20 seconds the cells are randomized and the game loop is restarted.

The results were impressive: https://jsfiddle.net/swingpants/eupxb9Lr/9/

{Sudden realisation that the last command only fires once. Should have said ‘After each 20 seconds…’ or similar}

2 Likes

This is really cool! Thanks for sharing your experiment. Game Of Life always looks impressive, and it kinda suits the spirit of creating new life forms with Codex, and GPT in general. Good luck in new explorations :+1:

1 Like

Ready or not – here we go! :sweat_smile:
But, looking at it more seriously, the world is moving in that direction really fast. For example - Tesla bots. I know that Elon over-hypes everything, and we will wait and wait for the tech, but the bots serve many purposes. One of the purposes is edutainment and PR – they let people know that shift towards AGI is happening. It’s like a sci-fi TV show which “predicts” future.
Also, seeing transformer architecture development achieving linear complexity, I can say this field will improve by leaps and bounds.

1 Like

A JavaScript version: https://jsfiddle.net/kirkouimet/ter97uyh/

2 Likes

Was this a single prompt or 4 separate prompts?

1 Like

This is a single prompt.

Expect Great results to different results!!!

2 Likes