资源简介

压缩包中包括Reinforcement Learning An Introduction英文与中文文档,还包括涉及的课程代码。

资源截图

代码片段和文件信息

#######################################################################
# Copyright (C)                                                       #
# 2016 - 2018 Shangtong Zhang(zhangshangtong.cpp@gmail.com)           #
# 2016 Jan Hakenberg(jan.hakenberg@gmail.com)                         #
# 2016 Tian Jun(tianjun.cpp@gmail.com)                                #
# 2016 Kenta Shimada(hyperkentakun@gmail.com)                         #
# Permission given to modify the code as long as you keep this        #
# declaration at the top                                              #
#######################################################################

import numpy as np
import pickle

BOARD_ROWS = 3
BOARD_COLS = 3
BOARD_SIZE = BOARD_ROWS * BOARD_COLS

class State:
    def __init__(self):
        # the board is represented by an n * n array
        # 1 represents a chessman of the player who moves first
        # -1 represents a chessman of another player
        # 0 represents an empty position
        self.data = np.zeros((BOARD_ROWS BOARD_COLS))
        self.winner = None
        self.hash_val = None
        self.end = None

    # compute the hash value for one state it‘s unique
    def hash(self):
        if self.hash_val is None:
            self.hash_val = 0
            for i in self.data.reshape(BOARD_ROWS * BOARD_COLS):
                if i == -1:
                    i = 2
                self.hash_val = self.hash_val * 3 + i
        return int(self.hash_val)

    # check whether a player has won the game or it‘s a tie
    def is_end(self):
        if self.end is not None:
            return self.end
        results = []
        # check row
        for i in range(0 BOARD_ROWS):
            results.append(np.sum(self.data[i :]))
        # check columns
        for i in range(0 BOARD_COLS):
            results.append(np.sum(self.data[: i]))

        # check diagonals
        results.append(0)
        for i in range(0 BOARD_ROWS):
            results[-1] += self.data[i i]
        results.append(0)
        for i in range(0 BOARD_ROWS):
            results[-1] += self.data[i BOARD_ROWS - 1 - i]

        for result in results:
            if result == 3:
                self.winner = 1
                self.end = True
                return self.end
            if result == -3:
                self.winner = -1
                self.end = True
                return self.end

        # whether it‘s a tie
        sum = np.sum(np.abs(self.data))
        if sum == BOARD_ROWS * BOARD_COLS:
            self.winner = 0
            self.end = True
            return self.end

        # game is still going on
        self.end = False
        return self.end

    # @symbol: 1 or -1
    # put chessman symbol in position (i j)
    def next_state(self i j symbol):
        new_state = State()
        new_state.data = np.copy(self.data)
        new_state.data[i j] = symbol
        return new_state

    # print the board
    def print(self):
        for i 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件   12613382  2018-09-29 12:23  Reinforcement Learning-增强学习(文档+代码)\Reinforcement Learning:An Introduction.pdf

     文件         40  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\.gitignore

     文件        148  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\.travis.yml

     文件      11177  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter01\tic_tac_toe.py

     文件       9048  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter02\ten_armed_testbed.py

     文件       3808  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter03\grid_world.py

     文件       7391  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter04\car_rental.py

     文件       2445  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter04\gamblers_problem.py

     文件       3436  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter04\grid_world.py

     文件      13065  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter05\blackjack.py

     文件       1814  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter05\infinite_variance.py

     文件       9355  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter06\cliff_walking.py

     文件       4269  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter06\maximization_bias.py

     文件       6574  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter06\random_walk.py

     文件       4018  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter06\windy_grid_world.py

     文件       4249  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter07\random_walk.py

     文件       1627  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter08\expectation_vs_sample.py

     文件      23252  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter08\maze.py

     文件       4892  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter08\trajectory_sampling.py

     文件      15793  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter09\random_walk.py

     文件       4262  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter09\square_wave.py

     文件       9605  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter10\access_control.py

     文件      13681  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter10\mountain_car.py

     文件      11839  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter11\counterexample.py

     文件      12140  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter12\mountain_car.py

     文件       9679  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter12\random_walk.py

     文件       8012  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\chapter13\short_corridor.py

     文件      36003  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\images\example_13_1.png

     文件     238133  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\images\example_6_2.png

     文件      31488  2018-09-17 16:16  Reinforcement Learning-增强学习(文档+代码)\reinforcement-learning-an-introduction-master\images\example_8_4.png

............此处省略69个文件信息

评论

共有 条评论