Skip to content

Instantly share code, notes, and snippets.

@zsoltk
Last active July 31, 2021 18:39
Show Gist options
  • Save zsoltk/f6d25f1fcbe07419d54aac4d4a193858 to your computer and use it in GitHub Desktop.
Save zsoltk/f6d25f1fcbe07419d54aac4d4a193858 to your computer and use it in GitHub Desktop.
@Parcelize
object KnightsMoveCount : DatasetVisualisation {
override val name = R.string.viz_knight_move_count
override val minValue: Int = 2
override val maxValue: Int = 8
override fun dataPointAt(position: Position, state: GameSnapshotState): Datapoint {
val value = valueAt(position)
return Datapoint(
value = value,
label = value.toString(),
colorScale = Color.DarkGray to Color.Green
)
}
private fun valueAt(position: Position): Int =
when(position) {
a1 -> 2
b1 -> 3
c1 -> 4
d1 -> 4
e1 -> 4
f1 -> 4
g1 -> 3
h1 -> 2
// ... etc.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment