Skip to content

Commit bdf492e

Browse files
delete deprecated functions (#83)
* delete deprecated functions * bump version * analyzer * fix file name
1 parent ad719bf commit bdf492e

9 files changed

Lines changed: 11 additions & 315 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.5.0
2+
3+
- delete deprecated functions.
4+
- `computeBestPathNumWithLink`
5+
- `streamOfBestPathNumWithLink`
6+
17
# 1.4.0
28

39
- enable `edaxBookCountBestpath` to receive Board param.

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ packages:
9191
path: ".."
9292
relative: true
9393
source: path
94-
version: "1.4.0"
94+
version: "1.5.0"
9595
meta:
9696
dependency: transitive
9797
description:

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: libedax4dart_example
2-
version: 1.4.0-example
2+
version: 1.5.0-example
33
publish_to: none
44

55
environment:

lib/libedax4dart.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/// dart wrapper for libedax
22
library libedax4dart;
33

4-
export 'src/best_path_num_with_link.dart';
54
export 'src/board.dart';
65
export 'src/constants.dart';
7-
export 'src/count_best_path_result.dart';
6+
export 'src/count_bestpath_result.dart';
87
export 'src/hint.dart';
98
export 'src/libedax.dart';
109
export 'src/link.dart';

lib/src/best_path_num_with_link.dart

Lines changed: 0 additions & 87 deletions
This file was deleted.

lib/src/libedax.dart

Lines changed: 1 addition & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import 'dart:ffi';
2-
import 'dart:math';
32

43
import 'package:ffi/ffi.dart';
54
import 'package:meta/meta.dart';
65

7-
import 'best_path_num_with_link.dart';
86
import 'board.dart';
97
import 'constants.dart';
10-
import 'count_best_path_result.dart';
8+
import 'count_bestpath_result.dart';
119
import 'ffi/bindings/bindings.dart';
1210
import 'ffi/bindings/structs/board.dart' as c_board;
1311
import 'ffi/bindings/structs/hint.dart' as c_hint;
@@ -19,7 +17,6 @@ import 'hint.dart';
1917
import 'move.dart';
2018
import 'move_list_with_position.dart';
2119
import 'position.dart';
22-
import 'util.dart';
2320

2421
@immutable
2522
class LibEdax {
@@ -376,148 +373,4 @@ class LibEdax {
376373
/// Stop edaxBookCountBestpath
377374
@experimental
378375
void edaxBookStopCountBestpath() => _bindings.edaxBookStopCountBestpath();
379-
380-
/// Compute the indicator of efficiency to win, which means the minimum number you should memorize on the situation both of players always choose one of the best move list.
381-
///
382-
/// [level] is search depth. <br>
383-
/// If [onlyBestScoreLink] is true, only compute the best score links on the current moves.
384-
///
385-
/// This is a Dart level function, and unique feature to libedax4dart.
386-
///
387-
/// btw, you can also see the graph of tree generated by this function, with using `BestPathNumWithLink.root.exportGraphvizDotFile()`. <br>
388-
/// e.g. on a light book, when current moves is 'f5f6', you can get a graph like this([graphviz online](https://bit.ly/3edxWGO)).
389-
///
390-
/// This function is not only experimental but also __advanced__. <br>
391-
/// __You must understand [the book structure of edax](https://choi.lavox.net/edax/book) and following important notice list__.
392-
///
393-
/// * Because internal each node lookup is stopped when book has no links, the more lower the accuracy of your book is, the more lower this feature accuracy is.
394-
/// * In addition, if your book has some depth links (e.g. 24, 30, 40, ...), shallow depth link (≈ path is few) can be taken with a reasonable probability.
395-
/// * __In a word, if the accuracy of your book is low, you shoudn't use this function__. For you reference, if your book has N GB and the depth is more than 30, this feature can probably be inidicator.
396-
/// * This function only lookup the best score links. So, this indicator can't consider easy win links which is _not_ best score. In reversi game, the situation can sometimes be found in my experience as a player.
397-
/// * __In a word, as you know, this indicator isn't perfect. This is just a indicator__.
398-
/// * The depth of this feature depends on [level] or your book.
399-
/// * The moves which meet up with anoter moves is counted respectively.
400-
/// * btw, symmetric moves is counted 1 because of edax book structure.
401-
/// * O(k^N). slow.
402-
/// * TODO(developer): consider following implementation.
403-
/// * isolation.
404-
/// * save tree data on local.
405-
///
406-
/// REF: https://github.com/abulmo/edax-reversi/blob/1ae7c9fe5322ac01975f1b3196e788b0d25c1e10/src/book.c#L2438-L2447
407-
@Deprecated('use edax_book_count_bestpath and edax_book_stop_count_bestpath')
408-
@experimental
409-
List<BestPathNumWithLink> computeBestPathNumWithLink({
410-
required final int level,
411-
final bool onlyBestScoreLink = true,
412-
final bool enableToPrintMovesOnBuildingTree = false,
413-
}) {
414-
final headMoves = edaxGetMoves();
415-
final maxDepth = headMoves.length + level * 2;
416-
if (headMoves.isEmpty || headMoves.length >= maxDepth) return [];
417-
418-
final headColor = edaxGetCurrentPlayer();
419-
final moveListWithPosition = edaxGetBookMoveWithPositionByMoves(headMoves);
420-
final position = moveListWithPosition.position;
421-
final targetRootLinks = onlyBestScoreLink ? position.bestScoreLinks : position.links;
422-
423-
return targetRootLinks.map((final link) {
424-
final move = symetryMove(link.move, moveListWithPosition.symetry);
425-
final root = BestPathNumNode(
426-
null,
427-
BestPathNumNodeValue(
428-
headMoves + move2String(move),
429-
headColor == TurnColor.black ? TurnColor.white : TurnColor.black,
430-
),
431-
);
432-
_buildTree(root, maxDepth, enableToPrintMovesOnBuildingTree);
433-
return BestPathNumWithLink(
434-
root.value.bestPathNumOfBlack,
435-
root.value.bestPathNumOfWhite,
436-
link,
437-
move,
438-
root,
439-
);
440-
}).toList();
441-
}
442-
443-
/// See: [computeBestPathNumWithLink]
444-
///
445-
/// you can get BestPathNumWithLink one by one.
446-
@Deprecated('use edax_book_count_bestpath and edax_book_stop_count_bestpath')
447-
@experimental
448-
Stream<BestPathNumWithLink> streamOfBestPathNumWithLink({
449-
required final int level,
450-
final bool onlyBestScoreLink = true,
451-
final bool enableToPrintMovesOnBuildingTree = false,
452-
}) async* {
453-
final headMoves = edaxGetMoves();
454-
final maxDepth = headMoves.length + level * 2;
455-
if (headMoves.isEmpty || headMoves.length >= maxDepth) return;
456-
457-
final headColor = edaxGetCurrentPlayer();
458-
final moveListWithPosition = edaxGetBookMoveWithPositionByMoves(headMoves);
459-
final position = moveListWithPosition.position;
460-
final targetRootLinks = onlyBestScoreLink ? position.bestScoreLinks : position.links;
461-
462-
for (final link in targetRootLinks) {
463-
final move = symetryMove(link.move, moveListWithPosition.symetry);
464-
final root = BestPathNumNode(
465-
null,
466-
BestPathNumNodeValue(
467-
headMoves + move2String(move),
468-
headColor == TurnColor.black ? TurnColor.white : TurnColor.black,
469-
),
470-
);
471-
_buildTree(root, maxDepth, enableToPrintMovesOnBuildingTree);
472-
yield BestPathNumWithLink(
473-
root.value.bestPathNumOfBlack,
474-
root.value.bestPathNumOfWhite,
475-
link,
476-
move,
477-
root,
478-
);
479-
}
480-
}
481-
482-
@Deprecated('use edax_book_count_bestpath and edax_book_stop_count_bestpath')
483-
void _buildTree(final BestPathNumNode parent, final int maxDepth, final bool enableToPrintMovesOnBuildingTree) {
484-
if (parent.value.moves.length >= maxDepth) {
485-
// On edge, reagard (1,1) .
486-
parent.value.bestPathNumOfBlack = 1;
487-
parent.value.bestPathNumOfWhite = 1;
488-
return;
489-
}
490-
final moveListWithPosition = edaxGetBookMoveWithPositionByMoves(parent.value.moves);
491-
final position = moveListWithPosition.position;
492-
if (position.links.isEmpty) {
493-
// On edge, reagard (1,1) .
494-
parent.value.bestPathNumOfBlack = 1;
495-
parent.value.bestPathNumOfWhite = 1;
496-
return;
497-
}
498-
499-
final addedNodeList = position.bestScoreLinks.map((final link) {
500-
final move = symetryMove(link.move, moveListWithPosition.symetry);
501-
final node = BestPathNumNode(
502-
parent,
503-
BestPathNumNodeValue(
504-
parent.value.moves + move2String(move),
505-
parent.value.currentColor == TurnColor.black ? TurnColor.white : TurnColor.black,
506-
),
507-
);
508-
if (enableToPrintMovesOnBuildingTree) print(node.value.moves); // ignore: avoid_print
509-
_buildTree(node, maxDepth, enableToPrintMovesOnBuildingTree);
510-
return node;
511-
});
512-
for (final addedNode in addedNodeList) {
513-
parent.children.add(addedNode);
514-
if (parent.value.currentColor == TurnColor.black) {
515-
parent.value.bestPathNumOfWhite += addedNode.value.bestPathNumOfWhite;
516-
parent.value.bestPathNumOfBlack = min(parent.value.bestPathNumOfBlack, addedNode.value.bestPathNumOfBlack);
517-
} else {
518-
parent.value.bestPathNumOfBlack += addedNode.value.bestPathNumOfBlack;
519-
parent.value.bestPathNumOfWhite = min(parent.value.bestPathNumOfWhite, addedNode.value.bestPathNumOfWhite);
520-
}
521-
}
522-
}
523376
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See: https://dart.dev/tools/pub/publishing
22

33
name: libedax4dart
4-
version: 1.4.0
4+
version: 1.5.0
55
description: Dart wrapper for libedax. With using libedax4dart, you can execute functions equivalent to edax.
66
homepage: https://github.com/sensuikan1973/libedax4dart
77
documentation: https://sensuikan1973.github.io/libedax4dart

test/edax_command_test.dart

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -311,81 +311,6 @@ void main() {
311311
..edaxBookStopCountBestpath()
312312
..libedaxTerminate();
313313
});
314-
315-
group('Deprecated functions', () {
316-
group('computeBestPathNumWithLink', () {
317-
test('with no moves', () {
318-
const initParams = ['', '-book-file', _testBookFile];
319-
final edax = LibEdax()..libedaxInitialize(initParams);
320-
sleep(const Duration(seconds: 1));
321-
edax.edaxInit();
322-
final bestPathNumWithLink = edax.computeBestPathNumWithLink(level: 40);
323-
expect(bestPathNumWithLink.isEmpty, true);
324-
edax.libedaxTerminate();
325-
});
326-
327-
test('with moves f5f6', () {
328-
const initParams = ['', '-book-file', _testBookFile];
329-
final edax = LibEdax()..libedaxInitialize(initParams);
330-
sleep(const Duration(seconds: 1));
331-
edax
332-
..edaxInit()
333-
..edaxPlay('f5f6');
334-
final bestPathNumWithLink = edax.computeBestPathNumWithLink(level: 40);
335-
expect(bestPathNumWithLink.length, 1);
336-
expect(bestPathNumWithLink.first.moveString, 'e6');
337-
expect(bestPathNumWithLink.first.bestPathNumOfBlack, 2);
338-
expect(bestPathNumWithLink.first.bestPathNumOfWhite, 1);
339-
edax.libedaxTerminate();
340-
});
341-
342-
test('with long moves less than 40, exportGraphvizDotFile', () {
343-
const initParams = ['', '-book-file', _testBookFile];
344-
const moves = 'F5f6e6d6e7g5c5c6e3d3c7f3f4g4g3d7e8c8c4f7c2d2f2h3d8f8g6h5g7b5h7c3b4e1';
345-
final edax = LibEdax()..libedaxInitialize(initParams);
346-
sleep(const Duration(seconds: 1));
347-
edax
348-
..edaxInit()
349-
..edaxPlay(moves);
350-
final bestPathNumWithLink = edax.computeBestPathNumWithLink(level: 40);
351-
expect(bestPathNumWithLink.length, 1);
352-
print(bestPathNumWithLink.first.root.exportGraphvizDotFile()); // ignore: avoid_print
353-
expect(bestPathNumWithLink.first.moveString, 'd1');
354-
expect(bestPathNumWithLink.first.bestPathNumOfBlack, 1);
355-
expect(bestPathNumWithLink.first.bestPathNumOfWhite, 1);
356-
edax.libedaxTerminate();
357-
});
358-
359-
test('with moves greater than book level', () {
360-
const initParams = ['', '-book-file', _testBookFile];
361-
const moves = 'F5f6e6d6e7g5c5c6e3d3c7f3f4g4g3d7e8c8c4f7c2d2f2h3d8f8g6h5g7b5h7c3b4e1d1a5a4a3b2b2a2a1';
362-
final edax = LibEdax()..libedaxInitialize(initParams);
363-
sleep(const Duration(seconds: 1));
364-
edax
365-
..edaxInit()
366-
..edaxPlay(moves);
367-
final bestPathNumWithLink = edax.computeBestPathNumWithLink(level: 40);
368-
expect(bestPathNumWithLink.isEmpty, true);
369-
edax.libedaxTerminate();
370-
});
371-
});
372-
373-
group('streamOfBestPathNumWithLink', () {
374-
test('with moves f5f6', () async {
375-
const initParams = ['', '-book-file', _testBookFile];
376-
final edax = LibEdax()..libedaxInitialize(initParams);
377-
await Future<void>.delayed(const Duration(seconds: 1));
378-
edax
379-
..edaxInit()
380-
..edaxPlay('f5f6');
381-
final stream = edax.streamOfBestPathNumWithLink(level: 10);
382-
await Future<void>.delayed(const Duration(seconds: 1));
383-
final firstEvent = await stream.first;
384-
expect(firstEvent.moveString, 'e6');
385-
edax.libedaxTerminate();
386-
});
387-
});
388-
});
389314
});
390315

391316
group('util command', () {

0 commit comments

Comments
 (0)