AlkantarClanX12
Current Path : /lib64/python3.8/turtledemo/__pycache__/ |
Current File : //lib64/python3.8/turtledemo/__pycache__/nim.cpython-38.opt-1.pyc |
U e5dq � @ s� d Z ddlZddlZddlZdZdZdZdZed Zeed d ed d Z dZ dZd Zdd� Z dd� Zdd� ZG dd� de�ZG dd� dej�ZG dd� de�ZG dd� de�ZG dd� de�Zdd� Zed kr�e� e�� dS )!z� turtle-example-suite: tdemo_nim.py Play nim against the computer. The player who takes the last stick is the winner. Implements the model-view-controller design pattern. � Ni� i� � � � � � � )�? r r )� �� r )r r r c C s t �tt�S �N)�random�randint� MINSTICKS� MAXSTICKS� r r �&/usr/lib64/python3.8/turtledemo/nim.py� randomrow s r c C sb | d | d A | d A }|dkr(t | �S td�D ],}| | |A }|| | kr0||f}| S q0d S )Nr � r � )� randommove�range)�stateZxored�z�s�mover r r �computerzug! s r c C sH t | �}t�dd�}| | |dkkrq(qt�|dk| | d �}||fS )Nr r r )�maxr r )r �mr Zrandr r r r + s r c @ s4 e Zd Zdd� Zdd� Zdd� Zdd� Zd d � ZdS )�NimModelc C s || _ d S r )�game)�selfr r r r �__init__6 s zNimModel.__init__c C sP | j jtjtjfkrd S t� t� t� g| _d| _d | _| j j � � tj| j _d S �Nr )r r �Nim�CREATED�OVERr �sticks�player�winner�view�setup�RUNNING�r r r r r* 9 s zNimModel.setupc C s� | j | }|| j |<