Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
layout: post | ||
title: Fizz Buzz with GameplayKit | ||
categories: [] | ||
tags: [] | ||
published: True | ||
|
||
--- | ||
|
||
A great idea found at http://www.knowing.net/index.php/2015/08/04/fizzbuzz-with-ios-9-gameplaykit-expert-system-in-c-with-xam-ios and backported to swift. | ||
|
||
[Fizz buzz](https://en.wikipedia.org/wiki/Fizz_buzz) is a simple game. GameplayKit makes it very easy to describe the rules. There is a vast place for improvement when working with state untyped dictionary. It can definitely use some swiftification. Here is the code: | ||
|
||
{% gist zats/0ad1dac35e75587da7e0 fizzbuzz.swift %} | ||
|
||
Output is | ||
|
||
``` | ||
1 | ||
2 | ||
fizz | ||
4 | ||
buzz | ||
fizz | ||
7 | ||
8 | ||
fizz | ||
buzz | ||
11 | ||
fizz | ||
13 | ||
14 | ||
fizz buzz | ||
16 | ||
... | ||
``` | ||
|
||
I'm looking forward to seeing frameworks emerging on top of GameplayKit. |