move
chessapp.model.move.Move
Source code in chessapp\model\move.py
__init__(tree, san, result, comment='', source=SourceType.default_value(), frequency=0)
creates a new move in the tree with the given SAN and resulting fen
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree |
ChessTree
|
the tree in which this move is contained |
required |
san |
str
|
SAN of the move |
required |
result |
str
|
resulting fen after this move is played |
required |
comment |
str
|
Defaults to "". comment for this move. this can be anything that might be useful to users that explore this move. |
''
|
source |
SourceType
|
Defaults to SourceType.default_value(). source of this move. |
default_value()
|
frequency |
int
|
Defaults to 0. frequency of this move (how many times it has been played) |
0
|
Source code in chessapp\model\move.py
eval()
returns the evaluation of this move
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
the evaluation of this move |
eval_depth()
returns the evaluation depth of this move
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
the evaluation depth of this move |
get_info(node)
returns a string formatting information about this move in human readable form
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Node
|
the node from which this move originates |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the information string in human readable form |
Source code in chessapp\model\move.py
is_equivalent_to(other)
two moves are equivalent if they have the same SAN and resulting fen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Move
|
the other move to compare to |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the two moves are equivalent, False otherwise |
Source code in chessapp\model\move.py
Source
from chessapp.model.sourcetype import SourceType
class Move:
def __init__(self, tree, san: str, result: str, comment: str = "", source: SourceType = SourceType.default_value(), frequency: int = 0):
""" creates a new move in the tree with the given SAN and resulting fen
Args:
tree (ChessTree): the tree in which this move is contained
san (str): SAN of the move
result (str): resulting fen after this move is played
comment (str, optional): Defaults to "". comment for this move. this can be anything that might be useful to users that explore this move.
source (SourceType, optional): Defaults to SourceType.default_value(). source of this move.
frequency (int, optional): Defaults to 0. frequency of this move (how many times it has been played)
"""
self.tree = tree
self.san: str = san
self.result: str = result
self.comment: str = comment
self.source: SourceType = source
self.frequency: int = frequency
def is_equivalent_to(self, other) -> bool:
""" two moves are equivalent if they have the same SAN and resulting fen.
Args:
other (Move): the other move to compare to
Returns:
bool: True if the two moves are equivalent, False otherwise
"""
return other != None and self.san == other.san and self.result == other.result
def get_info(self, node) -> str:
""" returns a string formatting information about this move in human readable form
Args:
node (Node): the node from which this move originates
Returns:
str: the information string in human readable form
"""
info: str = self.san + " with eval " + str(self.eval()) + " at depth " + str(self.eval_depth(
)) + " (cp loss = " + str(node.get_cp_loss(self)) + ") from source " + self.source.sformat()
return info
def eval(self) -> float:
""" returns the evaluation of this move
Returns:
float: the evaluation of this move
"""
return self.tree.get(self.result).eval
def eval_depth(self) -> int:
""" returns the evaluation depth of this move
Returns:
int: the evaluation depth of this move
"""
return self.tree.get(self.result).eval_depth