This file contains hidden or 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
enum Empire { | |
case britain | |
case france | |
case germany | |
case russia | |
case ottoman | |
case austria | |
case italy | |
} | |
enum CoastKind{ |
This file contains hidden or 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
class Board { | |
var territories: [Territory] | |
let borders:[Border] | |
enum Change { | |
case move(Move) | |
case hold(Territory, with:Unit, of:Empire) | |
enum Move{ | |
case army(of:Empire, from:Territory, to:Territory) | |
case fleet(of:Empire, from:Territory, to:Territory) | |
} |
This file contains hidden or 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
let clyde = Territory(name:"Clyde" , kind:.land) | |
let edinburgh = Territory(name:"Edinburgh", kind:.land) | |
let liverpool = Territory(name:"Liverpool", kind:.land) | |
let yorkshire = Territory(name:"Yorkshire", kind:.land) | |
let wales = Territory(name:"Wales" , kind:.land) | |
let london = Territory(name:"London" , kind:.land) | |
let gb = [ clyde, edinburgh, liverpool, yorkshire, wales, london ] |
This file contains hidden or 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
let brest = Territory(name:"Brest" , kind:.land) | |
let picardy = Territory(name:"Picardy" , kind:.land) | |
let paris = Territory(name:"Paris" , kind:.land) | |
let gascony = Territory(name:"Gascony" , kind:.land) | |
let burgundy = Territory(name:"Burgundy" , kind:.land) | |
let marseilles = Territory(name:"Marseilles", kind:.land) | |
let france = [ brest, picardy, paris, gascony, burgundy, marseilles] |
This file contains hidden or 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
let connectionsGB: [Border] = [ | |
.land(clyde, edinburgh), | |
.land(clyde, liverpool), | |
.land(edinburgh, liverpool), | |
.land(edinburgh, yorkshire), | |
.land(yorkshire, wales ), | |
.land(yorkshire, london ), | |
] | |
let connectionsFrance: [Border] = [ | |
.land(brest, picardy ), |
This file contains hidden or 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
let b = Board(territories:territories, borders:borders) | |
print(board:b); | |
b.execute( .move( .army(of:.germany,from:berlin, to:silesia)) ) | |
b.execute( .move( .army(of:.germany,from:ruhr, to:holland)) ) | |
b.execute( .move(.fleet(of:.britain,from:midatlantic, | |
to:westernmediterrean)) ) | |
b.execute( .move( .army(of:.germany,from:silesia, to:galicia)) ) | |
b.execute( .move( .army(of:.germany,from:holland, to:belgium)) ) | |
b.execute( .move(.fleet(of:.britain,from:westernmediterrean, |
This file contains hidden or 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
Ruhr (army: germany) | |
Berlin (army: germany) | |
Mid-Atlantic (fleet: britain) | |
------ |
This file contains hidden or 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
Constantinople (army: germany) | |
Belgium (army: germany) | |
Aegean Sea (fleet: britain) | |
------ |
This file contains hidden or 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
// MARK: - Tape | |
enum Value <T:Equatable>: Equatable { case value(T), unset } | |
typealias Step = () -> () | |
typealias Read<T:Equatable> = () -> Value<T> | |
typealias Write<T:Equatable> = (T?) -> () | |
typealias Tape<T:Equatable> = (stepBack:Step, stepForward:Step, read:Read<T>, write:Write<T>, print:() -> ()) | |
struct TapeState<T:Equatable> { | |
enum Change { | |
case cursor(Cursor) |
This file contains hidden or 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
roothandler( .lighting(.change(.display(.slider), on:light)) ) |