Library for the iterated evolutionary tournaments between memory-based agents.
- Installation
- Usage
2.1 Strategies
2.2 Game
2.3 Memory based strategies storage
2.4 Memory tournament - Development
pip install ipdframework
Create new instance of the memory based strategy (from responses sequence):
from ipdf.strategies.memory_based import MemoryBasedStrategy
strategy = MemoryBasedStrategy(sequence_str='101')
print(strategy.name(), '=>', strategy_1.responses)
Game class allows users to emulate interactions between two strategies
from ipdf.game import Game
from ipdf.strategies.memory_based import MemoryBasedStrategy
from ipdf.payment_matrix import init_default_payment_matrix
matrix = init_default_payment_matrix()
n_moves = 20
str1 = MemoryBasedStrategy(sequence_str='1011011')
str2 = MemoryBasedStrategy(sequence_str='0110011')
game = Game(matrix, str1, str2)
game.play(n_moves)
game.log_game_info()
MemoryStrategiesStorage class allows you to generate and store memory-based strategies.
Used to generate a pack with evey possible strategy with certain memory depth.
from ipdf.memory_strategies_storage import MemoryStrategiesStorage
mem_depth = 1
strategies_st = MemoryStrategiesStorage(mem_depth)
strategies_st.log_storage_info()
for strategy in strategies_st.strategies():
print(strategy.responses)
Encapsulates evolutionary tournament logic.
Class allows user to emulate tournament between each and every strategy with certain memory depth. Users can set memory depth and number of interactions between each pair of strategies.
from ipdf.memory_tournament import MemoryStrategiesTournament
from ipdf.payment_matrix import init_default_payment_matrix
num_of_interactions = 50
mem_depth = 2
payment_matrix = init_default_payment_matrix()
memory_strategies_tournament = MemoryStrategiesTournament(mem_depth, payment_matrix)
memory_strategies_tournament.play(num_of_interactions)
memory_strategies_tournament.save()
Python version: 3.6+
Install w/ dev dependencies:
pip install -e .[dev]
M.S. CS Dmytro Tkachuk
https://dmtk.app