All Projects β†’ zntfdr β†’ Life

zntfdr / Life

Licence: mit
Conway's Game of Life written in Swift πŸ‘Ύ

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Life

Open Source Ios Apps
πŸ“± Collaborative List of Open-Source iOS Apps
Stars: ✭ 28,826 (+137166.67%)
Mutual labels:  game, tvos, watchos
Color
Color utilities for macOS, iOS, tvOS, and watchOS
Stars: ✭ 145 (+590.48%)
Mutual labels:  tvos, watchos, spm
Columbus
A feature-rich country picker for iOS, tvOS and watchOS.
Stars: ✭ 23 (+9.52%)
Mutual labels:  tvos, watchos, spm
Swiftui
A collaborative list of awesome SwiftUI resources. Feel free to contribute!
Stars: ✭ 774 (+3585.71%)
Mutual labels:  tvos, watchos
Dynamicjson
Access JSON properties dynamically like JavaScript using Swift 4.2's new @dynamicMemberLookup feature
Stars: ✭ 678 (+3128.57%)
Mutual labels:  tvos, watchos
Rome
Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others
Stars: ✭ 724 (+3347.62%)
Mutual labels:  tvos, watchos
Purchases Ios
In-app purchases and subscriptions made easy. iOS, MacOS, iPadOS, tvOS, and WatchOS support.
Stars: ✭ 614 (+2823.81%)
Mutual labels:  tvos, watchos
Swiftyrsa
RSA public/private key encryption in Swift
Stars: ✭ 894 (+4157.14%)
Mutual labels:  tvos, watchos
Term2048
πŸŽ‰ 2048 in your terminal
Stars: ✭ 777 (+3600%)
Mutual labels:  cli, game
Ratelimit
Simple utility for only executing code every so often.
Stars: ✭ 918 (+4271.43%)
Mutual labels:  tvos, watchos
Difference
Simple way to identify what is different between 2 instances of any type. Must have for TDD.
Stars: ✭ 837 (+3885.71%)
Mutual labels:  tvos, watchos
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (+2952.38%)
Mutual labels:  tvos, watchos
Flint
The Flint framework for building apps on Apple platforms using Feature Driven Development
Stars: ✭ 636 (+2928.57%)
Mutual labels:  tvos, watchos
Samkeychain
Simple Objective-C wrapper for the keychain that works on Mac and iOS
Stars: ✭ 5,389 (+25561.9%)
Mutual labels:  tvos, watchos
Apprepositorytemplate
The easiest way to start a new application project without any manual configuration
Stars: ✭ 24 (+14.29%)
Mutual labels:  tvos, watchos
Sdwebimageswiftui
SwiftUI Image loading and Animation framework powered by SDWebImage
Stars: ✭ 844 (+3919.05%)
Mutual labels:  tvos, watchos
Flexibleimage
A simple way to play with the image!
Stars: ✭ 798 (+3700%)
Mutual labels:  tvos, watchos
Procedurekit
Advanced Operations in Swift
Stars: ✭ 863 (+4009.52%)
Mutual labels:  tvos, watchos
Countly Sdk Ios
Countly Product Analytics iOS SDK with macOS, watchOS and tvOS support.
Stars: ✭ 585 (+2685.71%)
Mutual labels:  tvos, watchos
Ouzel
C++ game engine for Windows, macOS, Linux, iOS, tvOS, Android, and web browsers
Stars: ✭ 607 (+2790.48%)
Mutual labels:  game, tvos

Life

Build status Swift Package Manager All platforms Twitter: @zntfdr

Welcome to Life, a Swift implementation of Conway's Game of Life.

Usage

Life has two main entitites, World and Cell:

  • World represents the game space, which is a two-dimensional orthogonal grid of square cells, it also keeps track of the current alive cells generation.

  • Cell represents a specific cell in the world.

import Life

// Create a World instance.
var world = try World(rows: rows, columns: columns)

// Add alive cells.
world.add(Cell(row: .., column: ..))
world.add(Cell(row: .., column: ..))
...

// Spawn the next world generations.
world.spawnNextGeneration()
world.spawnNextGeneration()
...

A World instance only remembers the current alive generation, which is accessible via the aliveCells property.

At any moment new alive cells can be added, and old alive cells can be removed, to do so use the add(_:) and remove(_:) World instance methods.

Lastly, World exposes an isCellAlive(_:) instance method to check whether the specified cell is part of the current generation.

You can find many more examples in the Tests folder.

Game modes

Life comes in two modes: Simple and Loop.

The mode is specified when creating a new World instance (the default mode is .simple):

var world = try World(rows: rows, columns: columns, mode: .loop)
Simple Loop
Any cell outside of the world edges is considered dead. The world left and right edges are stitched together, the world top and bottom edges are stitched together.

Installation

Life is distributed using the Swift Package Manager. To install it into a project, follow this tutorial and use this repository URL: https://github.com/zntfdr/Life.git.

Command Line Tool

life in action

Life also comes with a command line tool that showcases its functionality.

To install it, clone the project and run make:

$ git clone https://github.com/zntfdr/Life.git
$ cd Life
$ make

Credits

Life was built by Federico Zanetello.

Contributions and Support

All users are welcome and encouraged to become active participants in the project continued development β€” by fixing any bug that they encounter, or by improving the documentation wherever it’s found to be lacking.

If you'd like to make a change, please open a Pull Request, even if it just contains a draft of the changes you’re planning, or a test that reproduces an issue.

Thank you and please enjoy using Life!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].