Login  Register

Re: Agile Artificial Intelligence

Posted by bentai on Aug 21, 2020; 6:07am
URL: https://forum.world.st/Agile-Artificial-Intelligence-tp5119233p5120746.html

I think I found another bug in the book. I am using the Safari version, and the code in the text doesn't match the screenshot. For example, the text says:
somePoints := OrderedCollection new.
500 timesRepeat: [    somePoints add: {(50 atRandom - 25) . (50 atRandom - 25)}].
f := [ :x | (-2 * x) - 3 ].
"We use the Roassal Grapher engine to plot our points"
g := RTGrapher new.
d := RTData new.
d dotShape    color: [ :p | (p second > (f value: p first)) ifTrue: [ Color red trans ]                    ifFalse: [ Color blue trans ] ].
d points: somePoints.
d x: #first.
d y: #second.
g add: d.
g
"" The rendered code in the Safari version gets an error, whereas the screenshot version works:
f := [  :x | (-2 * x) - 3 ].

somePoints := OrderedCollection new.
500 timesRepeat: [ somePoints add: (( 50 atRandom - 25 ) @ ( 50 atRandom - 25 )) ].

g := RTGrapher new.
d := RTData new.
d dotShape color: [ :p | (p y > (f value: p x)) ifTrue: [ Color red trans ] ifFalse: [ Color blue trans ] ].
d points: somePoints.
d x: #x.
d y: #y.
g add: d.
g
-----------------------------------------------------------------------------------

This may be part of the cause of my bug report on Git, e.g. there is a mismatch between the eBook version, the printed version and the Safari/OReilly version.

It is Pharo 7.0.4, but I don't know if that matters in this case.

I apologize for not following the procedure of cloning the github repository and creating bug request from there with pull requests, but I am still working out the configuration of Iceberg.

Cheers,
Tom Sturgeon


Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.