Files
Yusuke Hosonuma 275f8f321f refactor: package
2022-04-27 13:49:36 +09:00

54 lines
1.8 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// BoardExample.swift
// LifeGameApp
//
// Created by Yusuke Hosonuma on 2020/08/25.
//
import LifeGame
// Note:
// Widget
// Widget
public enum BoardExample: CaseIterable {
public struct Data {
public var title: String
public var board: Board<Cell>
}
case butterfly
case cross
case monolith
case nebura
public var data: Data {
switch self {
case .butterfly:
return Data(
title: "Butterfly",
board: Board(size: 4, cells: cells([1,0,0,0,1,1,0,0,1,0,1,0,0,1,1,1]))
)
case .cross:
return Data(
title: "Cross",
board: Board(size: 8, cells: cells([0,0,1,1,1,1,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,0,0,1,1,1,1,0,0]))
)
case .monolith:
return Data(
title: "Monolith",
board: Board(size: 11, cells: cells([1,1,0,1,1,0,1,1,0,1,1,1,1,0,1,1,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,1,1,1,1,0,1,1,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,1,1,1,1,0,1,1,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,1,1,1,1,0,1,1,0,1,1,0,1,1]))
)
case .nebura:
return Data(
title: "Nebura",
board: Board(size: 9, cells: cells([1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1]))
)
}
}
private func cells(_ rawCells: [Int]) -> [Cell] {
rawCells.map { $0 == 1 ? Cell.alive : Cell.die }
}
}