flutter: Remove unused analyze.dart

This commit is contained in:
Calcitem 2021-03-07 22:48:07 +08:00
parent b35fa960ae
commit eb9c3d39cd
2 changed files with 0 additions and 87 deletions

View File

@ -1,55 +0,0 @@
/*
This file is part of Sanmill.
Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file)
Sanmill is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Sanmill is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class AnalyzeItem {
String move, moveName;
int score;
double winRate;
AnalyzeItem({this.move, this.score, this.winRate});
@override
String toString() {
return '{move: ${moveName ?? move}, score: $score, winRate: $winRate}';
}
}
class AnalyzeFetcher {
static List<AnalyzeItem> fetch(String response, {limit = 5}) {
final segments = response.split('|');
List<AnalyzeItem> result = [];
final regExp = RegExp(r'move:(.{4}).+score:(\-?\d+).+winRate:(\d+.?\d*)');
for (var segment in segments) {
final match = regExp.firstMatch(segment);
if (match == null) break;
final move = match.group(1);
final score = int.parse(match.group(2));
final winRate = double.parse(match.group(3));
result.add(AnalyzeItem(move: move, score: score, winRate: winRate));
if (result.length == limit) break;
}
return result;
}
}

View File

@ -19,7 +19,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:sanmill/common/config.dart';
import 'package:sanmill/engine/analyze.dart';
import 'package:sanmill/engine/engine.dart';
import 'package:sanmill/engine/native_engine.dart';
import 'package:sanmill/generated/l10n.dart';
@ -283,37 +282,6 @@ class _GamePageState extends State<GamePage> with RouteAware {
setState(() => _searching = true);
}
showAnalyzeItems(
BuildContext context, {
String title,
List<AnalyzeItem> items,
Function(AnalyzeItem item) callback,
}) {
final List<Widget> children = [];
for (var item in items) {
children.add(
ListTile(
title: Text(item.moveName, style: TextStyle(fontSize: 18)),
subtitle: Text(S.of(context).winRate + ": ${item.winRate}%"),
trailing: Text(S.of(context).score + ": ${item.score}'"),
onTap: () => callback(item),
),
);
children.add(Divider());
}
children.insert(0, SizedBox(height: 10));
children.add(SizedBox(height: 56));
showModalBottomSheet(
context: context,
builder: (BuildContext context) => SingleChildScrollView(
child: Column(mainAxisSize: MainAxisSize.min, children: children),
),
);
}
String getGameOverReasonString(GameOverReason reason, String winner) {
String loseReasonStr;
//String winnerStr =