Skip to content

Instantly share code, notes, and snippets.

@banksean
Last active February 14, 2018 16:33
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/c7c8fb592dfbfb5454810211f7004fc7 to your computer and use it in GitHub Desktop.
Save banksean/c7c8fb592dfbfb5454810211f7004fc7 to your computer and use it in GitHub Desktop.
// I was going to use slices, but hey I'm lazy why not let the compiler
// verify that I put the right number rows and columns in?
type literalBoard [8][8]ScoreType
var (
LiteralBoard = literalBoard{
{TW, None, None, DL, None, None, None, TW},
{None, DW, None, None, None, TL, None, None},
{None, None, DW, None, None, None, DL, None},
{DL, None, None, DW, None, None, None, DL},
{None, None, None, None, DW, None, None, None},
{None, TL, None, None, None, TL, None, None},
{None, None, DL, None, None, None, DL, None},
{TW, None, None, DL, None, None, None, DW},
}
)
// ScoreAtLiteral uses the method you were thinking of all along
// to return the score multiplier at x, y.
func ScoreAtLiteral(x, y int) ScoreType {
// Symmetric adjustments if x or y > 7. We could
// eliminate these by making LiteralBoard be 15x15
// but YOLO.
if x > 7 {
x = 14 - x
}
if y > 7 {
y = 14 - y
}
return LiteralBoard[y][x]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment