Skip to content

Commit

Permalink
Use default values for non-set board size and minimum word lengths in…
Browse files Browse the repository at this point in the history
… simulation
  • Loading branch information
tamaracha committed Jan 29, 2019
1 parent 5738be7 commit f5094b1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/HangmanCLI/Simulation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ extension Begriffix {
let vocabulary = try? condition.vocabulary.load()
guard let board = BegriffixBoard(condition: condition) else {return nil}
let players = DyadicPlayers<Begriffix>(starter: starter.move, opponent: opponent.move)
guard condition.hasWordMinLength else {
self.init(board: board, players: players, vocabulary: vocabulary)
return
}
let minWordLength = (
restricted: Int(condition.wordMinLength.restricted),
liberal: Int(condition.wordMinLength.liberal)
Expand All @@ -74,6 +78,10 @@ extension Begriffix {

extension BegriffixBoard {
init?(condition: SGSimulation.Condition) {
guard condition.boardSize >= 2 else{
try? self.init(startLetters: condition.startLetters)
return
}
try? self.init(startLetters: condition.startLetters, sideLength: Int(condition.boardSize))
}
}
Expand Down

0 comments on commit f5094b1

Please sign in to comment.