Exemplo n.º 1
0
                    if i % 4:  #white -1
                        if log[i]['1']['response']['x'] != -1:
                            board.step(
                                log[i]['1']['response']['x'] * 8 +
                                log[i]['1']['response']['y'], -1)
                        history.append((board.getState().copy(), int(i / 2)))
                    else:  #black 1
                        if log[i]['0']['response']['x'] != -1:
                            board.step(
                                log[i]['0']['response']['x'] * 8 +
                                log[i]['0']['response']['y'], 1)
                        history.append((board.getState().copy(), int(i / 2)))
                    i += 2

                if board.isTerminate():
                    result = board.BlackWins()
                    for state in history:
                        updateTP(training_position[state[1]], state[0], result)
                    file_total += 1

            print('%s-%s has been handled, %d valid' %
                  (str(start * 100 + 1), str(start * 100 + 100), file_total))
            if (start + 1) % 100 == 0:
                save(training_position)
                print('%s has been saved' % str(start * 100 + 100))
            total += file_total

    save(training_position)
    print("saved")
    print("%d valid" % (total))