-
-
Notifications
You must be signed in to change notification settings - Fork 366
Offline computer fixes and improvements #2678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
abc3325
157d895
d7af5b5
edfc027
b9b7f41
fcb85bf
a63fc81
15b8be7
f92cdce
e26687b
19f9abc
24104ad
d65e045
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,21 @@ sealed class SanMove with _$SanMove { | |||||
| // It's sufficient to check for O-O here, because that of course also covers O-O-O. | ||||||
| bool get isCastles => san.startsWith('O-O'); | ||||||
|
|
||||||
| /// Normalize UCI to a "king takes rook" UCI notation. | ||||||
| /// | ||||||
| /// Returns the original notation chess960 variant where this notation is already forced and | ||||||
| /// where the normalized notation could conflict with the actual move. | ||||||
| UCIMove normalizeUci(Variant variant) { | ||||||
| if (variant == Variant.chess960) { | ||||||
| return move.uci; | ||||||
| } | ||||||
| if (isCastles) { | ||||||
| return kingTakesRookCastles[move.uci] ?? move.uci; | ||||||
| } else { | ||||||
| return move.uci; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| bool isIrreversible(Variant variant) { | ||||||
| if (isCheck) return true; | ||||||
| if (variant == Variant.crazyhouse) return false; | ||||||
|
|
@@ -46,9 +61,16 @@ class MoveConverter implements JsonConverter<Move, String> { | |||||
| String toJson(Move object) => object.uci; | ||||||
| } | ||||||
|
|
||||||
| /// Alternative castling uci notations. | ||||||
| /// Get alternate castling notations from king takes rook notation, e.g. e1c1 for O-O-O and e1g1 for O-O. | ||||||
| const altCastles = {'e1a1': 'e1c1', 'e1h1': 'e1g1', 'e8a8': 'e8c8', 'e8h8': 'e8g8'}; | ||||||
|
|
||||||
| /// Get king takes rook castling notations from alternate notation, e.g. e1a1 for O-O-O and e1h1 for O-O. | ||||||
| const kingTakesRookCastles = {'e1c1': 'e1a1', 'e1g1': 'e1h1', 'e8c8': 'e8a8', 'e8g8': 'e8h8'}; | ||||||
|
|
||||||
| /// Normalizes a UCI move string for comparison by converting alternate castling notations to | ||||||
| /// standard notation. | ||||||
|
||||||
| /// standard notation. | |
| /// "king takes rook" notation (e.g. e1c1 → e1a1). |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -212,35 +212,36 @@ class EvaluationService { | |||||||||||||||||
| /// Returns a [Future] that completes with the evaluation, or `null` if no evaluation | ||||||||||||||||||
| /// could be obtained (e.g. the engine fails). | ||||||||||||||||||
| /// | ||||||||||||||||||
| /// The [work] must have a [EvalWork.searchTime] set. | ||||||||||||||||||
| /// | ||||||||||||||||||
| /// If [minDepth] is provided, the evaluation will stop early once this depth is reached. | ||||||||||||||||||
| /// Otherwise, it will run for the full [EvalWork.searchTime]. | ||||||||||||||||||
| Future<LocalEval?> findEval(EvalWork work, {int? minDepth}) async { | ||||||||||||||||||
| assert(work.searchTime != Duration.zero, 'searchTime must be set for findEval'); | ||||||||||||||||||
|
|
||||||||||||||||||
| final stream = evaluate(work); | ||||||||||||||||||
| if (stream == null) { | ||||||||||||||||||
| // do we have a cached eval? | ||||||||||||||||||
| switch (work.evalCache) { | ||||||||||||||||||
| case final LocalEval localEval: | ||||||||||||||||||
| return localEval; | ||||||||||||||||||
| case CloudEval _: | ||||||||||||||||||
| return null; | ||||||||||||||||||
| case _: | ||||||||||||||||||
| return null; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| /// If provided, the evaluation will stop at [depthThreshold], if the [minSearchTime] has passed. | ||||||||||||||||||
| /// This allows for better evaluations in high end devices while still providing quick responses in low end devices. | ||||||||||||||||||
| /// Even if [depthThreshold] is not reached, the evaluation will still stop at [EvalWork.searchTime]. | ||||||||||||||||||
|
Comment on lines
+215
to
+217
|
||||||||||||||||||
| /// If provided, the evaluation will stop at [depthThreshold], if the [minSearchTime] has passed. | |
| /// This allows for better evaluations in high end devices while still providing quick responses in low end devices. | |
| /// Even if [depthThreshold] is not reached, the evaluation will still stop at [EvalWork.searchTime]. | |
| /// If [depthThreshold] is provided, the evaluation may stop once that depth is | |
| /// reached, provided that [minSearchTime] (if given) has already elapsed. | |
| /// This allows for better evaluations in high end devices while still providing | |
| /// quick responses in low end devices. Regardless of these parameters, the | |
| /// evaluation will not run longer than [EvalWork.searchTime]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring grammar/clarity: “Returns the original notation chess960 variant …” is missing a preposition and is hard to parse. Consider rephrasing to something like “Returns the original notation in chess960, where this notation is already forced …” to make the behavior unambiguous.