Save each game for Debugging
This commit is contained in:
@@ -66,7 +66,7 @@ class Game(
|
||||
|
||||
companion object {
|
||||
fun parse(description: String): Game {
|
||||
val optionsRegex = Regex("[A-Z]+(_[A-Z]+)*")
|
||||
val optionsRegex = Regex("[A-Z]+(?:_[A-Z]+)*")
|
||||
val options = optionsRegex.findAll(description)
|
||||
.map { it.value }
|
||||
.distinct()
|
||||
|
||||
@@ -92,7 +92,7 @@ class NeighbourClue<A : ItemClass<A>, B : ItemClass<B>>(val a: Item<A>, val b: I
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex = Regex("^(\\* )?(?<a>[A-Z_]+) is next to (?<b>[A-Z_]+)$")
|
||||
val regex = Regex("^(?:\\* )?(?<a>[A-Z_]+) is next to (?<b>[A-Z_]+)$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val a = ItemClass.parse(matchResult.groups["a"]!!.value)
|
||||
@@ -154,7 +154,7 @@ class OrderClue<L : ItemClass<L>, R : ItemClass<R>>(val left: Item<L>, val right
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex = Regex("^(\\* )?(?<left>[A-Z_]+) is left of (?<right>[A-Z_]+)$")
|
||||
val regex = Regex("^(?:\\* )?(?<left>[A-Z_]+) is left of (?<right>[A-Z_]+)$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val left = ItemClass.parse(matchResult.groups["left"]!!.value)
|
||||
@@ -299,7 +299,7 @@ class TripletClue<A : ItemClass<A>, B : ItemClass<B>, C : ItemClass<C>>(
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex =
|
||||
Regex("^(\\* )?(?<b>[A-Z_]+) is between the neighbours (?<a>[A-Z_]+) and (?<c>[A-Z_]+) to both sides$")
|
||||
Regex("^(?:\\* )?(?<b>[A-Z_]+) is between the neighbours (?<a>[A-Z_]+) and (?<c>[A-Z_]+) to both sides$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val a = ItemClass.parse(matchResult.groups["a"]!!.value)
|
||||
@@ -364,7 +364,7 @@ class SameColumnClue<A : ItemClass<A>, B : ItemClass<B>>(val a: Item<A>, val b:
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex = Regex("^(\\* )?(?<a>[A-Z_]+) and (?<b>[A-Z_]+) are in the same column$")
|
||||
val regex = Regex("^(?:\\* )?(?<a>[A-Z_]+) and (?<b>[A-Z_]+) are in the same column$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val a = ItemClass.parse(matchResult.groups["a"]!!.value)
|
||||
@@ -408,7 +408,7 @@ class PositionClue<C : ItemClass<C>>(val item: Item<C>, val index: Int) : Clue()
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex = Regex("^(\\* )?(?<type>[A-Z_]+) is at position (?<pos>\\d)$")
|
||||
val regex = Regex("^(?:\\* )?(?<type>[A-Z_]+) is at position (?<pos>\\d)$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val type = ItemClass.parse(matchResult.groups["type"]!!.value)
|
||||
|
||||
Reference in New Issue
Block a user