Skip to content

Commit 809988d

Browse files
bruceyoungsysudelaray
authored andcommitted
add chapter 18 and 19 for 4th edition (aimacode#1076)
* chapter 18 learning * add chapter 19 * move init dataset in NN learner * add adam optimizer, add nn learner * remove cpt 19 for debug * change while loop in games4e * add chapter 19 * add sgd and adam optimizer * add chpt19 deep nn * add rnn * add auto encoder * add comments, correct tests * add more comments, change algorithms according to orders of chapter sections * add keras and numpy to requirements * add tf as requirement * add gc in test agent * fix agent bugs for running test_agent and test_agent_4e together * fix build error * add chapter 21 and 22 * add chapter 12 and part of 13 * remove chapter 12 and 13, add test of rl * modify rnn test * fix build error * Update utils4e.py
1 parent 37110de commit 809988d

13 files changed

Lines changed: 2600 additions & 14 deletions

DeepNeuralNet4e.py

Lines changed: 505 additions & 0 deletions
Large diffs are not rendered by default.

agents_4e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def add_thing(self, thing, location=(1, 1), exclude_duplicate_class_items=False)
514514
def is_inbounds(self, location):
515515
"""Checks to make sure that the location is inbounds (within walls if we have walls)"""
516516
x, y = location
517-
return not (x < self.x_start or x >= self.x_end or y < self.y_start or y >= self.y_end)
517+
return not (x < self.x_start or x > self.x_end or y < self.y_start or y > self.y_end)
518518

519519
def random_location_inbounds(self, exclude=None):
520520
"""Returns a random location that is inbounds (within walls if we have walls)"""

games4e.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ def backprop(n, utility):
210210

211211
root = MCT_Node(state=state)
212212

213-
while N > 0:
213+
for _ in range(N):
214214
leaf = select(root)
215215
child = expand(leaf)
216216
result = simulate(game, child.state)
217217
backprop(child, result)
218-
N -= 1
218+
219219
max_state = max(root.children, key=lambda p: p.N)
220220

221221
return root.children.get(max_state)

0 commit comments

Comments
 (0)