Beispiel #1
0
    def gameover(self, score):
        global games_count
        global x_train
        global y_train

        # when game ends, append a data point based on how we lost
        if games_count >= 0:
            x_train = np.append(x_train, self.last_value)
            if self.jumped:
                y_train = np.append(y_train, [0])
            else:
                y_train = np.append(y_train, [1])

        # training the model at the end of each run
            model.fit(x_train, y_train, epochs=10, verbose=1, shuffle=1)
            print(y_train)

        games_count += 1

        print("x_train:")
        print(x_train)
        print("y_train ")
        print(y_train)

        if games_count >= total_number_of_games:
            return
        controlled_run(self, games_count)
Beispiel #2
0
    def gameover(self, score):
        global games_count
        global x_train
        global y_train
        global model

        games_count += 1

        # Printing x_train and y_train
        print(x_train)
        print(y_train)

        if games_count is not 0 and games_count % train_frequency is 0:
            # Before training, let's make the y_train array categorical
            y_train_cat = to_categorical(y_train, num_classes=2)

            print(x_train)

            # Let's train the network
            model.fit(x_train, y_train_cat, epochs=50, verbose=1, shuffle=1)

            # Reset x_train and y_train
            x_train = np.array([])
            y_train = np.array([])

        if games_count >= total_number_of_games:
            # Let's exit the program now
            return

        # Let's start another game!
        controlled_run(self, games_count)
Beispiel #3
0
	def gameover(self, score):
		global games_count
		games_count += 1

		if games_count>=total_number_of_games:
			# Let's exit the program now
			return

		# Let's start another game!
		controlled_run(self, games_count)
Beispiel #4
0
    def gameover(self, score):
        global games_count
        global x_train
        global y_train
        global model

        global all_x
        global all_y
        global all_scores
        global average_scores
        global average_score_rate

        games_count += 1

        # mosntando os valores de x_train e y_train
        print(x_train)
        print(y_train)

        # adicionando os valores de x e y train, em um vetor, para utilizar posteriormente
        all_x = np.append(all_x, x_train)
        all_y = np.append(all_y, y_train)

        all_scores.append(score)

        Wrapper.visualize()

        #formula para colocar na tabela o media de pontos a nas partidas
        if games_count is not 0 and games_count % average_score_rate is 0:
            average_score = sum(all_scores) / len(all_scores)
            average_scores.append(average_score)

        if games_count is not 0 and games_count % train_frequency is 0:
            # formula para colocar na tabela da frequencia de treino
            y_train_cat = to_categorical(y_train, num_classes=2)

            print(x_train)

            # Treinar a rede neural
            model.fit(x_train, y_train_cat, epochs=50, verbose=1, shuffle=1)

            # Resetar o treinamento
            x_train = np.array([])
            y_train = np.array([])

        if games_count >= total_number_of_games:
            # Sair do jogo quando atingir o limite de jogos
            return

        # Começando outro jogo
        controlled_run(self, games_count)
Beispiel #5
0
    def gameover(self, score):
        global games_count
        global x_train
        global y_train
        global model

        global all_x
        global all_y
        global all_scores
        global average_scores
        global average_score_rate

        games_count += 1

        # Printing x_train and y_train
        print(x_train)
        print(y_train)

        all_x = np.append(all_x, x_train)
        all_y = np.append(all_y, y_train)

        all_scores.append(score)

        Wrapper.visualize()

        if games_count is not 0 and games_count % average_score_rate is 0:
            average_score = sum(all_scores) / len(all_scores)
            average_scores.append(average_score)

        if games_count is not 0 and games_count % train_frequency is 0:
            # Before training, let's make the y_train array categorical
            y_train_cat = to_categorical(y_train, num_classes=2)

            print(x_train)

            # Let's train the network
            model.fit(x_train, y_train_cat, epochs=50, verbose=1, shuffle=1)

            # Reset x_train and y_train
            x_train = np.array([])
            y_train = np.array([])

        if games_count >= total_number_of_games:
            # Let's exit the program now
            return

        # Let's start another game!
        controlled_run(self, games_count)
    def gameover(self, score):
        global games_count
        global x_train
        global y_train

        print(x_train)
        print(y_train)

        if (games_count > 0):
            y_train_cat = to_categorical(y_train, num_classes=2)
            model.fit(x_train, y_train_cat, epochs=50, verbose=1, shuffle=1)

        games_count += 1

        if games_count >= total_number_of_games:
            return
        controlled_run(self, games_count)
Beispiel #7
0
	def __init__(self):
		# Start the game
		controlled_run(self, 0)
 def __init__(self):
     controlled_run(self, 0)