Skip to content

Commit

Permalink
rename elucidator to solver
Browse files Browse the repository at this point in the history
  • Loading branch information
y-tetsu committed Jan 3, 2025
1 parent 66beb2c commit 80f4059
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ The examples to be copied are below.
- [07_minmax_strategy.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/07_minmax_strategy.py) - A example of Reversi minmax strategy
- [08_alphabeta_strategy.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/08_alphabeta_strategy.py) - A example of Reversi alpha beta AI strategy
- [09_genetic_algorithm.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/09_genetic_algorithm.py) - A example for discovering the parameters of a reversi strategy using a genetic algorithm
- [10_x_elucidator.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/10_x_elucidator.py) - Analysis tool for deformation boards
- [10_variant_board_solver.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/10_variant_board_solver.py) - Analysis tool for variant boards


You can run examples below.
Expand All @@ -129,7 +129,7 @@ $ python 06_table_strategy.py
$ python 07_minmax_strategy.py
$ python 08_alphabeta_strategy.py
$ python 09_genetic_algorithm.py
$ python 10_x_elucidator.py
$ python 10_variant_board_solver.py
```

## How to use the library
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ $ install_reversi_examples
- [07_minmax_strategy.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/07_minmax_strategy.py) - MinMax法で手を選ぶAIを実装するサンプル
- [08_alphabeta_strategy.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/08_alphabeta_strategy.py) - AlphaBeta法で手を選ぶAIを実装するサンプル
- [09_genetic_algorithm.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/09_genetic_algorithm.py) - 遺伝的アルゴリズムを使ってテーブルの重みを求めるサンプル
- [10_variant_elucidator.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/10_variant_elucidator.py) - 変則ボードの解析ツール
- [10_variant_board_solver.py](https://github.com/y-tetsu/reversi/blob/master/reversi/examples/10_variant_board_solver.py) - 変則ボードの解析ツール

サンプルの実行方法はそれぞれ下記のとおりです。
```
Expand All @@ -138,7 +138,7 @@ $ python 06_table_strategy.py
$ python 07_minmax_strategy.py
$ python 08_alphabeta_strategy.py
$ python 09_genetic_algorithm.py
$ python 10_variant_elucidator.py
$ python 10_variant_board_solver.py
```


Expand Down
4 changes: 2 additions & 2 deletions reversi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .error_message import ErrorMessage
from .recorder import Recorder
from .app import Reversi, Reversic
from .elucidator import Elucidator
from .solver import Solver
from .simulator import Simulator
from . import strategies
from . import genetic_algorithm
Expand Down Expand Up @@ -37,7 +37,7 @@
'Reversi',
'Reversic',
'Recorder',
'Elucidator',
'Solver',
'Simulator',
'strategies',
'genetic_algorithm',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""A example of variant-board elucidator
"""A example of variant-board solver
"""

import os
import re
import json

from reversi import BitBoard, Elucidator
from reversi import BitBoard, Solver
from reversi import C as c


Expand Down Expand Up @@ -218,51 +218,51 @@ def get_scores(socre):
print('skip Pioneer')
continue

elucidator = Elucidator(name, size, first, hole, ini_black, ini_white)
solver = Solver(name, size, first, hole, ini_black, ini_white)

squares = elucidator.squares
blanks = elucidator.blanks
squares = solver.squares
blanks = solver.blanks
conf['squares'] = squares
conf['blanks'] = blanks
print('squares :', squares)
print('blanks :', blanks)

if CONTROLL[name][0] and DO_RANDOM_MOVE_MATCHES:
conf['random_10000_matches'] = elucidator.get_random_match_result(RANDOM_MATCH)
conf['random_10000_matches'] = solver.get_random_match_result(RANDOM_MATCH)

if CONTROLL[name][1] and DO_BEST:
conf["best_match_winner"], conf["best_match_score"], conf["best_match_record"] = elucidator.get_best_match_winner()
conf["best_match_winner"], conf["best_match_score"], conf["best_match_record"] = solver.get_best_match_winner()

if CONTROLL[name][2] and DO_MAX:
conf["black_max_score"], conf["black_max_record"], conf["white_max_score"], conf["white_max_record"] = elucidator.get_max_winner()
conf["black_max_score"], conf["black_max_record"], conf["white_max_score"], conf["white_max_record"] = solver.get_max_winner()

if CONTROLL[name][3] and DO_SHORTEST:
conf["black_shortest_move_count"], conf["black_shortest_record"], conf["white_shortest_move_count"], conf["white_shortest_record"] = elucidator.get_shortest_winner() # noqa: E501
conf["black_shortest_move_count"], conf["black_shortest_record"], conf["white_shortest_move_count"], conf["white_shortest_record"] = solver.get_shortest_winner() # noqa: E501

if VERIFY_RECORD:
if conf["best_match_record"] != "?":
score = conf["best_match_score"]
black_score, white_score = get_scores(score)
print('\n>>> verify best_match_record :', conf["best_match_record"])
elucidator.verify_record(conf["best_match_record"], black_score=black_score, white_score=white_score)
solver.verify_record(conf["best_match_record"], black_score=black_score, white_score=white_score)
if conf["black_max_record"] != "?":
score = conf["black_max_score"]
black_score, white_score = get_scores(score)
print('\n>>> verify black_max_record :', conf["black_max_record"])
elucidator.verify_record(conf["black_max_record"], black_score=black_score, white_score=white_score)
solver.verify_record(conf["black_max_record"], black_score=black_score, white_score=white_score)
if conf["white_max_record"] != "?":
score = conf["white_max_score"]
black_score, white_score = get_scores(score)
print('\n>>> verify white_max_record :', conf["white_max_record"])
elucidator.verify_record(conf["white_max_record"], black_score=black_score, white_score=white_score)
solver.verify_record(conf["white_max_record"], black_score=black_score, white_score=white_score)
if conf["black_shortest_record"] != "?":
move_count = conf["black_shortest_move_count"]
print('\n>>> verify black_shortest_record :', conf["black_shortest_record"])
elucidator.verify_record(conf["black_shortest_record"], move_count=move_count)
solver.verify_record(conf["black_shortest_record"], move_count=move_count)
if conf["white_shortest_record"] != "?":
move_count = conf["white_shortest_move_count"]
print('\n>>> verify white_shortest_record :', conf["white_shortest_record"])
elucidator.verify_record(conf["white_shortest_record"], move_count=move_count)
solver.verify_record(conf["white_shortest_record"], move_count=move_count)

print('-------------------------------')

Expand Down
4 changes: 2 additions & 2 deletions reversi/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ def _game_play(self, info):
p.strategy.get_result(game.result)

if self.perfect_check:
from reversi import Elucidator
Elucidator(board=board).make_perfect_win_txt(self.perfect_win_txt)
from reversi import Solver
Solver(board=board).make_perfect_win_txt(self.perfect_win_txt)
return ret

def _totalize_results(self):
Expand Down
8 changes: 3 additions & 5 deletions reversi/elucidator.py → reversi/solver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Elucidator
"""Solver
"""

import os
Expand All @@ -10,10 +10,8 @@
from reversi.strategies import Random, _EndGame_


class Elucidator:
"""
ボード解明ツール
"""
class Solver:
"""ボード解析ツール"""
def __init__(self, name=None, size=None, first=None, hole=None, ini_black=None, ini_white=None, board=None):
self.name = name
self.size = size
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='reversi',
version='0.0.54',
version='0.0.55',
license='MIT License',
install_requires=[
'cython',
Expand Down

0 comments on commit 80f4059

Please sign in to comment.