Swiftpack.co - Package - akosma/Conway

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.

Conway's Game of Life

Requirements

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.

Structure

All applications have the same structure:

  • The World type represents a square lattice of Cell objects, represented as an enum. Each Cell is referenced in its World through a Coord object.
  • The World type also provides static methods to create common configurations of cells in a specific location in the lattice: "block", "blinker", "glider" and others are provided.
  • The WorldView class is in charge of the visual representation of a World instance 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.

Implementation Notes

  • 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.

Running 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 ./gradlew test.
  • The web application tests are built with Mocha and can be run on the command line with npm test.
  • 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.

License

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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. 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.

Github

link
Stars: 5
Help us keep the lights on

Dependencies

Used By

Total: