CoolFace
Apppublic

nicoloddo/x-tree-search

sourceHugging Facecc-by-nc-4.0updated 1y agoView on Hugging Face
1likes
alphabeta_explainer.cpython-312.pyc53 linesDownload Raw Back to __pycache__
1�

27
h�=���ddlmZddlmZddlmZmZmZmZm	Z	m3Z4mZddlmZddl
mZmZmZmZmZmZmZddlmZmZmZGd�d�Zy	)5�)�ArgumentativeExplainer)�ArgumentationFramework)�BooleanAdjective�PointerAdjective�QuantitativePointerAdjective�NodesGroupPointerAdjective�ComparisonAdjective�MaxRankAdjective�MinRankAdjective)�COMPARISON_AUXILIARY_ADJECTIVE)�6Possession�RecursivePossession�7Assumption�8Comparison�If�ConditionalExplanation�CompositeExplanation)�OnlyRelevantComparisons�SkipQuantitativeExplanations�%CompactComparisonsWithSameExplanationc�&�eZdZdZd�Zed��Zy)�AlphaBetaExplainerzw9    A factory class that returns an instance of ArgumentativeExplainer10    configured for AlphaBeta explanations.11    c��t�}|j�}g}ddddd�}|j|�td|d|��}|j	d	|�|S)12z�13        Create and return an instance of ArgumentativeExplainer14        configured for MiniMax explanations.15 16        Returns:17            An instance of ArgumentativeExplainer18        �F�verbose�verbal)�explanation_depth�print_implicit_assumptions�assumptions_verbosity�19print_mode�move�the best)�refer_to_nodes_as�20adjectives�main_explanation_adjective�tactics�	highlevel)r�_get_adjectives�configure_settingsr�
add_framework)�cls�args�kwargs�	explainerr$r&�settings�highlevel_frameworks        �_C:\Users\nicom\Projects\x-tree-search\workspace\x-tree-search\explainers\alphabeta_explainer.py�__new__zAlphaBetaExplainer.__new__sz��+�,�	��(�(�*�21�22��"#�*/�%.�"�	23��	�$�$�X�.�5�$�!�'1��	24��	����-@�A���c%���tdd��tdd��tddtd��	�td25dtd��	�tdd
td��	�tdddtt	dd�tt	dd�td�tt	dd26�td27�td�����tt	dd�t
td�td��tt	dd�td�tt	ddd�tt	ddd�tdd�tt	ddd28�tdd29�tdd�����t
td�td������������tdd��tddtt	dd�t
td�tt	dddd �tdd!d d"�#�tdd$d d"�#����t
tdd"�%�td&�tt	ddd'd(�tdd)d(d"�#�tdd$d(d"�#�������	�tdd*tt	dd�tt	dd�t
td+�tdd,��t
td-�tdd.����td/d�0����	�tdd1t
td2d�3�tdt	ddd�t	ddd30�t	ddd�t	ddd�g�4���	�tdd*td/d�0��	�td(d5��td d6��td'dd7t	dd8t�d8f�9�tddd:t	dd8t�d8f�9�td8dd;�td<dd;�td)dd7�td!dd:�td$dd;�td=d>d?�@�tdAd'd<gd=t	dd�d.d,f�9�td.d'd<gd=t	ddd"�B�d,ftddgdCdDdEgfgdg�F�g�G�td,dd<gd=t	dd�d.ftddgdCdDdEgfgdg�F�g�G�g}|S)HzZ31        Returns a list of adjective definitions for the argumentation framework.32        z33final moveznode.final_node)�34definitionz'the most forward in the future I lookedznode.max_search_depth_reachedza winz"node.final_node and node.score > 0zThese are the rules!)r5�explanationza lossz"node.final_node and node.score < 0za drawz#node.final_node and node.score == 0�scoreznode.readable_scoreT�35possession)�	condition�explanation_if_true�explanation_if_falsezzwhen I can't look further in the future, my evaluation of a move is qualitative, only based on the board position after itzXnot in possession of futures worth exploring after checking the first possible next movez"as future position after few moveszas next movezas next possible move)r9r;r:)r5�skip_statementr6zopponent player turnznot node.maximizing_player_turnznot node.fully_searchedzVThe opponent can choose to do this possible next move, or something even worse for me.�36comparisonzworse for me than�37upperboundz6already worse for me than the alternative coming afterF)� forward_possessions_explanationsz-already equal to the alternative coming after)�explain_furtherzJWe could choose to do this move, or something even worse for the opponent.zbetter for me than�38lowerboundz7already better for me than the alternative coming afterznode.score_childz/We assume the opponent will do their best move.zthe best the opponent can doz+On our turn we take the maximum rated move.zthe best for mezThe move is legal.)�implicitznode.deep_score_childzDWe assume the opponent will do their best move and us our best move.)�	necessary)�any_stop_conditionsznode.parent.betaznode.parent.alpha�>zequal to)�explain_with_adj_if�<z==zat least equal tozpossible alternative movesznode.parent.children�node)r5�	excludingr")�value�39evaluation�depth�last_move_id)�from_adjectives�same_if_equal_keys�also_compact_adjectives)rFr&)rrrrrr
rrrrr	rrr40r)r$s r1r(z"AlphaBetaExplainer._get_adjectives8s���
�\�.�
0��F�<�
>�
�W�A�(�)?�@�
B�
�X�A�(�)?�@�
B�
�X�B�(�)?�@�
B�41
)��2�!%�425� "�<�� >�+A�"$�\�7�";�,6�w�,?�.D�&(��x�&@�2<�X�2F�3=�x�3H�/�+�,B�$&�|�5^�$_�.B�&�'P�Q�&�(d�e�/�430F�&(��8R�'S�4>�>b�3c�3I�,.�|�^�\�,Z�7M�.0��~�w�.W�8B�>�SZ�8[�:P�24�\�>�S[�2\�>H��Ya�>b�?I�>�[c�?d�;*�7&�8L�$.�/F�$G�$.�0J�%K�8"�%3�0�',�7�?
�B
�3�>�
@�
�w�6�2� "�<�1G� H�*>�"�#{�|�.�(*�<�9P�Re�gs�(t�2<�=T�WO�Q]�EJ�3L�3=�>U�XG�IU�EJ�4L�	�	+�,@�"�#:�E�R�"�#o�p�.�(*�<�9P�Rf�ht�(u�2<�=T�WP�R^�EJ�3L�3=�>U�XG�IU�EJ�4L�	�44,��
�>
�^�/�4� "�<�2L�!M�,B�$&�|�5K�$L�.B�&�'X�Y�&�~�7U�V�/X�0D�&�'T�U�&�~�7H�I�0K�,�+5�5I�TX�*Y��
�*
�A�4�2��e�qu�v�'��r�R^�`n�pw�Ox�PR�S_�ao�qy�Pz�PR�S_�ao�qy�Pz�PR�S_�ao�r[�Q\�O]�^��	
�
�4�/�(�)=��M�
O�
�\�/�
1�
�\�0�
2�
 � 4�g�s�57��j�Rp�5q�s}�4~�
@�� 3�W�c�57��j�Rp�5q�s}�4~�
@��45�G�T�:�� 3�W�d�C�� Y�[b�dg�h�� X�Za�cf�g�� O�QX�Z^�_�&�'C�3�"�
$�
�Z�*>�@S�)T�Vr�')�,�8N�'O�Qb�eC�'D�
�
�.�1E�GZ�0[�]y�')�,�8N�V[�'\�^|�&}�9�)7�'>�)@�-9�G�^�;T�,U�+V�4N�3O�	��46
�
�;�>Q�Sf�=g�jF�')�,�8N�'O�Qb�&c�9�)7�'>�)@�-9�G�^�;T�,U�+V�4N�3O�	��47
�{H48�49�T�r3N)�__name__�50__module__�__qualname__�__doc__r2�staticmethodr(�r3r1rr51s#���52&�P�O��Or3rN)�src.explainer.explainerr�src.explainer.frameworkr�src.explainer.adjectiverrrrr	r53rr�src.explainer.explanationr
rrrrrr�!src.explainer.explanation_tacticsrrrrrVr3r1�<module>r\sJ��:�:�z�z�z�B�P�P�P�K�K�~�~r3