from lib.base import *
from lib.player_generators.base_player_generator import BasePlayerGenerator
from lib.matches.chance_based_matches.team_total_proportional_chance_match import TeamTotalProportionalChanceMatch
from lib.tiered_leagues.base_tiered_league import BaseTieredLeague

from sys import argv
if len(argv) < 2:
    baseline_strength = 0
else:
    baseline_strength = int(argv[1])

pb = BasePlayerGenerator(10000, baseline_strength)
tl = BaseTieredLeague(pb, TeamTotalProportionalChanceMatch)

for i in range(0, 100):
    tl.do_an_iteration()
tl.print_summary()
 def test_apply_tier_adjustments(self):
     bpg = BasePlayerGenerator(1)
     btl = BaseTieredLeague(bpg)
     btl.tiered_league = {
         0: {
             0: {
                 "a": 13
             },
             1: {
                 "b": 14
             },
             2: {
                 "c": -4
             },
         },
         1: {
             0: {
                 "d": 15
             },
             1: {
                 "e": -5
             },
             2: {
                 "f": 0
             },
         },
         2: {
             0: {
                 "g": 1
             },
             1: {
                 "h": 9
             },
             2: {
                 "i": -6
             },
         },
     }
     btl.apply_tier_adjustments()
     expected_league = {
         0: {
             0: {
                 "a": 13,
                 "b": 0
             },
             1: {},
             2: {
                 "d": 0
             },
         },
         1: {
             0: {
                 "c": 10
             },
             1: {},
             2: {
                 "e": 10,
                 "f": 0
             },
         },
         2: {
             0: {
                 "g": 1
             },
             1: {
                 "h": 9
             },
             2: {
                 "i": 0
             },
         },
     }
     self.assertEqual(btl.tiered_league, expected_league)
 def test_migrate_player1(self):
     bpg = BasePlayerGenerator(1)
     btl = BaseTieredLeague(bpg)
     test_league = {1: {2: {}}}
     btl.migrate_player(test_league, 1, 2, "test", 3)
     self.assertEqual(test_league, {1: {2: {"test": 3}}})
 def test_migrate_player7(self):
     bpg = BasePlayerGenerator(1)
     btl = BaseTieredLeague(bpg)
     test_league = {0: {0: {}}}
     btl.migrate_player(test_league, 0, 0, "test", 12)
     self.assertEqual(test_league, {0: {0: {"test": 12}}})
 def test_migrate_player4(self):
     bpg = BasePlayerGenerator(1)
     btl = BaseTieredLeague(bpg)
     test_league = {1: {0: {}}}
     btl.migrate_player(test_league, 0, 2, "test", -1)
     self.assertEqual(test_league, {1: {0: {"test": 10}}})
from lib.base import *
from lib.player_generators.base_player_generator import BasePlayerGenerator
from lib.matches.deterministic_matches.strongest_wins_match import StrongestWinsMatch
from lib.tiered_leagues.base_tiered_league import BaseTieredLeague

pb = BasePlayerGenerator(10000)
tl = BaseTieredLeague(pb, StrongestWinsMatch)

for i in range(0, 100):
    tl.do_an_iteration()
tl.print_summary()
Пример #7
0
 def test_calculate_needed_length_of_player_names(self):
     bpg = BasePlayerGenerator(0)
     self.assertEqual(bpg.calculate_needed_length_of_player_names(0), 0)
     self.assertEqual(bpg.calculate_needed_length_of_player_names(1), 1)
     self.assertEqual(bpg.calculate_needed_length_of_player_names(26), 1)
     self.assertEqual(bpg.calculate_needed_length_of_player_names(27), 2)
Пример #8
0
 def test_map_integer_to_string(self):
     bpg = BasePlayerGenerator(0)
     self.assertEqual(bpg.map_integer_to_string(0, 0), "")
     self.assertEqual(bpg.map_integer_to_string(0, 1), "a")
     self.assertEqual(bpg.map_integer_to_string(1, 1), "b")
     self.assertEqual(bpg.map_integer_to_string(10, 1), "k")
     self.assertEqual(bpg.map_integer_to_string(25, 1), "z")
     self.assertEqual(bpg.map_integer_to_string(0, 2), "aa")
     self.assertEqual(bpg.map_integer_to_string(1, 2), "ba")
     self.assertEqual(bpg.map_integer_to_string(10, 2), "ka")
     self.assertEqual(bpg.map_integer_to_string(25, 2), "za")
     self.assertEqual(bpg.map_integer_to_string(26, 2), "ab")
     self.assertEqual(bpg.map_integer_to_string(36, 2), "kb")
     self.assertEqual(bpg.map_integer_to_string(51, 2), "zb")
     self.assertEqual(bpg.map_integer_to_string(52, 2), "ac")
     self.assertEqual(bpg.map_integer_to_string(0, 3), "aaa")
     self.assertEqual(bpg.map_integer_to_string(1, 3), "baa")
     self.assertEqual(bpg.map_integer_to_string(10, 3), "kaa")
     self.assertEqual(bpg.map_integer_to_string(25, 3), "zaa")
     self.assertEqual(bpg.map_integer_to_string(26, 3), "aba")
     self.assertEqual(bpg.map_integer_to_string(36, 3), "kba")
     self.assertEqual(bpg.map_integer_to_string(51, 3), "zba")
     self.assertEqual(bpg.map_integer_to_string(52, 3), "aca")
     self.assertEqual(bpg.map_integer_to_string(17575, 3), "zzz")