Android: games against Maia (small model, no clocks)
«Play with Maia» on the Databases screen and «Play on from here with Maia…» in the move sheet: the strength (1100–1800), colour and name; Maia's 21 MB downloaded there. The game is a mode of the game screen: Maia answers after a person's pause (shared rules), take back, resign or abort, Maia's offer to resign judged by Stockfish when it is there; the end card offers analysis, rematch and saving. The game is written after each move: «back» puts it aside, the Databases screen offers to go on with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
57cc4b2360
commit
66f86ae3e5
21 changed files with 1377 additions and 24 deletions
|
|
@ -10,6 +10,7 @@ import io.github.vrubelroman.chesspenguin.data.AppUpdates
|
|||
import io.github.vrubelroman.chesspenguin.data.DbEntry
|
||||
import io.github.vrubelroman.chesspenguin.data.EngineFiles
|
||||
import io.github.vrubelroman.chesspenguin.data.MaiaFiles
|
||||
import io.github.vrubelroman.chesspenguin.data.MaiaGames
|
||||
import io.github.vrubelroman.chesspenguin.data.Library
|
||||
import io.github.vrubelroman.chesspenguin.data.OnlineDownloads
|
||||
import io.github.vrubelroman.chesspenguin.data.Settings
|
||||
|
|
@ -33,6 +34,8 @@ class ChessPenguinApp : Application() {
|
|||
val engineFiles by lazy { EngineFiles(this, scope) }
|
||||
/// Maia's weights, downloaded on request (android-play.md §31).
|
||||
val maiaFiles by lazy { MaiaFiles(this, scope) }
|
||||
/// The game against Maia in hand (android-play.md §31.7).
|
||||
val maiaGames by lazy { MaiaGames(this) }
|
||||
/// Games from Lichess and Chess.com being downloaded (android-ui.md §23).
|
||||
val downloads by lazy { OnlineDownloads(library, scope) }
|
||||
/// The app's own updates (android-ui.md §25).
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import io.github.vrubelroman.chesspenguin.ui.DatabasesScreen
|
|||
import io.github.vrubelroman.chesspenguin.ui.SettingsScreen
|
||||
import io.github.vrubelroman.chesspenguin.ui.GameScreen
|
||||
import io.github.vrubelroman.chesspenguin.ui.NEW_GAME
|
||||
import io.github.vrubelroman.chesspenguin.ui.PLAY_GAME
|
||||
import io.github.vrubelroman.chesspenguin.ui.GamesScreen
|
||||
import io.github.vrubelroman.chesspenguin.ui.OnlineScreen
|
||||
import kotlinx.serialization.Serializable
|
||||
|
|
@ -55,6 +56,9 @@ import kotlinx.serialization.Serializable
|
|||
/// A new game from the start position (android-play.md §30.4).
|
||||
@Serializable data object NewGameKey : NavKey
|
||||
|
||||
/// The game against Maia in hand (android-play.md §31).
|
||||
@Serializable data object PlayKey : NavKey
|
||||
|
||||
@Serializable data object SettingsKey : NavKey
|
||||
|
||||
@Serializable data object AboutKey : NavKey
|
||||
|
|
@ -119,16 +123,23 @@ fun MainNavigation() {
|
|||
onSettings = { backStack.add(SettingsKey) },
|
||||
onOnline = { backStack.add(OnlineKey) },
|
||||
onNewGame = { backStack.add(NewGameKey) },
|
||||
onPlay = { backStack.add(PlayKey) },
|
||||
)
|
||||
}
|
||||
entry<NewGameKey> {
|
||||
GameScreen(NEW_GAME, 0, "", onBack = { backStack.removeLastOrNull() }, onSettings = { backStack.add(SettingsKey) })
|
||||
GameScreen(NEW_GAME, 0, "", onBack = { backStack.removeLastOrNull() }, onSettings = { backStack.add(SettingsKey) }, onPlayGame = { backStack.add(PlayKey) })
|
||||
}
|
||||
entry<PlayKey> {
|
||||
GameScreen(PLAY_GAME, 0, "", onBack = { backStack.removeLastOrNull() }, onSettings = { backStack.add(SettingsKey) }, onPlayGame = {
|
||||
backStack.removeLastOrNull()
|
||||
backStack.add(PlayKey)
|
||||
})
|
||||
}
|
||||
entry<Games> { key ->
|
||||
GamesScreen(key.db, onBack = { backStack.removeLastOrNull() }, onGame = { place, query -> backStack.add(GameAt(key.db, place, query)) })
|
||||
}
|
||||
entry<GameAt> { key ->
|
||||
GameScreen(key.db, key.place, key.query, onBack = { backStack.removeLastOrNull() }, onSettings = { backStack.add(SettingsKey) })
|
||||
GameScreen(key.db, key.place, key.query, onBack = { backStack.removeLastOrNull() }, onSettings = { backStack.add(SettingsKey) }, onPlayGame = { backStack.add(PlayKey) })
|
||||
}
|
||||
entry<SettingsKey> {
|
||||
SettingsScreen(
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ data class FileSpec(
|
|||
class CheckedDownload(private val context: Context, private val scope: CoroutineScope, private val spec: FileSpec) {
|
||||
private val dir = File(context.filesDir, spec.dir)
|
||||
val file = File(dir, spec.name)
|
||||
val size: Long get() = spec.size
|
||||
private val part = File(dir, spec.name + ".part")
|
||||
private val prefs = context.getSharedPreferences(spec.prefs, Context.MODE_PRIVATE)
|
||||
private val downloads get() = context.getSystemService(DownloadManager::class.java)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
package io.github.vrubelroman.chesspenguin.data
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import java.io.File
|
||||
|
||||
/// A game against Maia: her strength, the user's colour and name; `floor`: the half-moves
|
||||
/// that came from another game ("Play on from here", not taken back); `over`: it ended.
|
||||
data class PlayMeta(val strength: Int, val userWhite: Boolean, val name: String, val floor: Int, val over: Boolean = false)
|
||||
|
||||
/// The game against Maia being played (android-play.md §31.7): its PGN is written after
|
||||
/// every move, so that "back" puts it aside and it outlives the app being closed. One at
|
||||
/// a time.
|
||||
class MaiaGames(context: Context) {
|
||||
private val file = File(context.filesDir, "play/current.pgn")
|
||||
private val prefs = context.getSharedPreferences("play", Context.MODE_PRIVATE)
|
||||
private val _current = MutableStateFlow(read())
|
||||
/// The game in hand, if any.
|
||||
val current: StateFlow<PlayMeta?> = _current.asStateFlow()
|
||||
|
||||
private fun read(): PlayMeta? {
|
||||
if (!file.isFile || !prefs.contains("strength")) return null
|
||||
return PlayMeta(
|
||||
strength = prefs.getInt("strength", 1500),
|
||||
userWhite = prefs.getBoolean("white", true),
|
||||
name = prefs.getString("name", "") ?: "",
|
||||
floor = prefs.getInt("floor", 0),
|
||||
over = prefs.getBoolean("over", false),
|
||||
)
|
||||
}
|
||||
|
||||
/// The PGN of the game in hand.
|
||||
fun pgn(): String? = runCatching { file.readText() }.getOrNull()
|
||||
|
||||
/// A new game: it replaces the one in hand.
|
||||
fun begin(pgn: String, meta: PlayMeta) {
|
||||
write(pgn)
|
||||
prefs.edit()
|
||||
.putInt("strength", meta.strength)
|
||||
.putBoolean("white", meta.userWhite)
|
||||
.putString("name", meta.name)
|
||||
.putInt("floor", meta.floor)
|
||||
.putBoolean("over", meta.over)
|
||||
.apply()
|
||||
_current.value = meta
|
||||
}
|
||||
|
||||
/// The game after a move.
|
||||
fun save(pgn: String) {
|
||||
if (_current.value != null) write(pgn)
|
||||
}
|
||||
|
||||
/// The game ended: it is not offered to go on with any more.
|
||||
fun finish(pgn: String) {
|
||||
save(pgn)
|
||||
prefs.edit().putBoolean("over", true).apply()
|
||||
_current.value = _current.value?.copy(over = true)
|
||||
}
|
||||
|
||||
/// The game is gone (left after its end, removed by the user).
|
||||
fun clear() {
|
||||
file.delete()
|
||||
prefs.edit().clear().apply()
|
||||
_current.value = null
|
||||
}
|
||||
|
||||
/// Written beside and moved in: a cut-off write leaves the last move's game whole.
|
||||
private fun write(pgn: String) {
|
||||
file.parentFile?.mkdirs()
|
||||
val tmp = File(file.path + ".tmp")
|
||||
tmp.writeText(pgn)
|
||||
if (!tmp.renameTo(file)) {
|
||||
file.writeText(pgn)
|
||||
tmp.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -39,19 +39,25 @@ class ReviewSession(private val cacheDir: String, private val scope: CoroutineSc
|
|||
|
||||
/// Shows the analysis of game `index` of database `db` (from the cache or its
|
||||
/// `[%eval]` comments); the analysis of the game before is stopped and kept.
|
||||
suspend fun open(db: String, database: Database, index: UInt) {
|
||||
if (game == db to index) return
|
||||
suspend fun open(db: String, database: Database, index: UInt) = openWith(db to index) { database.review(index, cacheDir) }
|
||||
|
||||
/// The analysis of a game being changed or played (no file of its own), as it is
|
||||
/// now; `stamp` names this state of it (a new stamp: the game changed).
|
||||
suspend fun openSession(stamp: String, session: uniffi.mobile_api.GameSession) = openWith("session" to stamp.hashCode().toUInt()) { session.review(cacheDir) }
|
||||
|
||||
private suspend fun openWith(key: Pair<String, UInt>, make: () -> GameReview) {
|
||||
if (game == key) return
|
||||
val gen = ++generation
|
||||
_state.value = null
|
||||
lock.withLock {
|
||||
closeLocked()
|
||||
val r = withContext(Dispatchers.IO) { runCatching { database.review(index, cacheDir) }.getOrNull() } ?: return
|
||||
val r = withContext(Dispatchers.IO) { runCatching { make() }.getOrNull() } ?: return
|
||||
if (gen != generation) {
|
||||
withContext(Dispatchers.IO) { r.close() }
|
||||
return
|
||||
}
|
||||
review = r
|
||||
game = db to index
|
||||
game = key
|
||||
_state.value = withContext(Dispatchers.IO) { r.state() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,13 @@ data class Prefs(
|
|||
/// The engine's speed per thread measured by the last game analysis (0 = not yet),
|
||||
/// for the time estimate.
|
||||
val reviewNps: Long = 0,
|
||||
/// The last choices of a game against Maia (android-play.md §31.1): her strength,
|
||||
/// the user's colour (-1 Black, 0 at random, 1 White), the user's name.
|
||||
val maiaStrength: Int = 1500,
|
||||
val maiaColor: Int = 0,
|
||||
val yourName: String = "",
|
||||
/// Sounds of moves and of the end of a game (§33).
|
||||
val sound: Boolean = true,
|
||||
)
|
||||
|
||||
/// Half the cores, at most 2: the engine leaves the phone's interface room (§9).
|
||||
|
|
@ -65,6 +72,10 @@ class Settings(context: Context) {
|
|||
engineHashMb = store.getInt("engineHashMb", d.engineHashMb),
|
||||
reviewQuality = store.getInt("reviewQuality", d.reviewQuality).coerceIn(0, REVIEW_NODES.size - 1),
|
||||
reviewNps = store.getLong("reviewNps", d.reviewNps),
|
||||
maiaStrength = store.getInt("maiaStrength", d.maiaStrength),
|
||||
maiaColor = store.getInt("maiaColor", d.maiaColor).coerceIn(-1, 1),
|
||||
yourName = store.getString("yourName", d.yourName) ?: d.yourName,
|
||||
sound = store.getBoolean("sound", d.sound),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -85,6 +96,10 @@ class Settings(context: Context) {
|
|||
.putInt("engineHashMb", p.engineHashMb)
|
||||
.putInt("reviewQuality", p.reviewQuality)
|
||||
.putLong("reviewNps", p.reviewNps)
|
||||
.putInt("maiaStrength", p.maiaStrength)
|
||||
.putInt("maiaColor", p.maiaColor)
|
||||
.putString("yourName", p.yourName)
|
||||
.putBoolean("sound", p.sound)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ import kotlinx.coroutines.withContext
|
|||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.Add
|
||||
import androidx.compose.material.icons.rounded.EditNote
|
||||
import androidx.compose.material.icons.rounded.Close
|
||||
import androidx.compose.material.icons.rounded.SmartToy
|
||||
import androidx.compose.material.icons.rounded.MoreVert
|
||||
import androidx.compose.material.icons.rounded.Settings
|
||||
import androidx.compose.material3.AlertDialog
|
||||
|
|
@ -89,7 +91,7 @@ import kotlinx.coroutines.launch
|
|||
/// The first screen: the databases on the list (android-ui.md §3).
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSettings: () -> Unit, onOnline: () -> Unit, onNewGame: () -> Unit) {
|
||||
fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSettings: () -> Unit, onOnline: () -> Unit, onNewGame: () -> Unit, onPlay: () -> Unit) {
|
||||
val library = app().library
|
||||
val downloads = app().downloads
|
||||
val views by downloads.views.collectAsState()
|
||||
|
|
@ -171,6 +173,20 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett
|
|||
}
|
||||
}
|
||||
val own = entries.filter { it.source == Source.Own }
|
||||
val theApp = app()
|
||||
val adjourned by theApp.maiaGames.current.collectAsState()
|
||||
val playRemovedText = stringResource(R.string.play_removed)
|
||||
var playing by remember { mutableStateOf(false) }
|
||||
val eventText = stringResource(R.string.play_event)
|
||||
if (playing) {
|
||||
PlaySheet(null, onPlay = { strength, white, name ->
|
||||
playing = false
|
||||
val s = uniffi.mobile_api.GameSession.newGame("")
|
||||
beginMaiaGame(theApp, s, strength, white, name, 0, eventText, null)
|
||||
s.close()
|
||||
onPlay()
|
||||
}, onDismiss = { playing = false })
|
||||
}
|
||||
val files = entries.filter { it.source != Source.Own }
|
||||
val list = rememberLazyListState()
|
||||
// The card comes when GitHub answers, after the list is drawn: a list at its top then
|
||||
|
|
@ -229,8 +245,41 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett
|
|||
) {
|
||||
// A newer version of the app (android-ui.md §25.2): the first item of the list.
|
||||
update?.let { u -> item(key = "update") { UpdateCard(u, onDismissed = onUpdateDismissed, modifier = Modifier.animateItem()) } }
|
||||
// A game against Maia put aside (§31.7): go on with it, or let it go.
|
||||
adjourned?.takeIf { !it.over }?.let { m ->
|
||||
item(key = "adjourned") {
|
||||
Row(
|
||||
Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 4.dp)
|
||||
.background(MaterialTheme.colorScheme.secondaryContainer, RoundedCornerShape(12.dp))
|
||||
.padding(start = 16.dp, end = 4.dp, top = 4.dp, bottom = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
stringResource(R.string.play_adjourned, m.strength.toString(), stringResource(if (m.userWhite) R.string.play_as_white else R.string.play_as_black)),
|
||||
Modifier.weight(1f),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
TextButton(onClick = onPlay) { Text(stringResource(R.string.play_continue)) }
|
||||
IconButton(onClick = {
|
||||
val pgn = theApp.maiaGames.pgn()
|
||||
theApp.maiaGames.clear()
|
||||
scope.launch {
|
||||
snackbar.currentSnackbarData?.dismiss()
|
||||
if (snackbar.showSnackbar(playRemovedText, undoText, duration = SnackbarDuration.Long) == SnackbarResult.ActionPerformed && pgn != null) {
|
||||
theApp.maiaGames.begin(pgn, m)
|
||||
}
|
||||
}
|
||||
}) { Icon(Icons.Rounded.Close, stringResource(R.string.close)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
item(key = "actions") {
|
||||
Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
FilledTonalButton(onClick = { playing = true }, modifier = Modifier.height(48.dp)) {
|
||||
Icon(Icons.Rounded.SmartToy, null)
|
||||
Spacer(Modifier.size(8.dp))
|
||||
Text(stringResource(R.string.play_with_maia))
|
||||
}
|
||||
FilledTonalButton(onClick = onNewGame, modifier = Modifier.height(48.dp)) {
|
||||
Icon(Icons.Rounded.Add, null)
|
||||
Spacer(Modifier.size(8.dp))
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import androidx.compose.material.icons.rounded.ChevronLeft
|
|||
import androidx.compose.material.icons.rounded.Close
|
||||
import androidx.compose.material.icons.rounded.Save
|
||||
import androidx.compose.material.icons.rounded.School
|
||||
import androidx.compose.material.icons.rounded.SmartToy
|
||||
import androidx.compose.material.icons.rounded.VerticalAlignTop
|
||||
import androidx.compose.material.icons.rounded.ChevronRight
|
||||
import androidx.compose.material.icons.rounded.Download
|
||||
|
|
@ -136,7 +137,7 @@ private data class Preview(val line: EngineLine, val step: Int, val best: Boolea
|
|||
/// under the thumb; ‹ › page the games of the list (android-ui.md §7).
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, onSettings: () -> Unit) {
|
||||
fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, onSettings: () -> Unit, onPlayGame: () -> Unit = {}) {
|
||||
val app = app()
|
||||
val context = LocalContext.current
|
||||
val prefs by app.settings.prefs.collectAsState()
|
||||
|
|
@ -150,6 +151,9 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
var game by held.data
|
||||
var edit by held.session
|
||||
val newGame = db == NEW_GAME
|
||||
// The game against Maia in hand (android-play.md §31).
|
||||
val playGame = db == PLAY_GAME
|
||||
val run = held.play.value
|
||||
// Learning the opening of this game: its own screen over the game (§32).
|
||||
held.trainer.value?.let { t ->
|
||||
TrainScreen(t, held.trainPly, held.trainFlipped, onPly = { held.trainPly = it }, onExit = {
|
||||
|
|
@ -164,8 +168,32 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
var preview by remember { mutableStateOf<Preview?>(null) }
|
||||
// The game report (§21): its own engine job; the live engine rests while it runs.
|
||||
val review = remember { ReviewSession(java.io.File(context.cacheDir, "analysis").path, app.scope) }
|
||||
LaunchedEffect(db, place) {
|
||||
LaunchedEffect(db, place, held.reloads.intValue) {
|
||||
preview = null
|
||||
if (playGame) {
|
||||
if (held.key != PLAY_GAME) {
|
||||
val meta = app.maiaGames.current.value
|
||||
val pgn = app.maiaGames.pgn()
|
||||
if (meta == null || pgn == null) {
|
||||
failed = true
|
||||
return@LaunchedEffect
|
||||
}
|
||||
held.key = PLAY_GAME
|
||||
held.savedTo = null
|
||||
val s = GameSession.fromPgn(pgn)
|
||||
edit = s
|
||||
val d = s.data()
|
||||
game = d
|
||||
held.play.value?.close()
|
||||
held.play.value = PlayRun(meta).also { r ->
|
||||
// A game that ended before the app was closed: its end as it was.
|
||||
if (meta.over) r.over.value = PlayOver(d.result, if (d.result == "1/2-1/2") R.string.play_draw else if ((d.result == "1-0") == meta.userWhite) R.string.play_won else R.string.play_lost, null)
|
||||
}
|
||||
flipped = !meta.userWhite
|
||||
current = lineEnd(d)
|
||||
}
|
||||
return@LaunchedEffect
|
||||
}
|
||||
if (newGame) {
|
||||
if (held.key != NEW_GAME) {
|
||||
held.key = NEW_GAME
|
||||
|
|
@ -391,12 +419,123 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
}
|
||||
// The move sheet of a long press on a move (§29.6): which move.
|
||||
var moveSheet by remember { mutableStateOf<Int?>(null) }
|
||||
// «Play on from here» asked for at this move.
|
||||
var playFrom by remember { mutableStateOf<Int?>(null) }
|
||||
val deletedText = stringResource(R.string.moves_deleted)
|
||||
val undoText = stringResource(R.string.undo_action)
|
||||
fun undo() {
|
||||
edit?.undo()?.let { apply(it) }
|
||||
}
|
||||
|
||||
// ----- a game against Maia (§31) -----
|
||||
val runOver = run?.over?.value
|
||||
val runOffer = run?.offer?.value == true
|
||||
val runThinking = run?.thinking?.value == true
|
||||
val runFailure = run?.failure?.value
|
||||
val gameOn = run != null && runOver == null
|
||||
fun persist() {
|
||||
if (run != null) edit?.let { app.maiaGames.save(it.pgn()) }
|
||||
}
|
||||
fun finishGame(over: PlayOver) {
|
||||
val r = run ?: return
|
||||
val e = edit ?: return
|
||||
r.generation++
|
||||
r.thinking.value = false
|
||||
r.offer.value = false
|
||||
e.setData(listOf(uniffi.mobile_api.Tag("Termination", "Normal")), over.result)
|
||||
game = e.data().copy(notes = held.notes)
|
||||
r.over.value = over
|
||||
app.maiaGames.finish(e.pgn())
|
||||
}
|
||||
// After a move of either side: kept, and the end of the game if it came.
|
||||
fun afterMove(e: Edited) {
|
||||
val r = run ?: return
|
||||
persist()
|
||||
edit?.ending(e.cursor)?.let { finishGame(overBy(it, r.meta.userWhite)) }
|
||||
}
|
||||
// Maia's move when it is her turn: computed in the background, shown after her pause.
|
||||
LaunchedEffect(run, g, runOver, runOffer, runFailure) {
|
||||
val r = run ?: return@LaunchedEffect
|
||||
val gg = g ?: return@LaunchedEffect
|
||||
val e = edit ?: return@LaunchedEffect
|
||||
if (runOver != null || runOffer || runFailure != null) return@LaunchedEffect
|
||||
val end = lineEnd(gg)
|
||||
if (whiteToMove(gg.nodes[end].fen) == r.meta.userWhite) return@LaunchedEffect
|
||||
val gen = ++r.generation
|
||||
r.thinking.value = true
|
||||
try {
|
||||
val player = r.player ?: withContext(Dispatchers.IO) { runCatching { uniffi.mobile_api.MaiaPlayer.load(app.maiaFiles.download.file.path) } }
|
||||
.getOrElse { ex ->
|
||||
r.failure.value = ex.message ?: ""
|
||||
return@LaunchedEffect
|
||||
}.also { r.player = it }
|
||||
// Her resignation is judged by Stockfish, when it is there.
|
||||
if (r.judge == null && files.state.value == NetState.Ready) {
|
||||
r.judge = runCatching { uniffi.mobile_api.ResignJudge.start(files.executable, files.net.path) }.getOrNull()
|
||||
}
|
||||
r.judge?.ask(e, end.toUInt())
|
||||
val started = System.currentTimeMillis()
|
||||
val only = e.legalMoves(end.toUInt()).size == 1
|
||||
val uci = withContext(Dispatchers.Default) {
|
||||
player.choose(e, end.toUInt(), r.meta.strength.toUInt(), null, kotlin.random.Random.nextFloat())
|
||||
} ?: return@LaunchedEffect
|
||||
val wait = uniffi.mobile_api.maiaPauseMs(depth(gg, end).toUInt(), only).toLong() - (System.currentTimeMillis() - started)
|
||||
if (wait > 0) delay(wait)
|
||||
if (gen != r.generation) return@LaunchedEffect
|
||||
r.judge?.hopeless()?.let { if (it) r.hopeless++ else r.hopeless = 0u }
|
||||
if (!r.playOn && r.hopeless >= uniffi.mobile_api.hopelessTurns()) {
|
||||
r.offer.value = true
|
||||
return@LaunchedEffect
|
||||
}
|
||||
runCatching { e.play(end.toUInt(), uci) }.getOrNull()?.let { ed ->
|
||||
apply(ed)
|
||||
afterMove(ed)
|
||||
}
|
||||
} finally {
|
||||
if (gen == r.generation) r.thinking.value = false
|
||||
}
|
||||
}
|
||||
var resigning by remember { mutableStateOf(false) }
|
||||
// The result card closed with ×: until the next game.
|
||||
var resultClosed by remember(run) { mutableStateOf(false) }
|
||||
val eventText = stringResource(R.string.play_event)
|
||||
val noteText = stringResource(R.string.play_note_from, (run?.meta?.strength ?: 0).toString())
|
||||
// The same strength again, colours swapped; from a position: the same one and colour.
|
||||
fun rematch() {
|
||||
val r = run ?: return
|
||||
val e = edit ?: return
|
||||
val gg = g ?: return
|
||||
val m = r.meta
|
||||
val base = if (m.floor > 0) {
|
||||
var n = 0
|
||||
repeat(m.floor) { n = gg.nodes[n].children.firstOrNull()?.toInt() ?: n }
|
||||
runCatching { e.playFrom(n.toUInt()) }.getOrNull() ?: return
|
||||
} else {
|
||||
GameSession.newGame("")
|
||||
}
|
||||
beginMaiaGame(app, base, m.strength, if (m.floor > 0) m.userWhite else !m.userWhite, m.name, m.floor, eventText, noteText)
|
||||
base.close()
|
||||
held.key = null
|
||||
held.reloads.intValue++
|
||||
}
|
||||
fun takeBack() {
|
||||
val r = run ?: return
|
||||
val gg = g ?: return
|
||||
val e = edit ?: return
|
||||
val end = lineEnd(gg)
|
||||
// While Maia thinks the last move is the user's; else hers, and the user's before.
|
||||
val from = if (r.thinking.value) end else gg.nodes[end].parent?.toInt() ?: return
|
||||
if (depth(gg, from) <= r.meta.floor) return
|
||||
r.generation++
|
||||
r.thinking.value = false
|
||||
r.judge?.forget()
|
||||
r.hopeless = 0u
|
||||
runCatching { e.deleteFrom(from.toUInt()) }.getOrNull()?.let {
|
||||
apply(it)
|
||||
persist()
|
||||
}
|
||||
}
|
||||
|
||||
// Saving (android-play.md §30.4): an own database's game in its place; a new game or
|
||||
// a copy of someone else's into an own database chosen once, then in its place there.
|
||||
val ownGame = dbEntry?.source == Source.Own && !newGame
|
||||
|
|
@ -438,7 +577,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
ownGame -> games?.getOrNull(place)?.let { saveInto(db, it) }
|
||||
to != null -> saveInto(to.first, to.second)
|
||||
// A new game's names and result first, as the desktop asks when adding.
|
||||
newGame -> {
|
||||
newGame && !playGame -> {
|
||||
firstSave = true
|
||||
editingData = true
|
||||
}
|
||||
|
|
@ -447,9 +586,22 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
}
|
||||
// Leaving with changes asks only where they are the user's to keep (an own game, a
|
||||
// new one); moves in someone else's game are for trying out (owner's decision).
|
||||
val asksOnLeave = modified && (ownGame || newGame)
|
||||
// A game against Maia: put aside while it goes on (no question); after its end like
|
||||
// a new game, and gone from hand once left.
|
||||
val asksOnLeave = modified && (ownGame || newGame || (playGame && runOver != null))
|
||||
val exit: () -> Unit = {
|
||||
if (playGame && held.play.value?.over?.value != null) app.maiaGames.clear()
|
||||
onBack()
|
||||
}
|
||||
// What leaving's question leads to (back, or a rematch).
|
||||
var leaveTo by remember { mutableStateOf<(() -> Unit)?>(null) }
|
||||
fun leave() {
|
||||
if (asksOnLeave) leaving = true else onBack()
|
||||
if (asksOnLeave) {
|
||||
leaveTo = exit
|
||||
leaving = true
|
||||
} else {
|
||||
exit()
|
||||
}
|
||||
}
|
||||
fun go(to: Int) {
|
||||
preview = null
|
||||
|
|
@ -506,7 +658,27 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
|
||||
val landscape = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
val controls: @Composable (Modifier) -> Unit = { modifier ->
|
||||
Column(modifier) {
|
||||
if (gameOn && run != null && g != null) {
|
||||
val end = lineEnd(g)
|
||||
val endDepth = depth(g, end)
|
||||
val floor = run.meta.floor
|
||||
PlayControls(
|
||||
// While Maia thinks the last move is the user's; else hers and the user's before.
|
||||
canTakeBack = if (runThinking) endDepth > floor else endDepth - 1 > floor,
|
||||
started = endDepth - floor >= 2,
|
||||
canBack = canBack,
|
||||
canForward = canForward,
|
||||
onTakeBack = ::takeBack,
|
||||
onResign = { resigning = true },
|
||||
onAbort = {
|
||||
app.maiaGames.clear()
|
||||
onBack()
|
||||
},
|
||||
onFlip = { flipped = !flipped },
|
||||
onBack = ::back,
|
||||
onForward = ::forward,
|
||||
)
|
||||
} else Column(modifier) {
|
||||
val p = preview
|
||||
if (p == null && node != null && nodes != null && node.children.size > 1) {
|
||||
Forks(node.children.map { nodes[it.toInt()] }, san, onMove = ::go)
|
||||
|
|
@ -584,10 +756,16 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
animated = prefs.animation,
|
||||
// A touch during a preview of an engine line closes it; no move is made (§29.5).
|
||||
modifier = if (p != null) boardModifier.pointerInput(Unit) { detectTapGestures { preview = null } } else boardModifier,
|
||||
input = edit?.takeIf { p == null && g != null }?.let { e ->
|
||||
input = edit?.takeIf {
|
||||
// In a game: only the user's side, in their turn, at the game's last move.
|
||||
p == null && g != null && (!gameOn || (current == lineEnd(g) && !runThinking && !runOffer && whiteToMove(g.nodes[current].fen) == run!!.meta.userWhite))
|
||||
}?.let { e ->
|
||||
val legal = remember(g, current) { e.legalMoves(current.toUInt()) }
|
||||
BoardInput(legal, onMove = { uci ->
|
||||
runCatching { e.play(current.toUInt(), uci) }.getOrNull()?.let { apply(it) }
|
||||
runCatching { e.play(current.toUInt(), uci) }.getOrNull()?.let {
|
||||
apply(it)
|
||||
if (gameOn) afterMove(it)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
|
|
@ -643,6 +821,45 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
)
|
||||
}
|
||||
if (p != null) PreviewBar(p.step + 1, p.line.steps.size, onClose = { preview = null }, best = p.best)
|
||||
if (run != null) {
|
||||
when {
|
||||
runOffer -> OfferCard(
|
||||
onAccept = { finishGame(PlayOver(if (run.meta.userWhite) "1-0" else "0-1", R.string.play_won, R.string.end_maia_resigned)) },
|
||||
onPlayOn = {
|
||||
run.playOn = true
|
||||
run.offer.value = false
|
||||
},
|
||||
)
|
||||
runFailure != null -> Text(
|
||||
stringResource(R.string.play_maia_failed, runFailure),
|
||||
Modifier.padding(16.dp),
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
runOver != null && !resultClosed -> ResultCard(
|
||||
runOver,
|
||||
saved = held.savedTo != null && !modified,
|
||||
onAnalyse = {
|
||||
val e = edit
|
||||
if (e != null) scope.launch {
|
||||
review.openSession("${held.key}/${System.nanoTime()}", e)
|
||||
reviewHidden = false
|
||||
reviewStart = true
|
||||
}
|
||||
},
|
||||
onRematch = {
|
||||
val go = { rematch() }
|
||||
if (modified) {
|
||||
leaveTo = go
|
||||
leaving = true
|
||||
} else {
|
||||
go()
|
||||
}
|
||||
},
|
||||
onSave = { save() },
|
||||
onClose = { resultClosed = true },
|
||||
)
|
||||
}
|
||||
}
|
||||
Box(Modifier.weight(1f).fillMaxWidth()) {
|
||||
when {
|
||||
g != null -> Notation(
|
||||
|
|
@ -677,14 +894,18 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
// The event and year (else the site); the game's place and round. A tap
|
||||
// shows the game's details.
|
||||
// No event and no site: the database's name.
|
||||
val event = if (newGame && held.savedTo == null) {
|
||||
val event = if (playGame && run != null) {
|
||||
stringResource(R.string.play_with_maia) + " " + run.meta.strength
|
||||
} else if (newGame && held.savedTo == null) {
|
||||
stringResource(R.string.new_game)
|
||||
} else {
|
||||
joinKnown(tag("Event"), year(tag("Date"))).ifEmpty { joinKnown(tag("Site")) }
|
||||
.ifEmpty { dbEntry?.let { displayName(it) } ?: "" }
|
||||
}
|
||||
val round = tag("Round").trim().takeIf { it.isNotEmpty() && it != "?" && it != "-" }
|
||||
val placeLine = joinKnown(
|
||||
val placeLine = if (playGame && run != null) {
|
||||
stringResource(R.string.play_adjourned_sub, stringResource(if (run.meta.userWhite) R.string.play_as_white else R.string.play_as_black), stringResource(R.string.play_untimed))
|
||||
} else joinKnown(
|
||||
if (total > 0) stringResource(R.string.game_of, place + 1, total) else "",
|
||||
round?.let { stringResource(R.string.tag_round).lowercase() + " " + it } ?: "",
|
||||
)
|
||||
|
|
@ -714,13 +935,13 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
},
|
||||
actions = {
|
||||
// Changes not saved: "Save" in place of ‹ › (they would need a decision).
|
||||
if (modified) {
|
||||
if (modified && !gameOn) {
|
||||
val where = when {
|
||||
ownGame -> dbEntry?.let { stringResource(R.string.save_in, displayName(it)) }
|
||||
else -> held.savedTo?.first?.let { app.library.entry(it) }?.let { stringResource(R.string.save_in, displayName(it)) }
|
||||
} ?: stringResource(R.string.save_to_mine)
|
||||
IconButton(onClick = { save() }) { Icon(Icons.Rounded.Save, where) }
|
||||
} else if (!newGame) {
|
||||
} else if (!newGame && !playGame) {
|
||||
IconButton(onClick = { place -= 1 }, enabled = place > 0) {
|
||||
Icon(Icons.Rounded.ChevronLeft, stringResource(R.string.previous_game))
|
||||
}
|
||||
|
|
@ -741,10 +962,18 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
DropdownMenuItem(
|
||||
text = { Text(stringResource(if (rs?.hasData == true) R.string.review_report_menu else R.string.review_menu)) },
|
||||
// During the first analysis the panel already shows its progress (§21.1).
|
||||
enabled = hasMoves && rs != null && (rs.hasData || !rs.running),
|
||||
enabled = hasMoves && !gameOn && ((newGame || playGame) || (rs != null && (rs.hasData || !rs.running))),
|
||||
onClick = {
|
||||
menu = false
|
||||
reviewHidden = false
|
||||
val e = edit
|
||||
if ((newGame || playGame) && e != null && rs == null) {
|
||||
scope.launch {
|
||||
review.openSession("${held.key}/${System.nanoTime()}", e)
|
||||
reviewStart = true
|
||||
}
|
||||
return@DropdownMenuItem
|
||||
}
|
||||
when {
|
||||
rs?.hasData == true -> reviewReport = true
|
||||
rs?.running == true -> {}
|
||||
|
|
@ -800,11 +1029,14 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
// a title for White and no Black keeps both bars, so the board does not jump.
|
||||
val study = whiteName != null && blackName == null
|
||||
val result = g?.result ?: ""
|
||||
// In a game: «thinking…» on Maia's bar while she computes (§31.3).
|
||||
val thinkingText = stringResource(R.string.play_thinking)
|
||||
val maiaThinks = { white: Boolean -> if (gameOn && runThinking && run?.meta?.userWhite != white) thinkingText else null }
|
||||
val whiteBar: @Composable () -> Unit = {
|
||||
PlayerBar(whiteName ?: whiteLabel, elo(tag("WhiteElo")), true, sideResult(result, true), known = whiteName != null, abbreviate = !study)
|
||||
PlayerBar(whiteName ?: whiteLabel, elo(tag("WhiteElo")), true, maiaThinks(true) ?: sideResult(result, true), known = whiteName != null, abbreviate = !study)
|
||||
}
|
||||
val blackBar: @Composable () -> Unit = {
|
||||
PlayerBar(blackName ?: blackLabel, elo(tag("BlackElo")), false, sideResult(result, false), known = blackName != null)
|
||||
PlayerBar(blackName ?: blackLabel, elo(tag("BlackElo")), false, maiaThinks(false) ?: sideResult(result, false), known = blackName != null)
|
||||
}
|
||||
val topBar = if (flipped) whiteBar else blackBar
|
||||
val bottomBar = if (flipped) blackBar else whiteBar
|
||||
|
|
@ -914,20 +1146,55 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
leaving = false
|
||||
save(then = onBack)
|
||||
save(then = leaveTo ?: exit)
|
||||
}) { Text(stringResource(if (ownGame || held.savedTo != null) R.string.save else R.string.save_to_db_ellipsis)) }
|
||||
},
|
||||
dismissButton = {
|
||||
Row {
|
||||
TextButton(onClick = {
|
||||
leaving = false
|
||||
onBack()
|
||||
(leaveTo ?: exit)()
|
||||
}) { Text(stringResource(R.string.dont_save)) }
|
||||
TextButton(onClick = { leaving = false }) { Text(stringResource(R.string.cancel)) }
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
// «Play on from here» (§31.6): the moves up to the move, then a game against Maia.
|
||||
val fromMove = playFrom
|
||||
if (fromMove != null && g != null && edit != null) {
|
||||
val n = g.nodes.getOrNull(fromMove)
|
||||
if (n == null) {
|
||||
playFrom = null
|
||||
} else {
|
||||
val moveLabel = (if (n.white) "${n.moveNumber}." else "${n.moveNumber}…") + san(n.san).text
|
||||
val origin = listOfNotNull(whiteName, blackName).joinToString(" — ").takeIf { it.isNotEmpty() }
|
||||
PlaySheet(
|
||||
PlayFrom(n.fen, listOfNotNull(stringResource(R.string.play_from_label, moveLabel), origin).joinToString("\n"), whiteToMove(n.fen)),
|
||||
onPlay = { strength, white, name ->
|
||||
playFrom = null
|
||||
val s = runCatching { edit?.playFrom(fromMove.toUInt()) }.getOrNull() ?: return@PlaySheet
|
||||
beginMaiaGame(app, s, strength, white, name, depth(g, fromMove), eventText, context.getString(R.string.play_note_from, strength.toString()))
|
||||
s.close()
|
||||
onPlayGame()
|
||||
},
|
||||
onDismiss = { playFrom = null },
|
||||
)
|
||||
}
|
||||
}
|
||||
if (resigning) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { resigning = false },
|
||||
title = { Text(stringResource(R.string.play_resign_q)) },
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
resigning = false
|
||||
run?.let { finishGame(PlayOver(if (it.meta.userWhite) "0-1" else "1-0", R.string.play_you_resigned, null)) }
|
||||
}) { Text(stringResource(R.string.play_resign).removePrefix("⚑ "), color = MaterialTheme.colorScheme.error) }
|
||||
},
|
||||
dismissButton = { TextButton(onClick = { resigning = false }) { Text(stringResource(R.string.cancel)) } },
|
||||
)
|
||||
}
|
||||
val sheetMove = moveSheet
|
||||
if (sheetMove != null && g != null && edit != null) {
|
||||
val n = g.nodes.getOrNull(sheetMove)
|
||||
|
|
@ -939,6 +1206,12 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
inVariation = g.nodes[n.parent!!.toInt()].children.firstOrNull()?.toInt() != sheetMove,
|
||||
runs = remember(sheetMove) { edit?.trainingRuns(sheetMove.toUInt())?.toInt() },
|
||||
canTrain = !n.nullMove,
|
||||
// Not at mate or stalemate, nor after a null move; not inside a game being played.
|
||||
canPlay = !n.nullMove && n.end.isEmpty() && !gameOn,
|
||||
onPlay = {
|
||||
moveSheet = null
|
||||
playFrom = sheetMove
|
||||
},
|
||||
onTrain = {
|
||||
moveSheet = null
|
||||
edit?.trainer(sheetMove.toUInt())?.let { t ->
|
||||
|
|
@ -1231,6 +1504,8 @@ private fun MoveSheet(
|
|||
onMakeMain: () -> Unit,
|
||||
onDelete: () -> Unit,
|
||||
onTrain: () -> Unit,
|
||||
canPlay: Boolean,
|
||||
onPlay: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
) {
|
||||
androidx.compose.material3.ModalBottomSheet(onDismissRequest = onDismiss) {
|
||||
|
|
@ -1239,6 +1514,7 @@ private fun MoveSheet(
|
|||
if (inVariation) SheetAction(Icons.Rounded.VerticalAlignTop, stringResource(R.string.make_main), onClick = onMakeMain)
|
||||
SheetAction(Icons.Rounded.Close, stringResource(R.string.delete_move), onClick = onDelete)
|
||||
HorizontalDivider(Modifier.padding(vertical = 4.dp), color = MaterialTheme.colorScheme.outlineVariant)
|
||||
SheetAction(Icons.Rounded.SmartToy, stringResource(R.string.play_from_maia), enabled = canPlay, onClick = onPlay)
|
||||
SheetAction(
|
||||
Icons.Rounded.School,
|
||||
stringResource(R.string.train_learn),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,217 @@
|
|||
package io.github.vrubelroman.chesspenguin.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.rounded.Undo
|
||||
import androidx.compose.material.icons.rounded.Close
|
||||
import androidx.compose.material.icons.rounded.Flag
|
||||
import androidx.compose.material.icons.rounded.PlayArrow
|
||||
import androidx.compose.material.icons.rounded.SwapVert
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.github.vrubelroman.chesspenguin.R
|
||||
import io.github.vrubelroman.chesspenguin.data.PlayMeta
|
||||
import uniffi.mobile_api.GameData
|
||||
import uniffi.mobile_api.GameEnding
|
||||
import uniffi.mobile_api.MaiaPlayer
|
||||
import uniffi.mobile_api.ResignJudge
|
||||
|
||||
/// The key of the game against Maia in hand (a game screen without a database).
|
||||
const val PLAY_GAME = "play"
|
||||
|
||||
/// How a game against Maia ended: the result and what the strip says.
|
||||
data class PlayOver(val result: String, val heading: Int, val detail: Int?)
|
||||
|
||||
/// A game against Maia being played (android-play.md §31), kept while the phone turns.
|
||||
class PlayRun(val meta: PlayMeta) {
|
||||
var player: MaiaPlayer? = null
|
||||
var judge: ResignJudge? = null
|
||||
val thinking = mutableStateOf(false)
|
||||
/// Maia offers to resign (her position hopeless two turns in a row).
|
||||
val offer = mutableStateOf(false)
|
||||
val over = mutableStateOf<PlayOver?>(null)
|
||||
/// Maia failed to start: why.
|
||||
val failure = mutableStateOf<String?>(null)
|
||||
/// «Play to the end»: no more offers in this game.
|
||||
var playOn = false
|
||||
var hopeless = 0u
|
||||
/// Bumped by a take-back: Maia's answer for the old position is dropped.
|
||||
var generation = 0
|
||||
|
||||
fun close() {
|
||||
player?.close()
|
||||
judge?.close()
|
||||
player = null
|
||||
judge = null
|
||||
}
|
||||
}
|
||||
|
||||
/// The last node of the main line.
|
||||
fun lineEnd(g: GameData): Int {
|
||||
var n = 0
|
||||
while (true) n = g.nodes[n].children.firstOrNull()?.toInt() ?: return n
|
||||
}
|
||||
|
||||
/// Half-moves from the start to node `id`.
|
||||
fun depth(g: GameData, id: Int): Int {
|
||||
var d = 0
|
||||
var n = g.nodes.getOrNull(id) ?: return 0
|
||||
while (true) {
|
||||
n = g.nodes.getOrNull(n.parent?.toInt() ?: return d) ?: return d
|
||||
d++
|
||||
}
|
||||
}
|
||||
|
||||
fun whiteToMove(fen: String) = fen.substringAfter(' ').startsWith("w")
|
||||
|
||||
/// The end of a game by the rules, from the user's side.
|
||||
fun overBy(ending: GameEnding, userWhite: Boolean): PlayOver = when (ending) {
|
||||
is GameEnding.Checkmate -> PlayOver(
|
||||
if (ending.whiteWon) "1-0" else "0-1",
|
||||
if (ending.whiteWon == userWhite) R.string.play_won else R.string.play_lost,
|
||||
R.string.end_mate,
|
||||
)
|
||||
GameEnding.Stalemate -> PlayOver("1/2-1/2", R.string.play_draw, R.string.end_stalemate)
|
||||
GameEnding.InsufficientMaterial -> PlayOver("1/2-1/2", R.string.play_draw, R.string.end_material)
|
||||
GameEnding.Threefold -> PlayOver("1/2-1/2", R.string.play_draw, R.string.end_threefold)
|
||||
GameEnding.FiftyMoves -> PlayOver("1/2-1/2", R.string.play_draw, R.string.end_fifty)
|
||||
}
|
||||
|
||||
/// The bottom bar during a game (§31.3): take back, resign (abort before the first
|
||||
/// moves), flip, a move back and forward.
|
||||
@Composable
|
||||
fun PlayControls(
|
||||
canTakeBack: Boolean,
|
||||
started: Boolean,
|
||||
canBack: Boolean,
|
||||
canForward: Boolean,
|
||||
onTakeBack: () -> Unit,
|
||||
onResign: () -> Unit,
|
||||
onAbort: () -> Unit,
|
||||
onFlip: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
onForward: () -> Unit,
|
||||
) {
|
||||
Column {
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
Surface(color = MaterialTheme.colorScheme.surfaceContainer) {
|
||||
Row(Modifier.fillMaxWidth().navigationBarsPadding().height(72.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
LabeledButton(Icons.AutoMirrored.Rounded.Undo, stringResource(R.string.play_take_back).removePrefix("↶ "), canTakeBack, Modifier.weight(1f), onTakeBack)
|
||||
if (started) {
|
||||
LabeledButton(Icons.Rounded.Flag, stringResource(R.string.play_resign).removePrefix("⚑ "), true, Modifier.weight(1f), onResign)
|
||||
} else {
|
||||
LabeledButton(Icons.Rounded.Close, stringResource(R.string.play_abort), true, Modifier.weight(1f), onAbort)
|
||||
}
|
||||
IconButton(onClick = onFlip, modifier = Modifier.weight(0.8f)) { Icon(Icons.Rounded.SwapVert, stringResource(R.string.flip)) }
|
||||
IconButton(onClick = onBack, enabled = canBack, modifier = Modifier.weight(1f)) {
|
||||
// The forward arrow turned round, as the game screen's.
|
||||
Icon(Icons.Rounded.PlayArrow, stringResource(R.string.move_back), Modifier.scale(-1f, 1f))
|
||||
}
|
||||
IconButton(onClick = onForward, enabled = canForward, modifier = Modifier.weight(1f)) { Icon(Icons.Rounded.PlayArrow, stringResource(R.string.move_forward)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LabeledButton(icon: androidx.compose.ui.graphics.vector.ImageVector, label: String, enabled: Boolean, modifier: Modifier, onClick: () -> Unit) {
|
||||
androidx.compose.material3.TextButton(onClick = onClick, enabled = enabled, modifier = modifier.height(64.dp)) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Icon(icon, null)
|
||||
Text(label, style = MaterialTheme.typography.labelSmall, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Maia offers to resign (§31.3): accept the win, or play on.
|
||||
@Composable
|
||||
fun OfferCard(onAccept: () -> Unit, onPlayOn: () -> Unit) {
|
||||
Card {
|
||||
Text(stringResource(R.string.play_maia_resigns), style = MaterialTheme.typography.titleMedium)
|
||||
Text(stringResource(R.string.play_her_position_lost), style = MaterialTheme.typography.bodyMedium)
|
||||
Row(Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(onClick = onAccept, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_accept_win)) }
|
||||
OutlinedButton(onClick = onPlayOn, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_to_end)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The end of the game (§31.4): the result, then analyse, rematch, save.
|
||||
@Composable
|
||||
fun ResultCard(over: PlayOver, saved: Boolean, onAnalyse: () -> Unit, onRematch: () -> Unit, onSave: () -> Unit, onClose: () -> Unit) {
|
||||
Card {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
(if (over.result == "1/2-1/2") "½-½" else over.result) + " " + stringResource(over.heading) + (over.detail?.let { " · " + stringResource(it) } ?: ""),
|
||||
Modifier.weight(1f),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
)
|
||||
IconButton(onClick = onClose) { Icon(Icons.Rounded.Close, stringResource(R.string.close)) }
|
||||
}
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(onClick = onAnalyse, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_analyse), maxLines = 1) }
|
||||
OutlinedButton(onClick = onRematch, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_rematch).removePrefix("↻ "), maxLines = 1) }
|
||||
OutlinedButton(onClick = onSave, enabled = !saved, modifier = Modifier.weight(1f)) {
|
||||
Text(stringResource(if (saved) R.string.play_saved else R.string.play_save), maxLines = 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Card(content: @Composable () -> Unit) {
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
.background(MaterialTheme.colorScheme.surfaceContainerHigh, RoundedCornerShape(12.dp))
|
||||
.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) { content() }
|
||||
}
|
||||
|
||||
/// Puts a new game against Maia in hand (android-play.md §31): `session` holds its moves
|
||||
/// so far (none, or those of the game it goes on from: `floor` half-moves); its tags
|
||||
/// are set, and after the moves of another game a note says where it comes from.
|
||||
fun beginMaiaGame(
|
||||
app: io.github.vrubelroman.chesspenguin.ChessPenguinApp,
|
||||
session: uniffi.mobile_api.GameSession,
|
||||
strength: Int,
|
||||
userWhite: Boolean,
|
||||
name: String,
|
||||
floor: Int,
|
||||
event: String,
|
||||
note: String?,
|
||||
) {
|
||||
val date = java.text.SimpleDateFormat("yyyy.MM.dd", java.util.Locale.ROOT).format(java.util.Date())
|
||||
val tags = uniffi.mobile_api.maiaGameTags(event, userWhite, name, strength.toUInt()) + uniffi.mobile_api.Tag("Date", date)
|
||||
session.setData(tags, "*")
|
||||
if (floor > 0 && note != null) {
|
||||
val data = session.data()
|
||||
runCatching { session.addComment(lineEnd(data).toUInt(), note) }
|
||||
}
|
||||
session.markSaved()
|
||||
app.maiaGames.begin(session.pgn(), PlayMeta(strength, userWhite, name, floor))
|
||||
}
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
package io.github.vrubelroman.chesspenguin.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.Close
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.SegmentedButton
|
||||
import androidx.compose.material3.SegmentedButtonDefaults
|
||||
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.github.vrubelroman.chesspenguin.R
|
||||
import io.github.vrubelroman.chesspenguin.data.NetProblem
|
||||
import io.github.vrubelroman.chesspenguin.data.NetState
|
||||
import io.github.vrubelroman.chesspenguin.theme.Tabular
|
||||
import uniffi.mobile_api.maiaRange
|
||||
|
||||
/// The position a game against Maia starts from (android-play.md §31.6): drawn small,
|
||||
/// with where it comes from; the side to move plays by default.
|
||||
data class PlayFrom(val fen: String, val label: String, val whiteToMove: Boolean)
|
||||
|
||||
/// «Play against the computer» (android-play.md §31.1): Maia's strength, the colour,
|
||||
/// the name; Maia downloaded here the first time (21 MB). `onPlay`: strength, the user
|
||||
/// plays White, name.
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun PlaySheet(from: PlayFrom?, onPlay: (Int, Boolean, String) -> Unit, onDismiss: () -> Unit) {
|
||||
val app = app()
|
||||
val prefs by app.settings.prefs.collectAsState()
|
||||
val files = app.maiaFiles.download
|
||||
val state by files.state.collectAsState()
|
||||
val range = remember { maiaRange() }
|
||||
val lo = range[0].toInt()
|
||||
val hi = range[1].toInt()
|
||||
var strength by remember { mutableFloatStateOf(prefs.maiaStrength.coerceIn(lo, hi).toFloat()) }
|
||||
// From a position: the side to move by default, not remembered (play-from-position.md §2).
|
||||
var color by remember { mutableIntStateOf(if (from != null) (if (from.whiteToMove) 1 else -1) else prefs.maiaColor) }
|
||||
var name by remember { mutableStateOf(prefs.yourName) }
|
||||
// «Download and play»: the game starts once the file is checked.
|
||||
var playAfter by remember { mutableStateOf(false) }
|
||||
val level = (strength / 50f).toInt() * 50
|
||||
fun play() {
|
||||
val white = when (color) {
|
||||
1 -> true
|
||||
-1 -> false
|
||||
else -> kotlin.random.Random.nextBoolean()
|
||||
}
|
||||
app.settings.update { p ->
|
||||
p.copy(maiaStrength = level, yourName = name.trim(), maiaColor = if (from != null) p.maiaColor else color)
|
||||
}
|
||||
onPlay(level, white, name.trim())
|
||||
}
|
||||
LaunchedEffect(state) {
|
||||
if (playAfter && state == NetState.Ready) {
|
||||
playAfter = false
|
||||
play()
|
||||
}
|
||||
}
|
||||
ModalBottomSheet(onDismissRequest = onDismiss, sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)) {
|
||||
Column(Modifier.fillMaxWidth().verticalScroll(rememberScrollState()).padding(start = 24.dp, end = 24.dp, bottom = 24.dp)) {
|
||||
Text(stringResource(R.string.play_title), style = MaterialTheme.typography.titleLarge)
|
||||
if (from != null) {
|
||||
Row(Modifier.padding(top = 12.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
MiniBoard(from.fen, flipped = color == -1, size = 96.dp)
|
||||
Text(from.label, Modifier.padding(start = 16.dp), style = MaterialTheme.typography.bodyMedium, maxLines = 4, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Text(stringResource(R.string.play_opponent, level.toString()), style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Medium)
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text("$lo", style = MaterialTheme.typography.bodySmall.merge(Tabular), color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
Slider(
|
||||
value = strength,
|
||||
onValueChange = { strength = it },
|
||||
valueRange = lo.toFloat()..hi.toFloat(),
|
||||
modifier = Modifier.weight(1f).padding(horizontal = 8.dp),
|
||||
)
|
||||
Text("$hi", style = MaterialTheme.typography.bodySmall.merge(Tabular), color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
Text(stringResource(R.string.play_measured), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Text(stringResource(R.string.play_colour), style = MaterialTheme.typography.titleSmall)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
val options = listOf(1 to R.string.color_white, 0 to R.string.color_random, -1 to R.string.color_black)
|
||||
SingleChoiceSegmentedButtonRow(Modifier.fillMaxWidth()) {
|
||||
options.forEachIndexed { i, (v, label) ->
|
||||
SegmentedButton(selected = color == v, onClick = { color = v }, shape = SegmentedButtonDefaults.itemShape(i, options.size)) {
|
||||
Text(stringResource(label))
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(12.dp))
|
||||
OutlinedTextField(name, { name = it }, Modifier.fillMaxWidth(), label = { Text(stringResource(R.string.play_your_name)) }, singleLine = true)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
// The state of Maia's file: always one line, so that nothing jumps.
|
||||
Row(Modifier.fillMaxWidth().height(40.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
when (val s = state) {
|
||||
NetState.Ready -> Text(stringResource(R.string.play_maia_ready), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
NetState.Missing -> Text(
|
||||
stringResource(R.string.play_download_note, megabytes(files.size)),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 2,
|
||||
)
|
||||
is NetState.Loading -> {
|
||||
Column(Modifier.weight(1f)) {
|
||||
LinearProgressIndicator(progress = { s.done.toFloat() / s.total.coerceAtLeast(1) }, modifier = Modifier.fillMaxWidth())
|
||||
Text(stringResource(R.string.downloaded_of, megabytes(s.done), megabytes(s.total)), style = MaterialTheme.typography.bodySmall.merge(Tabular))
|
||||
}
|
||||
IconButton(onClick = {
|
||||
playAfter = false
|
||||
files.cancel()
|
||||
}) { Icon(Icons.Rounded.Close, stringResource(R.string.cancel_download)) }
|
||||
}
|
||||
is NetState.Failed -> Text(
|
||||
when (s.problem) {
|
||||
NetProblem.NoInternet -> stringResource(R.string.no_internet)
|
||||
NetProblem.Interrupted -> stringResource(R.string.interrupted)
|
||||
NetProblem.NoSpace -> stringResource(R.string.no_space, megabytes(files.size))
|
||||
NetProblem.Corrupt -> stringResource(R.string.corrupt)
|
||||
},
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
maxLines = 2,
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
val loading = state is NetState.Loading
|
||||
Button(
|
||||
onClick = {
|
||||
if (state == NetState.Ready) {
|
||||
play()
|
||||
} else {
|
||||
playAfter = true
|
||||
files.download()
|
||||
}
|
||||
},
|
||||
enabled = !loading,
|
||||
modifier = Modifier.fillMaxWidth().height(56.dp),
|
||||
) {
|
||||
Text(
|
||||
stringResource(
|
||||
when (state) {
|
||||
NetState.Ready, is NetState.Loading -> R.string.play_play
|
||||
is NetState.Failed -> R.string.play_retry
|
||||
NetState.Missing -> R.string.play_download_and_play
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A small board of a position (no touches, no coordinates).
|
||||
@Composable
|
||||
fun MiniBoard(fen: String, flipped: Boolean, size: androidx.compose.ui.unit.Dp) {
|
||||
val app = app()
|
||||
val prefs by app.settings.prefs.collectAsState()
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
val pieces = remember { Pieces(context) }
|
||||
Board(
|
||||
fen = fen,
|
||||
flipped = flipped,
|
||||
lastFrom = null,
|
||||
lastTo = null,
|
||||
pieces = pieces,
|
||||
theme = prefs.board,
|
||||
set = prefs.pieces,
|
||||
description = "",
|
||||
animated = false,
|
||||
modifier = Modifier.width(size),
|
||||
)
|
||||
}
|
||||
|
||||
private fun megabytes(bytes: Long) = ((bytes + 999_999) / 1_000_000).toInt()
|
||||
|
|
@ -52,11 +52,16 @@ class GameEdit : ViewModel() {
|
|||
var savedTo: Pair<String, UInt>? = null
|
||||
/// An opening being learned over the game (android-play.md §32), how far, the board's side.
|
||||
val trainer = mutableStateOf<uniffi.mobile_api.Trainer?>(null)
|
||||
/// The game against Maia, when this screen plays one (§31).
|
||||
val play = mutableStateOf<PlayRun?>(null)
|
||||
/// Bumped to read the game in hand again (a rematch).
|
||||
val reloads = androidx.compose.runtime.mutableIntStateOf(0)
|
||||
var trainPly = 0
|
||||
var trainFlipped = false
|
||||
|
||||
override fun onCleared() {
|
||||
trainer.value?.close()
|
||||
play.value?.close()
|
||||
session.value?.close()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -461,4 +461,56 @@
|
|||
<item quantity="other">%1$d Durchgänge</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">Maia für ChessPenguin</string>
|
||||
<string name="play_won">Sie haben gewonnen</string>
|
||||
<string name="play_lost">Sie haben verloren</string>
|
||||
<string name="play_you_resigned">Sie haben aufgegeben</string>
|
||||
<string name="play_draw">Remis</string>
|
||||
<string name="end_mate">Schachmatt</string>
|
||||
<string name="end_stalemate">Patt</string>
|
||||
<string name="end_threefold">die Stellung ist dreimal aufgetreten</string>
|
||||
<string name="end_fifty">50 Züge ohne Schlagen oder Bauernzug</string>
|
||||
<string name="end_material">keine Seite kann mattsetzen</string>
|
||||
<string name="end_maia_resigned">Maia hat aufgegeben</string>
|
||||
<string name="play_resign_q">Aufgeben?</string>
|
||||
<string name="play_resign">⚑ Aufgeben</string>
|
||||
<string name="play_take_back">↶ Zurücknehmen</string>
|
||||
<string name="play_title">Gegen den Computer spielen</string>
|
||||
<string name="play_colour">Ihre Farbe</string>
|
||||
<string name="color_white">Weiß</string>
|
||||
<string name="color_black">Schwarz</string>
|
||||
<string name="color_random">Zufällig</string>
|
||||
<string name="play_opponent">Gegner — Maia %1$s</string>
|
||||
<string name="play_measured">Ihre gemessene Spielstärke, auf der Lichess-Blitz-Skala.</string>
|
||||
<string name="play_download_note">Maia wird einmalig heruntergeladen (%1$s MB, von huggingface.co, die Datei der Autoren selbst).</string>
|
||||
<string name="play_download_and_play">Herunterladen und spielen</string>
|
||||
<string name="play_play">Spielen</string>
|
||||
<string name="play_thinking">denkt nach…</string>
|
||||
<string name="play_event">Partie gegen den Computer</string>
|
||||
<string name="play_analyse">Analysieren</string>
|
||||
<string name="play_rematch">↻ Revanche</string>
|
||||
<string name="play_from_here">Von hier aus spielen…</string>
|
||||
<string name="play_checking">Wird geprüft…</string>
|
||||
<string name="play_maia_failed">Maia ist nicht gestartet: %1$s</string>
|
||||
<string name="play_accept_win">Sieg annehmen</string>
|
||||
<string name="play_to_end">Zu Ende spielen</string>
|
||||
<string name="play_maia_resigns">Maia gibt auf</string>
|
||||
<string name="play_note_from">Ab hier eine Partie gegen Maia %1$s.</string>
|
||||
<string name="play_abort">Abbrechen</string>
|
||||
<string name="play_with_maia">Gegen Maia spielen</string>
|
||||
<string name="play_your_name">Ihr Name (für die Partie)</string>
|
||||
<string name="play_maia_ready">Maia ist heruntergeladen</string>
|
||||
<string name="play_retry">Erneut versuchen</string>
|
||||
<string name="play_her_position_lost">Ihre Stellung ist verloren. Sieg annehmen oder weiterspielen?</string>
|
||||
<string name="play_continue">Fortsetzen</string>
|
||||
<string name="play_adjourned">Partie gegen Maia %1$s · Sie spielen %2$s</string>
|
||||
<string name="play_as_white">Weiß</string>
|
||||
<string name="play_as_black">Schwarz</string>
|
||||
<string name="play_removed">Partie entfernt</string>
|
||||
<string name="play_untimed">ohne Uhr</string>
|
||||
<string name="play_you">Sie</string>
|
||||
<string name="play_saved">✓ Gespeichert</string>
|
||||
<string name="play_save">Speichern…</string>
|
||||
<string name="play_adjourned_sub">Sie spielen %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Von hier gegen Maia weiterspielen…</string>
|
||||
<string name="play_from_label">Nach %1$s</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -469,4 +469,56 @@
|
|||
<item quantity="other">%1$d repasos</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">Maia para ChessPenguin</string>
|
||||
<string name="play_won">Has ganado</string>
|
||||
<string name="play_lost">Has perdido</string>
|
||||
<string name="play_you_resigned">Has abandonado</string>
|
||||
<string name="play_draw">Tablas</string>
|
||||
<string name="end_mate">jaque mate</string>
|
||||
<string name="end_stalemate">rey ahogado</string>
|
||||
<string name="end_threefold">la posición se repitió tres veces</string>
|
||||
<string name="end_fifty">50 jugadas sin capturas ni movimientos de peón</string>
|
||||
<string name="end_material">ningún bando puede dar mate</string>
|
||||
<string name="end_maia_resigned">Maia se rindió</string>
|
||||
<string name="play_resign_q">¿Abandonar?</string>
|
||||
<string name="play_resign">⚑ Abandonar</string>
|
||||
<string name="play_take_back">↶ Deshacer jugada</string>
|
||||
<string name="play_title">Jugar contra el ordenador</string>
|
||||
<string name="play_colour">Tu color</string>
|
||||
<string name="color_white">Blancas</string>
|
||||
<string name="color_black">Negras</string>
|
||||
<string name="color_random">Al azar</string>
|
||||
<string name="play_opponent">Rival — Maia %1$s</string>
|
||||
<string name="play_measured">Su fuerza medida, en la escala de blitz de Lichess.</string>
|
||||
<string name="play_download_note">Maia se descarga una sola vez (%1$s MB, desde huggingface.co, el archivo de los propios autores).</string>
|
||||
<string name="play_download_and_play">Descargar y jugar</string>
|
||||
<string name="play_play">Jugar</string>
|
||||
<string name="play_thinking">pensando…</string>
|
||||
<string name="play_event">Partida contra el ordenador</string>
|
||||
<string name="play_analyse">Analizar</string>
|
||||
<string name="play_rematch">↻ Revancha</string>
|
||||
<string name="play_from_here">Jugar desde aquí…</string>
|
||||
<string name="play_checking">Comprobando…</string>
|
||||
<string name="play_maia_failed">Maia no se inició: %1$s</string>
|
||||
<string name="play_accept_win">Aceptar la victoria</string>
|
||||
<string name="play_to_end">Jugar hasta el final</string>
|
||||
<string name="play_maia_resigns">Maia se rinde</string>
|
||||
<string name="play_note_from">A partir de aquí, una partida contra Maia %1$s.</string>
|
||||
<string name="play_abort">Abortar</string>
|
||||
<string name="play_with_maia">Jugar con Maia</string>
|
||||
<string name="play_your_name">Tu nombre (para la partida)</string>
|
||||
<string name="play_maia_ready">Maia está descargada</string>
|
||||
<string name="play_retry">Reintentar</string>
|
||||
<string name="play_her_position_lost">Su posición está perdida. ¿Aceptar la victoria o seguir?</string>
|
||||
<string name="play_continue">Continuar</string>
|
||||
<string name="play_adjourned">Partida contra Maia %1$s · juegas con %2$s</string>
|
||||
<string name="play_as_white">blancas</string>
|
||||
<string name="play_as_black">negras</string>
|
||||
<string name="play_removed">Partida eliminada</string>
|
||||
<string name="play_untimed">sin reloj</string>
|
||||
<string name="play_you">Tú</string>
|
||||
<string name="play_saved">✓ Guardada</string>
|
||||
<string name="play_save">Guardar…</string>
|
||||
<string name="play_adjourned_sub">juegas con %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Seguir desde aquí contra Maia…</string>
|
||||
<string name="play_from_label">Tras %1$s</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -469,4 +469,56 @@
|
|||
<item quantity="other">%1$d passages</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">Maia pour ChessPenguin</string>
|
||||
<string name="play_won">Vous avez gagné</string>
|
||||
<string name="play_lost">Vous avez perdu</string>
|
||||
<string name="play_you_resigned">Vous avez abandonné</string>
|
||||
<string name="play_draw">Nulle</string>
|
||||
<string name="end_mate">échec et mat</string>
|
||||
<string name="end_stalemate">pat</string>
|
||||
<string name="end_threefold">la position s’est répétée trois fois</string>
|
||||
<string name="end_fifty">50 coups sans prise ni coup de pion</string>
|
||||
<string name="end_material">aucun camp ne peut mater</string>
|
||||
<string name="end_maia_resigned">Maia a abandonné</string>
|
||||
<string name="play_resign_q">Abandonner ?</string>
|
||||
<string name="play_resign">⚑ Abandonner</string>
|
||||
<string name="play_take_back">↶ Reprendre</string>
|
||||
<string name="play_title">Jouer contre l’ordinateur</string>
|
||||
<string name="play_colour">Votre couleur</string>
|
||||
<string name="color_white">Blancs</string>
|
||||
<string name="color_black">Noirs</string>
|
||||
<string name="color_random">Au hasard</string>
|
||||
<string name="play_opponent">Adversaire — Maia %1$s</string>
|
||||
<string name="play_measured">Sa force mesurée, sur l’échelle du blitz Lichess.</string>
|
||||
<string name="play_download_note">Maia est téléchargée une seule fois (%1$s Mo, depuis huggingface.co, le fichier des auteurs eux-mêmes).</string>
|
||||
<string name="play_download_and_play">Télécharger et jouer</string>
|
||||
<string name="play_play">Jouer</string>
|
||||
<string name="play_thinking">réfléchit…</string>
|
||||
<string name="play_event">Partie contre l’ordinateur</string>
|
||||
<string name="play_analyse">Analyser</string>
|
||||
<string name="play_rematch">↻ Revanche</string>
|
||||
<string name="play_from_here">Jouer à partir d’ici…</string>
|
||||
<string name="play_checking">Vérification…</string>
|
||||
<string name="play_maia_failed">Maia n’a pas démarré : %1$s</string>
|
||||
<string name="play_accept_win">Accepter la victoire</string>
|
||||
<string name="play_to_end">Jouer jusqu’au bout</string>
|
||||
<string name="play_maia_resigns">Maia abandonne</string>
|
||||
<string name="play_note_from">À partir d’ici, une partie contre Maia %1$s.</string>
|
||||
<string name="play_abort">Abandonner</string>
|
||||
<string name="play_with_maia">Jouer contre Maia</string>
|
||||
<string name="play_your_name">Votre nom (pour la partie)</string>
|
||||
<string name="play_maia_ready">Maia est téléchargée</string>
|
||||
<string name="play_retry">Réessayer</string>
|
||||
<string name="play_her_position_lost">Sa position est perdue. Accepter la victoire ou continuer ?</string>
|
||||
<string name="play_continue">Continuer</string>
|
||||
<string name="play_adjourned">Partie contre Maia %1$s · vous jouez %2$s</string>
|
||||
<string name="play_as_white">les Blancs</string>
|
||||
<string name="play_as_black">les Noirs</string>
|
||||
<string name="play_removed">Partie supprimée</string>
|
||||
<string name="play_untimed">sans pendule</string>
|
||||
<string name="play_you">Vous</string>
|
||||
<string name="play_saved">✓ Enregistrée</string>
|
||||
<string name="play_save">Enregistrer…</string>
|
||||
<string name="play_adjourned_sub">vous jouez %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Continuer d’ici contre Maia…</string>
|
||||
<string name="play_from_label">Après %1$s</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -469,4 +469,56 @@
|
|||
<item quantity="other">%1$d ripassi</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">Maia per ChessPenguin</string>
|
||||
<string name="play_won">Hai vinto</string>
|
||||
<string name="play_lost">Hai perso</string>
|
||||
<string name="play_you_resigned">Hai abbandonato</string>
|
||||
<string name="play_draw">Patta</string>
|
||||
<string name="end_mate">scacco matto</string>
|
||||
<string name="end_stalemate">stallo</string>
|
||||
<string name="end_threefold">la posizione si è ripetuta tre volte</string>
|
||||
<string name="end_fifty">50 mosse senza catture né mosse di pedone</string>
|
||||
<string name="end_material">nessuno dei due può dare matto</string>
|
||||
<string name="end_maia_resigned">Maia ha abbandonato</string>
|
||||
<string name="play_resign_q">Abbandonare?</string>
|
||||
<string name="play_resign">⚑ Abbandona</string>
|
||||
<string name="play_take_back">↶ Ritira mossa</string>
|
||||
<string name="play_title">Gioca contro il computer</string>
|
||||
<string name="play_colour">Il tuo colore</string>
|
||||
<string name="color_white">Bianco</string>
|
||||
<string name="color_black">Nero</string>
|
||||
<string name="color_random">Casuale</string>
|
||||
<string name="play_opponent">Avversario — Maia %1$s</string>
|
||||
<string name="play_measured">La sua forza misurata, sulla scala del blitz di Lichess.</string>
|
||||
<string name="play_download_note">Maia si scarica una sola volta (%1$s MB, da huggingface.co, il file degli autori stessi).</string>
|
||||
<string name="play_download_and_play">Scarica e gioca</string>
|
||||
<string name="play_play">Gioca</string>
|
||||
<string name="play_thinking">sta pensando…</string>
|
||||
<string name="play_event">Partita contro il computer</string>
|
||||
<string name="play_analyse">Analizza</string>
|
||||
<string name="play_rematch">↻ Rivincita</string>
|
||||
<string name="play_from_here">Gioca da qui…</string>
|
||||
<string name="play_checking">Controllo…</string>
|
||||
<string name="play_maia_failed">Maia non si è avviata: %1$s</string>
|
||||
<string name="play_accept_win">Accetta la vittoria</string>
|
||||
<string name="play_to_end">Gioca fino alla fine</string>
|
||||
<string name="play_maia_resigns">Maia abbandona</string>
|
||||
<string name="play_note_from">Da qui, una partita contro Maia %1$s.</string>
|
||||
<string name="play_abort">Annulla</string>
|
||||
<string name="play_with_maia">Gioca con Maia</string>
|
||||
<string name="play_your_name">Il tuo nome (per la partita)</string>
|
||||
<string name="play_maia_ready">Maia è scaricata</string>
|
||||
<string name="play_retry">Riprova</string>
|
||||
<string name="play_her_position_lost">La sua posizione è persa. Accettare la vittoria o continuare?</string>
|
||||
<string name="play_continue">Continua</string>
|
||||
<string name="play_adjourned">Partita contro Maia %1$s · giochi con %2$s</string>
|
||||
<string name="play_as_white">il Bianco</string>
|
||||
<string name="play_as_black">il Nero</string>
|
||||
<string name="play_removed">Partita rimossa</string>
|
||||
<string name="play_untimed">senza orologio</string>
|
||||
<string name="play_you">Tu</string>
|
||||
<string name="play_saved">✓ Salvata</string>
|
||||
<string name="play_save">Salva…</string>
|
||||
<string name="play_adjourned_sub">giochi con %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Continua da qui contro Maia…</string>
|
||||
<string name="play_from_label">Dopo %1$s</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -462,4 +462,56 @@
|
|||
<item quantity="other">%1$d рет</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">ChessPenguin үшін Maia</string>
|
||||
<string name="play_won">Сіз жеңдіңіз</string>
|
||||
<string name="play_lost">Сіз жеңілдіңіз</string>
|
||||
<string name="play_you_resigned">Сіз берілдіңіз</string>
|
||||
<string name="play_draw">Тең ойын</string>
|
||||
<string name="end_mate">мат</string>
|
||||
<string name="end_stalemate">пат</string>
|
||||
<string name="end_threefold">позиция үш рет қайталанды</string>
|
||||
<string name="end_fifty">50 жүріс бойы алу да, пешка жүрісі де жоқ</string>
|
||||
<string name="end_material">ешбір жақ мат қоя алмайды</string>
|
||||
<string name="end_maia_resigned">Maia берілді</string>
|
||||
<string name="play_resign_q">Берілесіз бе?</string>
|
||||
<string name="play_resign">⚑ Берілу</string>
|
||||
<string name="play_take_back">↶ Жүрісті қайтару</string>
|
||||
<string name="play_title">Компьютермен ойнау</string>
|
||||
<string name="play_colour">Түсіңіз</string>
|
||||
<string name="color_white">Ақтар</string>
|
||||
<string name="color_black">Қаралар</string>
|
||||
<string name="color_random">Кездейсоқ</string>
|
||||
<string name="play_opponent">Қарсылас — Maia %1$s</string>
|
||||
<string name="play_measured">Оның өлшенген күші, Lichess блиц шкаласы бойынша.</string>
|
||||
<string name="play_download_note">Maia бір рет жүктеледі (%1$s МБ, huggingface.co сайтынан — авторлардың өз файлы).</string>
|
||||
<string name="play_download_and_play">Жүктеп алып ойнау</string>
|
||||
<string name="play_play">Ойнау</string>
|
||||
<string name="play_thinking">ойлануда…</string>
|
||||
<string name="play_event">Компьютермен партия</string>
|
||||
<string name="play_analyse">Талдау</string>
|
||||
<string name="play_rematch">↻ Реванш</string>
|
||||
<string name="play_from_here">Осы жерден ойнау…</string>
|
||||
<string name="play_checking">Тексерілуде…</string>
|
||||
<string name="play_maia_failed">Maia іске қосылмады: %1$s</string>
|
||||
<string name="play_accept_win">Жеңісті қабылдау</string>
|
||||
<string name="play_to_end">Соңына дейін ойнау</string>
|
||||
<string name="play_maia_resigns">Maia беріледі</string>
|
||||
<string name="play_note_from">Бұдан әрі — Maia %1$s-мен ойын.</string>
|
||||
<string name="play_abort">Тоқтату</string>
|
||||
<string name="play_with_maia">Maia-мен ойнау</string>
|
||||
<string name="play_your_name">Атыңыз (ойын жазбасы үшін)</string>
|
||||
<string name="play_maia_ready">Maia жүктелді</string>
|
||||
<string name="play_retry">Қайталау</string>
|
||||
<string name="play_her_position_lost">Оның позициясы ұтылды. Жеңісті қабылдайсыз ба, әлде жалғастырасыз ба?</string>
|
||||
<string name="play_continue">Жалғастыру</string>
|
||||
<string name="play_adjourned">Maia %1$s-мен ойын · сіз %2$s</string>
|
||||
<string name="play_as_white">ақпен</string>
|
||||
<string name="play_as_black">қарамен</string>
|
||||
<string name="play_removed">Ойын жойылды</string>
|
||||
<string name="play_untimed">сағатсыз</string>
|
||||
<string name="play_you">Сіз</string>
|
||||
<string name="play_saved">✓ Сақталды</string>
|
||||
<string name="play_save">Сақтау…</string>
|
||||
<string name="play_adjourned_sub">сіз %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Осы жерден Maia-мен жалғастыру…</string>
|
||||
<string name="play_from_label">%1$s кейін</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -470,4 +470,56 @@
|
|||
<item quantity="other">%1$d passagens</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">Maia para o ChessPenguin</string>
|
||||
<string name="play_won">Você venceu</string>
|
||||
<string name="play_lost">Você perdeu</string>
|
||||
<string name="play_you_resigned">Você abandonou</string>
|
||||
<string name="play_draw">Empate</string>
|
||||
<string name="end_mate">xeque-mate</string>
|
||||
<string name="end_stalemate">afogamento</string>
|
||||
<string name="end_threefold">a posição se repetiu três vezes</string>
|
||||
<string name="end_fifty">50 lances sem captura nem lance de peão</string>
|
||||
<string name="end_material">nenhum lado consegue dar mate</string>
|
||||
<string name="end_maia_resigned">Maia desistiu</string>
|
||||
<string name="play_resign_q">Abandonar?</string>
|
||||
<string name="play_resign">⚑ Abandonar</string>
|
||||
<string name="play_take_back">↶ Voltar lance</string>
|
||||
<string name="play_title">Jogar contra o computador</string>
|
||||
<string name="play_colour">Sua cor</string>
|
||||
<string name="color_white">Brancas</string>
|
||||
<string name="color_black">Pretas</string>
|
||||
<string name="color_random">Aleatório</string>
|
||||
<string name="play_opponent">Adversário — Maia %1$s</string>
|
||||
<string name="play_measured">A força medida dela, na escala de blitz do Lichess.</string>
|
||||
<string name="play_download_note">A Maia é baixada uma única vez (%1$s MB, de huggingface.co, o arquivo dos próprios autores).</string>
|
||||
<string name="play_download_and_play">Baixar e jogar</string>
|
||||
<string name="play_play">Jogar</string>
|
||||
<string name="play_thinking">pensando…</string>
|
||||
<string name="play_event">Partida contra o computador</string>
|
||||
<string name="play_analyse">Analisar</string>
|
||||
<string name="play_rematch">↻ Revanche</string>
|
||||
<string name="play_from_here">Jogar a partir daqui…</string>
|
||||
<string name="play_checking">Verificando…</string>
|
||||
<string name="play_maia_failed">A Maia não iniciou: %1$s</string>
|
||||
<string name="play_accept_win">Aceitar a vitória</string>
|
||||
<string name="play_to_end">Jogar até o fim</string>
|
||||
<string name="play_maia_resigns">Maia desiste</string>
|
||||
<string name="play_note_from">A partir daqui, uma partida contra Maia %1$s.</string>
|
||||
<string name="play_abort">Abortar</string>
|
||||
<string name="play_with_maia">Jogar com a Maia</string>
|
||||
<string name="play_your_name">Seu nome (para a partida)</string>
|
||||
<string name="play_maia_ready">A Maia foi baixada</string>
|
||||
<string name="play_retry">Tentar de novo</string>
|
||||
<string name="play_her_position_lost">A posição dela está perdida. Aceitar a vitória ou continuar?</string>
|
||||
<string name="play_continue">Continuar</string>
|
||||
<string name="play_adjourned">Partida contra a Maia %1$s · você joga de %2$s</string>
|
||||
<string name="play_as_white">brancas</string>
|
||||
<string name="play_as_black">pretas</string>
|
||||
<string name="play_removed">Partida removida</string>
|
||||
<string name="play_untimed">sem relógio</string>
|
||||
<string name="play_you">Você</string>
|
||||
<string name="play_saved">✓ Salva</string>
|
||||
<string name="play_save">Salvar…</string>
|
||||
<string name="play_adjourned_sub">você joga de %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Continuar daqui contra a Maia…</string>
|
||||
<string name="play_from_label">Depois de %1$s</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -477,4 +477,56 @@
|
|||
<item quantity="other">прохождений: %1$d</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">Maia для ChessPenguin</string>
|
||||
<string name="play_won">Вы выиграли</string>
|
||||
<string name="play_lost">Вы проиграли</string>
|
||||
<string name="play_you_resigned">Вы сдались</string>
|
||||
<string name="play_draw">Ничья</string>
|
||||
<string name="end_mate">мат</string>
|
||||
<string name="end_stalemate">пат</string>
|
||||
<string name="end_threefold">позиция повторилась трижды</string>
|
||||
<string name="end_fifty">50 ходов без взятий и ходов пешек</string>
|
||||
<string name="end_material">ни у кого нет материала для мата</string>
|
||||
<string name="end_maia_resigned">Maia сдалась</string>
|
||||
<string name="play_resign_q">Сдаться?</string>
|
||||
<string name="play_resign">⚑ Сдаться</string>
|
||||
<string name="play_take_back">↶ Ход назад</string>
|
||||
<string name="play_title">Игра с компьютером</string>
|
||||
<string name="play_colour">Цвет</string>
|
||||
<string name="color_white">Белые</string>
|
||||
<string name="color_black">Чёрные</string>
|
||||
<string name="color_random">Случайно</string>
|
||||
<string name="play_opponent">Соперник — Maia %1$s</string>
|
||||
<string name="play_measured">Её измеренная сила, по шкале блица Lichess.</string>
|
||||
<string name="play_download_note">Maia скачивается один раз (%1$s МБ, с huggingface.co — файл самих авторов).</string>
|
||||
<string name="play_download_and_play">Скачать и играть</string>
|
||||
<string name="play_play">Играть</string>
|
||||
<string name="play_thinking">думает…</string>
|
||||
<string name="play_event">Партия с компьютером</string>
|
||||
<string name="play_analyse">Анализировать</string>
|
||||
<string name="play_rematch">↻ Реванш</string>
|
||||
<string name="play_from_here">Играть отсюда…</string>
|
||||
<string name="play_checking">Проверяю…</string>
|
||||
<string name="play_maia_failed">Maia не запустилась: %1$s</string>
|
||||
<string name="play_accept_win">Принять победу</string>
|
||||
<string name="play_to_end">Играть до конца</string>
|
||||
<string name="play_maia_resigns">Maia сдаётся</string>
|
||||
<string name="play_note_from">Дальше — игра с Maia %1$s.</string>
|
||||
<string name="play_abort">Прервать</string>
|
||||
<string name="play_with_maia">Играть с Maia</string>
|
||||
<string name="play_your_name">Ваше имя (для записи партии)</string>
|
||||
<string name="play_maia_ready">Maia скачана</string>
|
||||
<string name="play_retry">Повторить</string>
|
||||
<string name="play_her_position_lost">Её позиция проиграна. Принять победу или доиграть?</string>
|
||||
<string name="play_continue">Продолжить</string>
|
||||
<string name="play_adjourned">Партия с Maia %1$s · вы %2$s</string>
|
||||
<string name="play_as_white">белыми</string>
|
||||
<string name="play_as_black">чёрными</string>
|
||||
<string name="play_removed">Партия удалена</string>
|
||||
<string name="play_untimed">без часов</string>
|
||||
<string name="play_you">Вы</string>
|
||||
<string name="play_saved">✓ Сохранено</string>
|
||||
<string name="play_save">Сохранить…</string>
|
||||
<string name="play_adjourned_sub">вы %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Играть отсюда с Maia…</string>
|
||||
<string name="play_from_label">После %1$s</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -460,4 +460,56 @@
|
|||
<item quantity="other">%1$d marta</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">ChessPenguin uchun Maia</string>
|
||||
<string name="play_won">Siz yutdingiz</string>
|
||||
<string name="play_lost">Siz yutqazdingiz</string>
|
||||
<string name="play_you_resigned">Siz taslim bo‘ldingiz</string>
|
||||
<string name="play_draw">Durang</string>
|
||||
<string name="end_mate">mat</string>
|
||||
<string name="end_stalemate">pat</string>
|
||||
<string name="end_threefold">pozitsiya uch marta takrorlandi</string>
|
||||
<string name="end_fifty">50 yurish davomida olish ham, piyoda yurishi ham yo‘q</string>
|
||||
<string name="end_material">hech bir tomon mat qila olmaydi</string>
|
||||
<string name="end_maia_resigned">Maia taslim bo‘ldi</string>
|
||||
<string name="play_resign_q">Taslim bo‘lasizmi?</string>
|
||||
<string name="play_resign">⚑ Taslim bo‘lish</string>
|
||||
<string name="play_take_back">↶ Yurishni qaytarish</string>
|
||||
<string name="play_title">Kompyuter bilan o‘ynash</string>
|
||||
<string name="play_colour">Rangingiz</string>
|
||||
<string name="color_white">Oqlar</string>
|
||||
<string name="color_black">Qoralar</string>
|
||||
<string name="color_random">Tasodifiy</string>
|
||||
<string name="play_opponent">Raqib — Maia %1$s</string>
|
||||
<string name="play_measured">Uning o‘lchangan kuchi, Lichess blits shkalasi bo‘yicha.</string>
|
||||
<string name="play_download_note">Maia bir marta yuklab olinadi (%1$s MB, huggingface.co dan — mualliflarning o‘z fayli).</string>
|
||||
<string name="play_download_and_play">Yuklab olish va o‘ynash</string>
|
||||
<string name="play_play">O‘ynash</string>
|
||||
<string name="play_thinking">o‘ylamoqda…</string>
|
||||
<string name="play_event">Kompyuter bilan partiya</string>
|
||||
<string name="play_analyse">Tahlil qilish</string>
|
||||
<string name="play_rematch">↻ Revansh</string>
|
||||
<string name="play_from_here">Shu yerdan o‘ynash…</string>
|
||||
<string name="play_checking">Tekshirilmoqda…</string>
|
||||
<string name="play_maia_failed">Maia ishga tushmadi: %1$s</string>
|
||||
<string name="play_accept_win">G‘alabani qabul qilish</string>
|
||||
<string name="play_to_end">Oxirigacha o‘ynash</string>
|
||||
<string name="play_maia_resigns">Maia taslim bo‘lmoqda</string>
|
||||
<string name="play_note_from">Bundan keyin — Maia %1$s bilan o‘yin.</string>
|
||||
<string name="play_abort">To‘xtatish</string>
|
||||
<string name="play_with_maia">Maia bilan o‘ynash</string>
|
||||
<string name="play_your_name">Ismingiz (o‘yin yozuvi uchun)</string>
|
||||
<string name="play_maia_ready">Maia yuklab olindi</string>
|
||||
<string name="play_retry">Qayta urinish</string>
|
||||
<string name="play_her_position_lost">Uning pozitsiyasi yutqazilgan. G‘alabani qabul qilasizmi yoki davom etasizmi?</string>
|
||||
<string name="play_continue">Davom ettirish</string>
|
||||
<string name="play_adjourned">Maia %1$s bilan o‘yin · siz %2$s</string>
|
||||
<string name="play_as_white">oqlar bilan</string>
|
||||
<string name="play_as_black">qoralar bilan</string>
|
||||
<string name="play_removed">O‘yin o‘chirildi</string>
|
||||
<string name="play_untimed">soatsiz</string>
|
||||
<string name="play_you">Siz</string>
|
||||
<string name="play_saved">✓ Saqlandi</string>
|
||||
<string name="play_save">Saqlash…</string>
|
||||
<string name="play_adjourned_sub">siz %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Shu yerdan Maia bilan davom ettirish…</string>
|
||||
<string name="play_from_label">%1$s dan keyin</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -465,4 +465,56 @@
|
|||
<item quantity="other">%1$d runs</item>
|
||||
</plurals>
|
||||
<string name="maia_download_title">Maia for ChessPenguin</string>
|
||||
<string name="play_won">You won</string>
|
||||
<string name="play_lost">You lost</string>
|
||||
<string name="play_you_resigned">You resigned</string>
|
||||
<string name="play_draw">Draw</string>
|
||||
<string name="end_mate">checkmate</string>
|
||||
<string name="end_stalemate">stalemate</string>
|
||||
<string name="end_threefold">the position occurred three times</string>
|
||||
<string name="end_fifty">50 moves without a capture or a pawn move</string>
|
||||
<string name="end_material">neither side can checkmate</string>
|
||||
<string name="end_maia_resigned">Maia resigned</string>
|
||||
<string name="play_resign_q">Resign?</string>
|
||||
<string name="play_resign">⚑ Resign</string>
|
||||
<string name="play_take_back">↶ Take back</string>
|
||||
<string name="play_title">Play against the computer</string>
|
||||
<string name="play_colour">Your colour</string>
|
||||
<string name="color_white">White</string>
|
||||
<string name="color_black">Black</string>
|
||||
<string name="color_random">Random</string>
|
||||
<string name="play_opponent">Opponent — Maia %1$s</string>
|
||||
<string name="play_measured">Her measured strength, on the Lichess blitz scale.</string>
|
||||
<string name="play_download_note">Maia is downloaded once (%1$s MB, from huggingface.co, the authors\' own file).</string>
|
||||
<string name="play_download_and_play">Download and play</string>
|
||||
<string name="play_play">Play</string>
|
||||
<string name="play_thinking">thinking…</string>
|
||||
<string name="play_event">Game vs computer</string>
|
||||
<string name="play_analyse">Analyse</string>
|
||||
<string name="play_rematch">↻ Rematch</string>
|
||||
<string name="play_from_here">Play on from here…</string>
|
||||
<string name="play_checking">Checking…</string>
|
||||
<string name="play_maia_failed">Maia did not start: %1$s</string>
|
||||
<string name="play_accept_win">Accept the win</string>
|
||||
<string name="play_to_end">Play to the end</string>
|
||||
<string name="play_maia_resigns">Maia resigns</string>
|
||||
<string name="play_note_from">From here on, a game against Maia %1$s.</string>
|
||||
<string name="play_abort">Abort</string>
|
||||
<string name="play_with_maia">Play with Maia</string>
|
||||
<string name="play_your_name">Your name (for the game’s record)</string>
|
||||
<string name="play_maia_ready">Maia is downloaded</string>
|
||||
<string name="play_retry">Try again</string>
|
||||
<string name="play_her_position_lost">Her position is lost. Accept the win or play on?</string>
|
||||
<string name="play_continue">Continue</string>
|
||||
<string name="play_adjourned">Game against Maia %1$s · you play %2$s</string>
|
||||
<string name="play_as_white">White</string>
|
||||
<string name="play_as_black">Black</string>
|
||||
<string name="play_removed">Game removed</string>
|
||||
<string name="play_untimed">no clock</string>
|
||||
<string name="play_you">You</string>
|
||||
<string name="play_saved">✓ Saved</string>
|
||||
<string name="play_save">Save…</string>
|
||||
<string name="play_adjourned_sub">you play %1$s · %2$s</string>
|
||||
<string name="play_from_maia">Play on from here with Maia…</string>
|
||||
<string name="play_from_label">After %1$s</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -197,6 +197,19 @@ impl GameSession {
|
|||
})
|
||||
}
|
||||
|
||||
/// Adds `text` to the comments after the move at place `at` (its symbols kept).
|
||||
pub fn add_comment(&self, at: u32, text: String) -> Result<Edited, ApiError> {
|
||||
self.with(|g| {
|
||||
let id = node(g, at)?;
|
||||
let n = g.node(id).ok_or(ApiError::NoNode { place: at })?;
|
||||
let nags = n.nags().to_vec();
|
||||
let mut comments = n.comments_after().to_vec();
|
||||
comments.push(text);
|
||||
g.annotate(id, nags, comments)?;
|
||||
Ok(edited(g, id))
|
||||
})
|
||||
}
|
||||
|
||||
/// Changed since it was opened or last saved.
|
||||
pub fn is_modified(&self) -> bool {
|
||||
self.with(|g| g.is_modified())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue