Esempio n. 1
0
    def test_1(self):
        spiel = Spiel_class.Spiel(Kartenliste)

        # alle_orte nach Zug
        goal = [spiel.alle_orte[0]]
        # alle strassen nach Zug
        goal2 = [spiel.alle_strassen[0], Strasse((1, 0), [1, 2])]

        k = card_class.Card("O", "S", 'S', 'O', 'O')
        spiel.make_action(Player_Class.Player(1), k, 1, 0, 0, None)

        self.assertEqual(len(spiel.alle_orte), len(goal))
        self.assertEqual(len(goal2), len(spiel.alle_strassen))
        self.assertEqual(
            sorted(k.kanten),
            sorted({
                0: spiel.cards_set[(0, 0)].kanten[1],
                1: k.kanten[1],
                2: k.kanten[2],
                3: spiel.cards_set[(0, 0)].kanten[1]
            }))

        for o in spiel.alle_orte:
            a = True
            for ort in goal:
                a = a or o == ort
            self.assertTrue(a)
        for s in spiel.alle_strassen:
            a = True
            for strasse in goal2:
                a = a or s == strasse
            self.assertTrue(a)
Esempio n. 2
0
    def test1(self):

        p1 = Player(1)
        p2 = Player(2)

        spiel = Spiel_class.Spiel([], p1, p2)

        k1 = Card('O', 'O', 'S', 'O', 'O', True)
        spiel.make_action(p1, k1, 1, 0, 0, k1.orte[0])

        k2 = Card('O', 'S', 'S', 'W')
        spiel.make_action(p2, k2, 0, 1, 1, k2.strassen[0])

        k3 = Card('O', 'S', 'S', 'W')
        spiel.make_action(p1, k3, 2, 0, 3, k3.strassen[0])

        k4 = Card('W', 'W', 'S', 'S')
        spiel.make_action(p2, k4, 2, -1, 0, k4.strassen[0])

        k5 = Card('S', 'W', 'S', 'W')
        spiel.make_action(p1, k5, -1, 0, 0, k5.strassen[0])

        k6 = Card('W', 'W', 'S', 'S')
        spiel.make_action(p2, k6, 0, 2, 1, k6.strassen[0])

        k7 = Card('W', 'W', 'S', 'W', 'K')
        spiel.make_action(p1, k7, 2, 1, 0, 'k')

        k8 = Card('S', 'O', 'S', 'S', 'G')

        s = None
        for st in k8.strassen:
            if st.kanten == [3]:
                s = st

        spiel.make_action(p2, k8, 1, -1, 1, s)

        k9 = Card('O', 'S', 'S', 'W')
        spiel.make_action(p1, k9, 1, -2, 0, k9.orte[0])

        #display_spielbrett_dict(spiel.cards_set)

        k10 = Card('S', 'O', 'W', 'S')

        #pos = spiel.calculate_possible_actions(k10, p2)
        #node = Node(True, None, p2.nummer, None)

        #a, b = uct_select(spiel, k10, p2, pos, d=1, root_node=node, t_end=None, rechenzeit=30, c=1.4142, threads=1)

        #print(a, b)

        w = None
        for wi in k10.wiesen:
            if wi.ecken == [4]:
                w = wi
        spiel.make_action(p2, k10, 2, -2, 0, w)

        spiel.final_evaluate()

        self.assertEqual(p2.punkte, 12)
Esempio n. 3
0
    def test_4(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player_Class.Player(1)
        player2 = Player_Class.Player(2)

        k1 = card_class.Card('O', 'W', 'W', 'O', 'O', True)
        #plot_cards.draw_card(k1)
        spiel.make_action(player1, k1, 1, 0, 0, k1.orte[0])

        self.assertEqual(spiel.alle_orte[0].besitzer, player1)
        self.assertEqual(len(spiel.alle_orte[0].meeples), 1)

        k2 = card_class.Card('O', 'O', 'W', 'O', 'O')
        #plot_cards.draw_card(k2)
        spiel.make_action(player2, k2, 2, 0, 1, k2.orte[0])

        self.assertEqual(spiel.alle_orte[-1].besitzer, player2)
        self.assertEqual(len(spiel.alle_orte[-1].meeples), 1)

        k3 = card_class.Card('O', 'W', 'W', 'O', 'O')
        spiel.make_action(player1, k3, 1, 1, 2)

        k4 = card_class.Card('O', 'W', 'W', 'O', 'O')
        spiel.make_action(player2, k4, 2, 1, 3)

        #plot_cards.display_spielbrett_dict(spiel.cards_set)
        print('end')
Esempio n. 4
0
    def test4(self):
        p1 = Player(1)
        p2 = Player(2)

        spiel = Spiel_class.Spiel([], p1, p2)

        k1 = Card('W', 'W', 'S', 'S')
        spiel.make_action(p1, k1, 0, -1, 2)

        k2 = Card('W', 'S', 'S', 'S', 'G')
        spiel.make_action(p2, k2, 1, -1, 0)

        k3 = Card('S', 'O', 'W', 'S')
        spiel.make_action(p1, k3, 0, -2, 2)

        k4 = Card('O', 'S', 'S', 'W')
        spiel.make_action(p2, k4, 0, -3, 3)

        k5 = Card('W', 'W', 'S', 'S')
        spiel.make_action(p1, k5, 1, -3, 1)

        k6 = Card('W', 'W', 'S', 'W', 'K')
        spiel.make_action(p2, k6, 2, -3, 0)

        #display_spielbrett_dict(spiel.cards_set)

        k7 = Card('S', 'S', 'S', 'S', 'G')
        spiel.make_action(p1, k7, 1, -2, 0)

        print('ende')
Esempio n. 5
0
    def test4(self):
        spiel = Spiel_class.Spiel(
            card_class.create_kartenliste([
                'OSSW', 'SWSW', 'SOSSG', 'WWSWK', 'WWSS', 'WWSS', 'OOSOOT',
                'OSSW', 'SOWS', 'OSSW'
            ], False))
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('O', 'S', 'S', 'W')
        spiel.make_action(player1, k1, 1, 0, 3)

        k2 = Card('W', 'W', 'S', 'W', 'K')
        spiel.make_action(player2, k2, 1, -1, 1, 'k')

        k3 = Card('S', 'O', 'W', 'S')
        spiel.make_action(player1, k3, 0, 1, 3)

        k4 = Card('O', 'S', 'S', 'W')
        spiel.make_action(player2, k4, 0, -1, 3)

        k5 = Card('W', 'W', 'S', 'S')
        spiel.make_action(player1, k5, 1, 1, 3)

        self.assertEqual(len(spiel.alle_wiesen), 2)
Esempio n. 6
0
    def test10(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('O', 'S', 'S', 'W')
        pos1 = spiel.calculate_possible_actions(k1, player1)

        self.assertEqual(30, len(pos1))
        spiel.make_action(player1, k1, 0, 1, 1, k1.orte[0])

        k2 = Card('O', 'W', 'W', 'O', 'O', True)
        pos2 = spiel.calculate_possible_actions(k2, player2)

        self.assertEqual(22, len(pos2))
        spiel.make_action(player2, k2, 1, 0, 0, k2.orte[0])

        k3 = Card('O', 'O', 'W', 'O', 'O')

        pos3 = spiel.calculate_possible_actions(k3, player1)

        self.assertEqual(16, len(pos3))
        spiel.make_action(player1, k3, 1, 1, 2)

        #display_spielbrett_dict(spiel.cards_set)

        k4 = Card('W', 'O', 'W', 'O')

        pos4 = spiel.calculate_possible_actions(k4, player2)

        self.assertEqual(23, len(pos4))
Esempio n. 7
0
    def test2(self):
        p1 = Player(1)
        p2 = Player(2)

        spiel = Spiel_class.Spiel([], p1, p2)

        k1 = Card('W', 'W', 'S', 'W', 'K')
        spiel.make_action(p1, k1, 0, -1, 2)

        k2 = Card('O', 'O', 'S', 'O', 'O', True)
        spiel.make_action(p2, k2, 1, 0, 2)

        k3 = Card('S', 'O', 'W', 'S')
        spiel.make_action(p1, k3, -1, 0, 3)

        k4 = Card('W', 'W', 'S', 'W', 'K')
        spiel.make_action(p2, k4, 1, 1, 0)

        k5 = Card('O', 'S', 'S', 'W')
        spiel.make_action(p1, k5, -1, 1, 2)

        #display_spielbrett_dict(spiel.cards_set)

        k6 = Card('S', 'W', 'S', 'W')
        pos = spiel.calculate_possible_actions(k6, p2)

        spiel.make_action(p2, k6, 0, 1, 0)
Esempio n. 8
0
 def test7(self):
     spiel = Spiel_class.Spiel(
         card_class.create_kartenliste([
             'OSSW', 'SWSW', 'SOSSG', 'WWSWK', 'WWSS', 'WWSS', 'OOSOOT',
             'OSSW', 'SOWS', 'OSSW', 'SWSW', 'WOWOOT', 'WOWO', 'OWWOO',
             'WWWWK', 'OOSOO'
         ], False))
     player1 = Player(1)
     player2 = Player(2)
Esempio n. 9
0
    def test5(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player_Class.Player(1)
        player2 = Player_Class.Player(2)

        k1 = Card('W', 'O', 'W', 'O')
        spiel.make_action(player1, k1, -1, 0, 1)

        self.assertEqual(len(spiel.alle_orte), 3)
Esempio n. 10
0
    def test1(self):
        player1 = Player(1)
        player2 = Player(2)

        spiel = Spiel_class.Spiel([])

        k1 = Card('S', 'W', 'S', 'W')
        pos = spiel.calculate_possible_actions(k1, player1)

        self.assertEqual(12, len(pos))
Esempio n. 11
0
    def test_3(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player_Class.Player(1)
        player2 = Player_Class.Player(2)

        k1 = card_class.Card('O', 'W', 'W', 'W')
        spiel.make_action(player1, k1, 1, 0, 3, k1.orte[0])

        self.assertEqual(player1.punkte, 4)
        self.assertEqual(player1.meeples, 7)
Esempio n. 12
0
    def test5(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k2 = Card('O', 'W', 'W', 'O', 'O')
        spiel.make_action(player1, k2, 1, 0, 0, k2.orte[0])

        k3 = Card('W', 'O', 'W', 'O')
        pos = spiel.calculate_possible_actions(k3, player2)

        self.assertEqual(len(pos), 15)
Esempio n. 13
0
    def test3(self):
        spiel = Spiel_class.Spiel(
            card_class.create_kartenliste([
                'SOWS', 'SWSW', 'WWSS', 'WWSWK', 'OOSOOT', 'OSSW', 'SOSSG',
                'OSSW', 'WWSS', 'OSSW'
            ], False))
        player1 = Player(1)
        player2 = Player(2)

        k1 = spiel.cards_left.pop(0)
        spiel.make_action(player2, k1, 1, 0, 2, k1.orte[0])

        k2 = spiel.cards_left.pop(0)
        spiel.make_action(player1, k2, 2, 0, 1, k2.strassen[0])

        k3 = spiel.cards_left.pop(0)
        spiel.make_action(player2, k3, 0, 1, 3, k3.strassen[0])

        k4 = spiel.cards_left.pop(0)
        spiel.make_action(player1, k4, 1, -1, 2, 'k')

        k5 = spiel.cards_left.pop(0)
        spiel.make_action(player2, k5, 3, 0, 1, k5.orte[0])

        k6 = spiel.cards_left.pop(0)
        spiel.make_action(player1, k6, 1, -2, 1, k6.strassen[0])

        k7 = spiel.cards_left.pop(0)

        strasse = None
        for s in k7.strassen:
            if s.kanten == [0]:
                strasse = s

        spiel.make_action(player2, k7, 3, 1, 1, strasse)

        k8 = spiel.cards_left.pop(0)
        spiel.make_action(player1, k8, 2, -2, 3, k8.orte[0])

        k9 = spiel.cards_left.pop(0)

        w = [wi for wi in k9.wiesen if wi.ecken == [7]][0]
        spiel.make_action(player2, k9, 1, -3, 2, w)

        #display_spielbrett_dict(spiel.cards_set)

        k10 = spiel.cards_left.pop(0)
        spiel.make_action(player1, k10, 0, -2, 0, k10.orte[0])

        spiel.final_evaluate()

        self.assertEqual(player1.punkte, 19)
        self.assertEqual(player2.punkte, 16)
Esempio n. 14
0
    def test4(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k2 = Card('O', 'W', 'W', 'O', 'O')
        spiel.make_action(player1, k2, 1, 0, 0)

        k3 = Card('W', 'O', 'W', 'O')
        pos = spiel.calculate_possible_actions(k3, player2)

        #display_spielbrett_dict(spiel.cards_set)

        self.assertEqual(len(pos), 16)
Esempio n. 15
0
    def test_1(self):
        spiel = Spiel_class.Spiel(Kartenliste)

        # startvorgaben
        card1 = card_class.Card("W", "O", "O", "W", "O")
        spiel.cards_set.update({(1, 1): card1})

        ort1 = Ort((1, 1), [1, 2])
        wiese2 = Wiese((1, 1), [4, 5, 7])
        spiel.alle_orte.append(ort1)
        spiel.alle_wiesen.append(wiese2)

        spiel.cards_set[(1, 1)].ecken = {
            4: wiese2,
            5: wiese2,
            6: None,
            7: wiese2
        }
        spiel.cards_set[(1, 1)].kanten = {0: None, 1: ort1, 2: ort1, 3: None}

        spiel.possible_coordinates = [(0, 1), (1, 0), (0, -1), (-1, 0), (1, 2),
                                      (2, 1)]

        #display_spielbrett_dict(spiel.cards_set)

        k = card_class.Card("S", "O", "O", "S", "O")
        #draw_card(k)

        goal = [(0, -1, 0, k.strassen[0]), (0, -1, 0, k.orte[0]),
                (0, -1, 1, k.strassen[0]), (0, -1, 1, k.orte[0]),
                (2, 1, 1, k.strassen[0]), (2, 1, 1, k.orte[0]),
                (2, 1, 2, k.strassen[0]), (2, 1, 2, k.orte[0]),
                (1, 0, 2, k.orte[0]), (1, 0, 2, k.strassen[0]),
                (0, -1, 0, None), (0, -1, 1, None), (1, 0, 2, None),
                (2, 1, 1, None), (2, 1, 2, None), (1, 0, 2, k.wiesen[0]),
                (1, 0, 2, k.wiesen[1]), (2, 1, 1, k.wiesen[0]),
                (2, 1, 1, k.wiesen[1]), (2, 1, 2, k.wiesen[0]),
                (2, 1, 2, k.wiesen[1]), (0, -1, 0, k.wiesen[0]),
                (0, -1, 0, k.wiesen[1]), (0, -1, 1, k.wiesen[0]),
                (0, -1, 1, k.wiesen[1])]

        player1 = Player(1)
        pos_act = spiel.calculate_possible_actions(k, player1)
        self.assertEqual(25, len(pos_act))

        for tup in spiel.calculate_possible_actions(k, Player(1)):
            print(tup)
            self.assertTrue(tup in goal)
Esempio n. 16
0
    def test6(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player_Class.Player(1)
        player2 = Player_Class.Player(2)

        k1 = Card('S', 'O', 'S', 'S', 'G')
        spiel.make_action(player2, k1, 0, -1, 0)

        k2 = Card('S', 'O', 'S', 'W')
        spiel.make_action(player1, k2, 0, 1, 2)

        k3 = Card('O', 'W', 'W', 'O', 'O')
        spiel.make_action(player2, k3, 2, 0, 1)

        k4 = Card('O', 'O', 'S', 'O', 'O', True)
        spiel.calculate_possible_actions(k4, player1)
Esempio n. 17
0
    def test4(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player_Class.Player(1)
        player2 = Player_Class.Player(2)

        k1 = Card('W', 'W', 'W', 'W', 'K')
        spiel.make_action(player2, k1, -1, 0, 0, 'k')

        k2 = Card('O', 'W', 'W', 'W')
        spiel.make_action(player1, k2, -2, 0, 0)

        k3 = Card('W', 'O', 'W', 'O')
        spiel.make_action(player2, k3, -2, 1, 3, k3.wiesen[0])

        self.assertEqual(player1.punkte, 0)
        self.assertEqual(player2.punkte, 0)
Esempio n. 18
0
    def test4(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player_Class.Player(1)
        player2 = Player_Class.Player(2)

        k1 = Card('O', 'O', 'W', 'O', 'O')
        spiel.make_action(player1, k1, 1, 0, 2)

        k2 = Card('O', 'S', 'S', 'O', 'O')
        spiel.make_action(player2, k2, 1, -1, 1)

        k3 = Card('O', 'W', 'W', 'O', 'O')
        spiel.make_action(player1, k3, 2, -1, 0)

        k4 = Card('O', 'O', 'O', 'O', 'O')
        spiel.make_action(player2, k4, 2, 0, 0)
Esempio n. 19
0
    def test5(self):
        p1 = Player(1)
        p2 = Player(2)

        spiel = Spiel_class.Spiel([], p1, p2)

        k1 = Card('S', 'W', 'S', 'W')
        spiel.make_action(p1, k1, 0, -1, 0, k1.strassen[0])

        k2 = Card('O', 'S', 'S', 'W')

        w = None
        for wi in k2.wiesen:
            if sorted(wi.ecken) == [4, 5, 7]:
                w = wi

        spiel.make_action(p2, k2, 0, 1, 0, w)
        print('ende')
Esempio n. 20
0
    def test7(self):
        p1 = Player(1)
        p2 = Player(2)

        spiel = Spiel_class.Spiel([], p1, p2)

        k1 = Card('O', 'S', 'S', 'O', 'O')
        spiel.make_action(p2, k1, 1, 0, 0, k1.strassen[0])

        k2 = Card('W', 'W', 'S', 'S')
        spiel.make_action(p1, k2, 1, -1, 2)

        k3 = Card('W', 'W', 'S', 'S')
        spiel.make_action(p2, k3, 2, -1, 1)

        k4 = Card('W', 'S', 'S', 'S', 'G')
        spiel.make_action(p1, k4, 2, 0, 0)

        self.assertEqual(p2.meeples, 7)
        self.assertEqual(p2.punkte, 5)
Esempio n. 21
0
    def test2(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('W', 'S', 'S', 'W')
        spiel.make_action(player1, k1, 0, 1, 1, k1.strassen[0])

        k2 = Card("S", 'W', 'S', 'W')
        spiel.make_action(player2, k2, -1, 0, 0, k2.strassen[0])

        k3 = Card('W', 'S', 'S', 'W')
        spiel.make_action(player1, k3, -1, 1, 0, None)

        # display_spielbrett_dict(spiel.cards_set)

        spiel.final_evaluate()

        self.assertEqual(player1.punkte, 4)
        self.assertEqual(player2.punkte, 4)
Esempio n. 22
0
    def test_2(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        card0 = card_class.Card("S", "O", "S", "W")
        card1 = card_class.Card("S", "S", "W", "W")
        card2 = card_class.Card("O", "O", "O", "O", "O", True)
        card3 = card_class.Card("W", "O", "O", "W")
        card4 = card_class.Card("W", "O", "W", "O")

        k = card_class.Card("O", "S", "S", "O", "O", True)

        strasse0 = Strasse((0, 0), [0, 2])
        strasse0.koordinaten_plus_oeffnungen.update({(0, -1): [1]})
        strasse0.koordinaten_plus_oeffnungen[(0, 0)].remove(2)

        ort0 = Ort((0, 0), [1])
        ort1 = Ort((1, 1), [1])
        ort2 = Ort((2, 0), [1])
        ort0.koordinaten_plus_oeffnungen.update({
            (1, 0): 2,
            (1, 1): [],
            (2, 0): []
        })
        ort0.koordinaten_plus_oeffnungen[(0, 0)].remove(1)

        # meeple in ort2
        ort2.besitzer = Player(2)

        spiel.cards_set = {
            (0, 0): card0,
            (0, -1): card1,
            (1, 0): card2,
            (1, 1): card3,
            (2, 0): card4
        }
        spiel.possible_coordinates = [(0, 1), (-1, 0), (-1, -1), (0, -2),
                                      (1, -1), (2, -1), (3, 0), (2, 1), (1, 2)]

        goal = [(1, -1, 1, k.strassen[0]),
                (1, -1, 1, k.orte[0], (1, -1, 1, None)), (3, 0, 0, None),
                (3, 0, 0, k.strassen[0]), (3, 0, 3, None),
                (3, 0, 3, k.strassen[0])]
Esempio n. 23
0
    def test11(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('S', 'O', 'S', 'S', 'G')

        spiel.make_action(player1, k1, 1, 0, 2, k1.orte[0])

        k2 = Card('O', 'S', 'S', 'W')
        spiel.make_action(player2, k2, 0, -1, 2, k2.orte[0])
        pos = spiel.calculate_possible_actions(k2, player2)

        k3 = Card('W', 'W', 'S', 'S')
        wiese = None
        for w in k3.wiesen:
            if sorted(w.ecken) == sorted([4, 5, 7]):
                wiese = w
        spiel.make_action(player1, k3, 1, -1, 2, wiese)

        k4 = Card('S', 'W', 'S', 'W')
        spiel.make_action(player2, k4, 0, 1, 0, k4.strassen[0])

        k5 = Card('O', 'O', 'S', 'O', 'O', True)
        wiese = [w for w in k5.wiesen if w.ecken == [6]][0]
        spiel.make_action(player1, k5, 2, -1, 1, wiese)

        k6 = Card('O', 'S', 'S', 'W')
        wiese = [w for w in k6.wiesen
                 if sorted(w.ecken) == sorted([4, 5, 7])][0]
        spiel.make_action(player2, k6, 0, -2, 0, wiese)

        k7 = Card('O', 'S', 'S', 'W')
        spiel.make_action(player1, k7, 2, 0, 2, k7.orte[0])

        k8 = Card('S', 'O', 'W', 'S')
        pos = spiel.calculate_possible_actions(k8, player2)

        print('hi')
Esempio n. 24
0
    def test6(self):
        spiel = Spiel_class.Spiel(
            card_class.create_kartenliste([
                'OSSW', 'SWSW', 'SOSSG', 'WWSWK', 'WWSS', 'WWSS', 'OOSOOT',
                'OSSW', 'SOWS', 'OSSW'
            ], False))
        player1 = Player(1)
        player2 = Player(2)

        k0 = Card('S', 'W', 'W', 'S')
        spiel.make_action(player1, k0, 0, 1, 2)

        k1 = Card('W', 'W', 'S', 'S')
        spiel.make_action(player2, k1, 0, 2, 1)

        k2 = Card('W', 'W', 'S', 'W', 'K')
        spiel.make_action(player1, k2, 1, 2, 0)

        k3 = Card('O', 'S', 'S', 'W')
        spiel.make_action(player2, k3, 1, 1, 2)

        self.assertEqual(1, 1)
Esempio n. 25
0
    def test_2(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player_Class.Player(1)
        player2 = Player_Class.Player(2)

        k1 = card_class.Card('O', 'W', 'S', 'S')
        spiel.make_action(player1, k1, 0, 1, 0, k1.strassen[0])

        self.assertEqual(len(spiel.alle_strassen), 1)
        self.assertEqual(len(spiel.alle_orte), 2)
        self.assertEqual(player1.meeples, 6)

        k2 = card_class.Card('O', 'W', 'W', 'O', 'O')
        spiel.make_action(player2, k2, 1, 1, 2, k2.orte[0])

        self.assertEqual(len(spiel.alle_strassen), 1)
        self.assertEqual(len(spiel.alle_orte), 3)
        self.assertEqual(player2.meeples, 6)

        k3 = card_class.Card('W', 'S', 'S', 'S', 'G')
        spiel.make_action(player1, k3, 0, -1, 3, None)

        self.assertEqual(len(spiel.alle_strassen), 3)
        self.assertEqual(len(spiel.alle_orte), 3)

        k4 = card_class.Card('O', 'S', 'S', 'O', 'O', True)
        spiel.make_action(player2, k4, 1, -1, 1, None)

        self.assertEqual(len(spiel.alle_strassen), 3)
        self.assertEqual(len(spiel.alle_orte), 4)

        #display_spielbrett_dict(spiel.cards_set)

        k5 = card_class.Card('O', 'O', 'O', 'O', 'O', True)
        spiel.make_action(player1, k5, 1, 0, 1, None)

        self.assertEqual(len(spiel.alle_strassen), 3)
        self.assertEqual(len(spiel.alle_orte), 2)
Esempio n. 26
0
    def test5(self):
        spiel = Spiel_class.Spiel(
            card_class.create_kartenliste([
                'OSSW', 'SWSW', 'SOSSG', 'WWSWK', 'WWSS', 'WWSS', 'OOSOOT',
                'OSSW', 'SOWS', 'OSSW'
            ], False))
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('O', 'S', 'S', 'W')
        spiel.make_action(player1, k1, 1, 0, 3)

        k2 = Card('W', 'W', 'S', 'W', 'K')
        spiel.make_action(player2, k2, 1, -1, 1, 'k')

        k3 = Card('W', 'W', 'S', 'W', 'K')
        spiel.make_action(player1, k3, 0, 1, 1, 'k')

        k4 = Card('W', 'W', 'S', 'S')
        spiel.make_action(player2, k4, 0, -1, 2)

        a = sorted([
            list(v) for v in [w.alle_teile.items() for w in spiel.alle_wiesen]
        ])
        b = [[((1, 0), [5])],
             [((1, 0), [7, 4, 6]), ((1, -1), [5, 6, 7, 4]),
              ((0, -1), [6, 7, 4, 5]), ((0, 0), [5, 6, 4, 7]),
              ((0, 1), [5, 6, 7, 4])]]

        self.assertEqual(a, b)

        w = [w for w in spiel.alle_wiesen if len(w.alle_teile) != 1][0]

        for c in spiel.cards_set:
            if c != (1, 0):
                for ecke in spiel.cards_set[c].ecken:

                    self.assertEqual(spiel.cards_set[c].ecken[ecke], w)
Esempio n. 27
0
    def test9(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('W', 'W', 'S', 'S')
        pos1 = spiel.calculate_possible_actions(k1, player1)

        self.assertEqual(len(pos1), 24)
        spiel.make_action(player1, k1, 0, 1, 3)

        k2 = Card('S', 'O', 'S', 'W')
        pos2 = spiel.calculate_possible_actions(k2, player2)

        self.assertEqual(len(pos2), 40)
        wiese = [w for w in k2.wiesen if w.ecken == [5, 6]][0]

        spiel.make_action(player1, k2, 1, 1, 1, wiese)

        k3 = Card('O', 'O', 'S', 'O', 'O', True)
        pos3 = spiel.calculate_possible_actions(k3, player1)

        self.assertEqual(len(pos3), 18)
Esempio n. 28
0
    def test3(self):

        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('O', 'O', 'S', 'O', 'O', True)
        spiel.make_action(player2, k1, 1, 0, 0, k1.orte[0])

        k2 = Card('O', 'W', 'W', 'O', 'O')
        spiel.make_action(player1, k2, 1, 1, 2, k2.wiesen[0])

        k3 = Card('W', 'W', 'W', 'W', 'K')
        pos = spiel.calculate_possible_actions(k3, player2)

        #display_spielbrett_dict(spiel.cards_set)

        goal = [(-1, 0, 0, k3.wiesen[0]), (-1, 0, 0, None), (-1, 0, 0, 'k'),
                (1, 2, 0, None), (1, 2, 0, 'k')]

        self.assertEqual(len(pos), len(goal))
        for tup in pos:
            self.assertTrue(tup in goal)
Esempio n. 29
0
    def test7(self):
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('S', 'W', 'S', 'W')
        pos1 = spiel.calculate_possible_actions(k1, player1)

        self.assertEqual(len(pos1), 12)
        spiel.make_action(player1, k1, 0, 1, 0, k1.strassen[0])

        k2 = Card('O', 'W', 'W', 'O', 'O')
        pos2 = spiel.calculate_possible_actions(k2, player2)

        self.assertEqual(len(pos2), 24)
        spiel.make_action(player2, k2, 1, 0, 0, k2.orte[0])

        #display_spielbrett_dict(spiel.cards_set)

        k3 = Card('W', 'W', 'S', 'S')
        pos3 = spiel.calculate_possible_actions(k3, player1)

        self.assertEqual(len(pos3), 44)
        spiel.make_action(player1, k3, 0, 2, 3)

        k4 = Card('O', 'S', 'S', 'W')
        pos4 = spiel.calculate_possible_actions(k4, player2)

        self.assertEqual(len(pos4), 46)
        spiel.make_action(player2, k4, 1, 2, 2)

        k4 = Card('W', 'O', 'W', 'O')
        pos5 = spiel.calculate_possible_actions(k4, player1)

        #display_spielbrett_dict(spiel.cards_set)

        self.assertEqual(len(pos5), 31)
Esempio n. 30
0
    def test8(self):
        """fast der gleiche wie test7, nur mit meeple mehr in vorletzem Zug"""
        spiel = Spiel_class.Spiel(Kartenliste)
        player1 = Player(1)
        player2 = Player(2)

        k1 = Card('S', 'W', 'S', 'W')
        pos1 = spiel.calculate_possible_actions(k1, player1)

        self.assertEqual(len(pos1), 12)
        spiel.make_action(player1, k1, 0, 1, 0, k1.strassen[0])

        k2 = Card('O', 'W', 'W', 'O', 'O')
        pos2 = spiel.calculate_possible_actions(k2, player2)

        self.assertEqual(len(pos2), 24)
        spiel.make_action(player2, k2, 1, 0, 0, k2.orte[0])

        #display_spielbrett_dict(spiel.cards_set)

        k3 = Card('W', 'W', 'S', 'S')
        pos3 = spiel.calculate_possible_actions(k3, player1)

        self.assertEqual(len(pos3), 44)
        spiel.make_action(player1, k3, 0, 2, 3)

        k4 = Card('O', 'S', 'S', 'W')
        pos4 = spiel.calculate_possible_actions(k4, player2)

        self.assertEqual(len(pos4), 46)
        spiel.make_action(player2, k4, 1, 2, 2, k4.orte[0])

        k5 = Card('W', 'O', 'W', 'O')
        pos5 = spiel.calculate_possible_actions(k5, player1)

        self.assertEqual(len(pos5), 30)