This is a simple implementation of the famous Conway's Game of Life in Prolog. My motivation was simply to implement something using a pure logical paradigm in order to get a better grasp of it.
To run the program, first make sure you have Prolog installed in your system.
Then, on your terminal:
- Navigate to the database file's (main.pl) directory.
- Run the command
swipl
to enter Prolog's environment. - Run the command/consult
run({NRows}, {NCols})
, replacing{NRows}
and{NCols}
by the number of rows and columns that you want your simulation to have. - Input either
y
to update the population and display it orn
to abort (finish) the execution.
Here's what it should look like:
Contributions are welcome! What I implemented is very basic, but if you feel inspired, you may implement some stuff yourself! Here are some ideas:
- Custom Initial World Input: allow the user to set the initial state of the world, instead of the default behavior of generating a random state.
- World State Customization: allow the user to modify the state of cells during execution.
- Automatic Population Update: user inputs the number of next steps to execute and the program runs them without the need of input.
- Custom Updates' Time Step: let the user set a number of seconds or milliseconds between automatic population updates.
- Pretty UI: displaying the game on the terminal is quick, easy and is feasible using pure prolog. If you're interested in trainning some frontend skills, you're more than welcome to implement a UI in whichever platform you choose: web, desktop, mobile (not sure if Prolog would work here), or whatever is feasible!