ShangtongZhang / reinforcement-learning-an-introduction

Python Implementation of Reinforcement Learning: An Introduction
MIT License
13.47k stars 4.81k forks source link

Chapter 04: CarRental.py - suggestions for realRentalFirst/SecondLoc fix #81

Closed ychong closed 6 years ago

ychong commented 6 years ago

Hi ShangtongZhang,

This is regarding the CarRental.py for Chapter 04. I'm curious under the expectedReturn function, under line 115 and 116 for variables realRentalFirst/SecondLoc, why would you require the valid rental requests to be less than the actual # of cars?

Wouldn't you want to maximize your returns by actually renting out the maximum number of cars? When I changed lines 115 and 116 to the following:

realRentalFirstLoc = max(numOfCarsFirstLoc, rentalRequestFirstLoc) realRentalSecondLoc = max(numOfCarsSecondLoc, rentalRequestSecondLoc)

I actually get higher expected returns in the range of 1650-1750, instead of expected returns at 550-650. Let me know if this makes sense to you.

Regards, Yi Xiang chongyixiang@gmail.com

ShangtongZhang commented 6 years ago

How can Jack rent 5 cars if only have 2 cars?

ychong commented 6 years ago

Ok thanks for clarifying. Appreciate it