GithubHelp home page GithubHelp logo

jrie / cgol Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 15.06 MB

An advanced conway game of life simulator in C

License: GNU General Public License v3.0

Makefile 0.80% C 99.20%
conway-s-game-of-life conway conway-game graphics image-processing history histogram animations

cgol's Introduction

cgol

A Conway game of life simulator

Video demo: cgol - feature video demo

Compilation

Requirements for compilation are gcc, make and pkg-config and the following libraries:

  • libpng
  • libcairo2
  • libsdl2
  • libsdl2-image2

Compile using make under Linux. For Windows, you can use Msys2 and make -f Makefile_win but this version seemed to have some drawbacks while in "painting mode".

On "Ubuntu 16.04" - you have to change the line number 650:

sprintf(gameOptions->message, message);

to

sprintf(gameOptions->message, "%63s", message);

This might be in reason of the gcc version on Ubuntu 16.04 LTS.

Welcome to Conway's Game of life

This is a competition entry for the IT-Talents.de coding competition. By Jan R. - Version date: September 25th 2017.

Enter cgol -h to show the help which is much recommended

GENERAL HELP

This is Conway's Game of life. You can either paint living cells, using the mouse in paint mode or drag and drop a 32 bit png with alpha channel into the game window, this will generate a cell map varying from the image.

Images should be equal in there dimensions in order to reach the best effect. For example a one by one ratio, divisble by the cells in x and y to the image pixel dimensions. For generation you could use TheGimp or save out images from the game using s key. Example images are incuded which are all consisting of 32bit PNG images with alpha.

SAVING IMAGES AND DRAG AND DROP

If you want to save an image, you can do so by pressing s key. It is then saved to the folder saved_images/TIMESTAMP.png. The routine saves everything except the grid and the message displayed inside the game window. Those images can be reimported into the application, like other images, by drag and drop.

Note that CAIRO backend png's, switch -cb, cannot directly be imported as they are missing the alpha channel. You have to use TheGimp or similiar to add an alpha channel, then import is working!

INFO PANEL USAGE

If the history is enabled ("h" key) - and the info panel enabled, three bars are shown at the bottom of the screen. When the mouse is moved on top of those bars, either: - Stable cells are shown, which didnt change in this turn or survived - Born cells. cells which did become born during a turn - Dead cells, which died during this turn

If you hover over the corresponding bar, you see the exact cells highlighted. And there counts are always displayed on the bars.

AVAILABLE COMMANDS

-h: This help

-c5 ... 250: Amount of cells in x and y by one number from 5 to 250 (default: 50)

-ct0.0 ... 1.0: Floating point value 0.5 for 50 percent color threshold (default: 0.85) (rgb added together and averaged) for living cell image generation, below the set value

-mfc0.0 ... 1.0: Maximum fit cells for random number generator (default 0.4)

Start options of boolean type either 0/1 or t/f AND (also in game options/keybindings):

-gBOOL or [KEY]: Grid enabled (t)rue or 1 or disabled (f)alse or 0 - (g key in game)

-aBOOL or [KEY]: Animations enabled or disabled (a key in game to toggle)

-htBOOL or [KEY]: History enabled or disabled (Toggled using h key in game)

-iBOOL or [KEY]: Draw infopanel when history is enabled and one turn is processed (Toggled with i key)

-r or [KEY]: Should the game start with a random playboard, be regenerated with a random playboard (r key in game)

-cb: Should cairo's png functions be used instead of libpng to save images Cairo backend images cannot be imported directly! Please read the help for more information.

[KEY] s: Saves the actual scene, including the info panel if displayed ("s" key in game)

[KEY] + (not numpad): Decrease game ticks and increase game speed (+ key in game)

[KEY] ,: Go back in history, if enabled (, key in game)

[KEY] .: Go forward in history, if enabled (. key in game)

[KEY] c: Clear game board (c key in game)

[KEY] p: Paint mode (p key in game)

[KEY] Space :Play/Pause the game (space key in game)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.