Last active
February 14, 2018 16:28
-
-
Save banksean/ed8729928cd788b466eb51dce20e6051 to your computer and use it in GitHub Desktop.
This file contains 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
// ScoreAtConditional uses a series of conditional checks to determine what a | |
// particular square's score multiplier is. | |
func ScoreAtConditional(x, y int) ScoreType { | |
// Symmetric adjustments if x or y > 7 to simplify checks below. | |
if x > 7 { | |
x = 14 - x | |
} | |
if y > 7 { | |
y = 14 - y | |
} | |
if x == y { | |
if x == 0 { | |
return TW | |
} | |
if x > 0 && x < 5 { | |
return DW | |
} | |
if x == 5 { | |
return TL | |
} | |
if x == 6 { | |
return DL | |
} | |
if x == 7 { | |
return DW | |
} | |
} | |
symCheck := func(a, b int) bool { | |
return x == a && y == b || x == b && y == a | |
} | |
switch { | |
case symCheck(0, 3) || symCheck(2, 6) || symCheck(3, 7): | |
return DL | |
case symCheck(0, 7): | |
return TW | |
case symCheck(1, 5): | |
return TL | |
case symCheck(3, 7): | |
return DW | |
} | |
return None | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment