Conway's Game of Life
This repo contains several different implementations of the same algorithm to play Conway's Game of Life for iOS, Android, CLI, and the web.
- The iOS application was written in Swift 4 and runs in iOS 11. The project and storyboards requires Xcode 9.
- The Android application was written in Kotlin 1.1.60 and runs in Android 5 ("Lollipop", API 21) and higher. The project requires Android Studio 3.0.
<canvas>support (IE 9+, Edge 12, Firefox 3.6+, Chrome 4+, Safari 4+, Opera 10.1+). The project can be opened with WebStorm 2017.2.5.
- The C++ application was written in C++ 17 with Visual Studio Code, using CMake to drive the compilation. It requires the curses library to be installed locally. It uses Catch2 (already distributed with this project.)
The mobile applications do not have any external dependencies. On the other hand, the web application can be built using webpack and uses the ts-loader package. Run
npm install right after checking out, to download all the dependencies.
All applications have the same structure:
Worldtype represents a square lattice of
Cellobjects, represented as an enum. Each
Cellis referenced in its
Worldtype also provides static methods to create common configurations of cells in a specific location in the lattice: "block", "blinker", "glider" and others are provided.
WorldViewclass is in charge of the visual representation of a
Worldinstance using the underlying drawing mechanism: CoreGraphics in iOS,
<canvas>in HTML, and native Android drawing.
- The screen of the application is represented by an activity in Android, a view controller in iOS and a webpage in HTML. It triggers the evaluation of the next iteration of the world every 500 milliseconds with a delayed task on the main thread of the application.
- There are some small differences in the implementations to take care of some conceptual and performance requirements in each of the supported platforms.
- The algorithms privilege readability and study rather than performance and efficiency.
- The lattice has no periodic boundary conditions.
- The three applications have exactly the same unit tests.
- The iOS tests can be run with
xcodebuild -scheme Conway -destination 'platform=iOS Simulator,name=iPhone 8' test.
- The Android tests can be run with
- The web application tests are built with Mocha and can be run on the command line with
- The C++ application can be built and run using the following commands:
cmake . make build/life
The root of the project contains a
Makefile with a
test task that will execute all tests at once.
Copyright 2017 – Adrian Kosmaczewski
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.