Example #1
0
    def run(self):
        run = True
        clock = pygame.time.Clock()
        while run:
            clock.tick(30)
            self.draw()
            if self.oczekiwanie:
                odpowiedz = self.n.send({-1: []})
                if odpowiedz:
                    run = False
                    g = Gra(self.win, self.n)

                    for gracz in odpowiedz:
                        p = Gracz(gracz)
                        g.dodaj_gracza(p)
                    g.run()

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    run = False
                    pygame.quit()
                    quit()

                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_RETURN:
                        if len(self.nazwa) > 1:
                            self.oczekiwanie = True
                            self.n = Siec(self.nazwa)
                    else:

                        key_name = pygame.key.name(event.key)

                        key_name = key_name.lower()
                        self.type(key_name)
Example #2
0
    def obsluga_kolejki(self, gracz):

        self.kolejka.append(gracz)

        if len(self.kolejka) >= self.GRACZE:
            gra = Gra(self.numer_gry, self.kolejka[:])

            for g in gra.gracze:
                g.zacznij_gre(gra)

            self.numer_gry += 1
            self.kolejka = []
            print(f"Gra {self.numer_gry - 1} rozpoczeła się")
Example #3
0
import random
from gra import Gra
from monteCarloGenerator import MonteCarloGenerator

SEED = random.randint(0, 500)
random.seed(SEED)

nowaGra = Gra(4)
nowaGra.print()

randoms = [random.randint(0, 3) for x in range(400)]
# i = 0
monteCarloSize = 100

while nowaGra.notOver():
    # time.sleep(1)
    # ruch = randint(0, 3)
    # print("Wylosowano: ", str(ruch))
    # moved = nowaGra.move(randoms[i])
    # nextMove = MonteCarloGenerator.generateNext(nowaGra, monteCarloSize)
    # print(nextMove)
    moved = nowaGra.move(MonteCarloGenerator.generateNext(nowaGra, monteCarloSize))
    # moved = nowaGra.move(random.randint(0, 3))
    # i += 1
    # if moved:
        # nowaGra.print()

    print("Moves= ", nowaGra.moves)

nowaGra.print()
print("Game over, wykonano {} ruchów. Zdobyto {} punktów".format(nowaGra.moves, nowaGra.score))