lascar
lascar copied to clipboard
Make Engine name optional
Reason
This PR is only a suggestion, based on a perhaps personal view: giving a name to an engine feels unwarranted in most straightforward cases.
The changes implemented here make it possible to name an Engine only when needed, and otherwise pick a default name with no user intervention: cpa = CpaEngine(selection_function, guess_range)
would now be accepted.
Details
For example, the default CpaEngine
would be named "cpa"
. Several of them would be named "cpa", "cpa1", "cpa2", ...
.
Two CpaEngine
s and two NicvEngine
in the same session would be named "cpa", "cpa1", "nicv", "nicv3"
as this PR appends the current number of present engines in the session to their default names. This could be confusing, but is also a case where one would prefer naming their engines manually anyway.
Breaking change
This introduces a breaking change in the Engine's prototype:
- CpaEngine("cpa0", selection_function, guess_range)
+ CpaEngine(selection_function, guess_range, name="cpa0")
As the name
parameter is now optional, it is a keyword argument and is placed at the end of the parameter list. Therefore the first parameter changes from the name
to selection_function
, which will make existing scripts fail with a type error.