Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type scoreInt uint64
- var (
- // If you think I came up with these values by hand... LOL
- //
- // Each bit in a value represents the presence or absence
- // of a score multiplier in the 8x8 upper-left corner of
- // the board.
- TWInt = scoreInt(0x8000000000000081)
- DWInt = scoreInt(0x100000810204000)
- TLInt = scoreInt(0x440000000400)
- DLInt = scoreInt(0x1022000081020010)
- NoneInt = scoreInt(0x6eddbbf76eddbb6e)
- )
- // ScoreAtInt uses Fanciness to return the score multiplier at x, y.
- func ScoreAtInt(x, y int) ScoreType {
- // [adjustments for x or y > 7 omitted for brevity...]
- // Now THIS is why I studied CS!!!!!!1010110110 amirite?
- mask := scoreInt(1 << (uint(y)*8 + uint(7-x)))
- // These switch cases are ordered such that the more
- // common cases should return earlier than the less common,
- // leading to fewer checks overall.
- switch {
- case NoneInt&mask > 0:
- return None
- case DLInt&mask > 0:
- return DL
- case DWInt&mask > 0:
- return DW
- case TLInt&mask > 0:
- return TL
- case TWInt&mask > 0:
- return TW
- }
- return None // Should not happen, but 0xIDGAF
- }
Add Comment
Please, Sign In to add comment