Skip to content

Instantly share code, notes, and snippets.

@zsoltk
Created July 28, 2021 07:53
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 zsoltk/ac2d746f7690254684c8b96efa181fe1 to your computer and use it in GitHub Desktop.
Save zsoltk/ac2d746f7690254684c8b96efa181fe1 to your computer and use it in GitHub Desktop.
override fun dataPointAt(position: Position, state: GameSnapshotState): Datapoint? =
valueAt(position, state)?.let { value ->
Datapoint(
value = value,
label = null,
colorScale = when (value) {
0 -> Color.Red.copy(alpha = 0.35f) to Color.Unspecified
else -> Color.Unspecified to Color.Unspecified
},
)
}
private fun valueAt(position: Position, state: GameSnapshotState): Int? =
when {
state.board[position].isEmpty -> null
else -> state.legalMovesFrom(position).size
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment