35 lines
688 B
Swift
35 lines
688 B
Swift
//
|
|
// LifeWikiPattern.swift
|
|
// LifeGameApp
|
|
//
|
|
// Created by Yusuke Hosonuma on 2020/09/18.
|
|
//
|
|
|
|
import Foundation
|
|
import LifeGame
|
|
|
|
struct LifeWikiPattern: Codable, Identifiable {
|
|
let title: String
|
|
let patternType: String
|
|
let rule: String
|
|
let discoveredBy: String
|
|
let yearOfDiscovery: String
|
|
let width: Int
|
|
let height: Int
|
|
let cells: [Int]
|
|
let sourceURL: URL
|
|
|
|
var id: String {
|
|
sourceURL.absoluteString.md5
|
|
}
|
|
|
|
func makeBoard() -> Board<Cell> {
|
|
Board(
|
|
width: width,
|
|
height: height,
|
|
cells: cells.map{ $0 == 0 ? Cell.die : Cell.alive },
|
|
blank: Cell.die
|
|
)
|
|
}
|
|
}
|