Пример #1
0
import numpy as np

from axelrod.actions import Actions, Action
from axelrod.player import Player
from axelrod.load_data_ import load_weights

from typing import List, Tuple

C, D = Actions.C, Actions.D
nn_weights = load_weights()


# Neural Network and Activation functions
relu = np.vectorize(lambda x: max(x, 0))


def compute_features(player: Player, opponent: Player) -> List[int]:
    """
    Compute history features for Neural Network:
    * Opponent's first move is C
    * Opponent's first move is D
    * Opponent's second move is C
    * Opponent's second move is D
    * Player's previous move is C
    * Player's previous move is D
    * Player's second previous move is C
    * Player's second previous move is D
    * Opponent's previous move is C
    * Opponent's previous move is D
    * Opponent's second previous move is C
    * Opponent's second previous move is D
Пример #2
0
from typing import List, Tuple

import numpy as np
from axelrod.action import Action
from axelrod.load_data_ import load_weights
from axelrod.player import Player

C, D = Action.C, Action.D
nn_weights = load_weights()


# Neural Network and Activation functions
relu = np.vectorize(lambda x: max(x, 0))


def compute_features(player: Player, opponent: Player) -> List[int]:
    """
    Compute history features for Neural Network:
    * Opponent's first move is C
    * Opponent's first move is D
    * Opponent's second move is C
    * Opponent's second move is D
    * Player's previous move is C
    * Player's previous move is D
    * Player's second previous move is C
    * Player's second previous move is D
    * Opponent's previous move is C
    * Opponent's previous move is D
    * Opponent's second previous move is C
    * Opponent's second previous move is D
    * Total opponent cooperations