TakeDirection in Game chapter

8 views
Skip to first unread message

Surya Subramanian

unread,
Jan 25, 2016, 10:11:21 AM1/25/16
to Machine Learning Projects for DotNET Developers
Hi Mathias,
Thank you for an enjoyable learning experience reading your engaging book on Machine Learning using F#. Your choice of topics and problems especially make it stand out.
While reading the chapter on Reinforcement Learning, I found the following a bit confusing. 
    type Dir =
        | North
        | West
        | South
        | East

let takeDirection (act:Act) (dir:Dir) =
    match act with
    | Straight -> dir
    | Left ->
        match dir with
        | North -> East
        | East -> South
        | South -> West
        | West -> North
    | Right ->
        match dir with
        | North -> West
        | West -> South
        | South -> East
        | East -> North

Usually North points upwards. So, when the Hero is pointing North, turning Left would make it point West. I dont follow why takeDirection implements it the other way. Am I missing something?
-Surya



Mathias Brandewinder

unread,
Jan 30, 2016, 1:36:29 PM1/30/16
to Machine Learning Projects for DotNET Developers
Hi Surya,

Glad you are enjoying it - thank you!

I think you are not missing anything, this sounds like a silly mistake on my side; I am one of these people who has trouble with left and right, and always has to first think 'which hand do I use for writing' to identify them...

The error is of no consequence here, because left and right play a symmetrical role, but it IS an error nevertheless, thanks for pointing it out!

Mathias
Reply all
Reply to author
Forward
0 new messages