예제 #1
0
    def run(self):
        max_unit = 0
        for i in range(self.ran):
            print("Generation ", i)
            gen = Generation(self.p)
            #gen.hand.print_cards()
            gen.assign_unit_value(0)
            #gen.print_stats()
            gen.calc_fitness(self.step, 0)

            #for i in range(p.size):
            #    print(gen.population.units[i].fitness)

            if (i == self.ran - 1):
                break

            max_val = 0
            for i in range(gen.population.size):
                if (gen.population.units[i].fitness > max_val):
                    max_unit = gen.population.units[i]
                    max_val = gen.population.units[i].fitness

            print(max_unit.fitness)
            s = Step(gen)
            gen.population.units = s.generate_mating_pool()

        max_val = 0
        max_unit = 0
        for i in range(gen.population.size):
            if (gen.population.units[i].fitness > max_val):
                max_unit = gen.population.units[i]
                max_val = gen.population.units[i].fitness

        print(max_unit.weights)
        return max_unit.weights
예제 #2
0
    my_cards = g.deck.deal_cards(2)

    my_cards[0].print_short()
    my_cards[1].print_short()

    print("\nHow much Money would you like to bet?")
    print("You Have", money, "Dollars")
    bet = int(input())

    eval = g.calc_hand(0, my_cards)

    print("\n")

    g.print_stats()
    t = g.calc_fitness(1, eval)

    if (t):
        money += bet * 2
    else:
        money -= bet

    print("Human Evaluation:", eval, "Unit Evaluation:",
          g.population.units[0].value)

    print(g.population.units[0].fitness)

    g.deck.cards.append(my_cards[0])
    g.deck.cards.append(my_cards[1])

    g = Generation(p)