Skip to content

Instantly share code, notes, and snippets.

@banksean
Last active February 14, 2018 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banksean/ed8729928cd788b466eb51dce20e6051 to your computer and use it in GitHub Desktop.
Save banksean/ed8729928cd788b466eb51dce20e6051 to your computer and use it in GitHub Desktop.
// 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