Hello everyone!

Happy to inform you that I've just updated my game :)
There where lots of changes made due to Stef's and kilon's comments. I
really appreciate your feedback.
Also thanks to Phil for his note (originally this game is written on Pharo
3.0).

Update:

- "impossible mode is quite easy to win" -kilon. Now it is harder to win,
but it is possible despite the name of mode :)
- if click New Game it keeps difficulty level + playing mode(PvsP or
PvsComp) + now position of it is not 0@0
- added background for game log and game state for better visibility
- added the class comment: XsAndOsGame new openInWorld.
- all methods now are classifyied
- fixed problems reported by criticBrowser(not all problems but many)
- other many minor fixes to problems which were mentioned by Stef

ToDo in next versions:

- make some methods shorter
- divide twoPlayers logic and PlayervsComputer logic in different classes
- lots of other style changes and minor fixes
- AND I want to provide a possibility to play not only just on 3X3 board
but on any other (but I don't know yet how to implement AI)
the last point about AI should be seriously thought through and requiers
some of my time:) hope to get it done
Link for project:
http://smalltalkhub.com/#!/~MarkRizun/XsAndOsGame/versions/XsAndOsGame-MarkRizun.2

Again thanks to everyone!

Mark



2014-02-10 10:22 GMT+02:00 p...@highoctane.be <p...@highoctane.be>:

> I loaded the game in Pharo2.0
>
> There is ImageMorph>>form: aForm missing but adding
>
> ImageMorph>>form: aForm
>    self image: aFrom
>
> makes it work.
>
> Phil
>
>
>
>
> On Sun, Feb 9, 2014 at 9:59 PM, Маркіян Різун <mri...@gmail.com> wrote:
>
>> Thanks for comment.
>> I'll fix all problems and change everything you mentioned, hope to
>> succeed in it.
>>
>> Mark
>>
>>
>> 2014-02-09 22:51 GMT+02:00 Pharo4Stef <pharo4s...@free.fr>:
>>
>>> Hi mark
>>>
>>> I read a bit your code
>>>
>>> It is nice for a first project!!!!
>>>
>>> Here are some feedback. I suggest that you take into account the easy
>>> one and produce a new version and if you want to
>>> train your skills you try to see how to address the difficult ones.
>>>
>>> Stef
>>>
>>>
>>>
>>> - Add it in the class comment
>>>  XsAndOsGame new openInWorld.
>>>
>>> - you have some unclassified protocols on the class side.
>>>
>>> - you may want to run smallLint (criticBorwser on your code and see the
>>> hints that it can give you).
>>>
>>> - When you create a new game do not move the window to the top corner :)
>>>
>>> easyBtn -> easyButton (you do not pay per character :))
>>>
>>> findEmptyCellPos -> findEmptyCellPosition
>>> not in accessing
>>>
>>> impBtn -> impossibleButton
>>>
>>> .... :)
>>>  - Why do you need a separate class just for three colors?
>>>  I would merge
>>> XsAndOsGameColors and XsAndOsGame
>>>
>>> XsAndOsGame>>initialize is long
>>>  May be you should extract some methods from it (methods that you can
>>> then reuse for other tasks)
>>>
>>>
>>> renderOContents
>>> | delta offset x1 y1 x2 y2 rect |
>>>  delta := CellRenderer cellExtent - 1.
>>> offset := self offsetWithinGridForm.
>>> x1 := offset x + self oCorner x.
>>>  x2 := offset x + delta x - self oCorner x.
>>> y1 := offset y + self oCorner y.
>>> y2 := offset y + delta y - self oCorner y.
>>>  rect := Rectangle new setOrigin: x1 @ y1 corner: x2 @ y2.
>>> self targetForm getCanvas
>>> fillOval: rect
>>>  color: XsAndOsGameColors gameBoardBackgroundColor
>>> borderWidth: 3
>>> borderColor: XsAndOsGameColors OColor
>>>
>>> What do you refer to CellRenderer direcly? self class ?
>>>
>>>
>>> rendererFor: aCell
>>> "VERY BAD IMPLEMENTATION OF THIS METHOD!!!"
>>>
>>> aCell class = EmptyCell
>>> ifTrue: [ ^ CellRenderer ].
>>> aCell class = XCell
>>>  ifTrue: [ ^ XCellRenderer ].
>>> aCell class = OCell
>>> ifTrue: [ ^ OCellRenderer ]
>>>
>>> indeed :)
>>> why not implementing some methods call renderClass and sending a message
>>> to the object :)
>>>
>>> mptyCell>>initialize
>>> super initialize.
>>>
>>>
>>>
>>> CellRenderer>>offsetWithinGridForm
>>> "Returns a point - left top corner of current cell"
>>>
>>> ^ CellRenderer cellExtent * ((self cellLocation x - 1) @ (self
>>> cellLocation y - 1))
>>> => self clas cellExtent
>>>
>>> CellRenderer >> renderBorderBottom
>>> | delta offset x1 y1 x2 y2 |
>>> delta := CellRenderer cellExtent - 1.
>>>  offset := self offsetWithinGridForm.
>>> x1 := offset x.
>>> x2 := x1 + delta x.
>>>  y1 := offset y + delta y.
>>> y2 := y1.
>>> self targetForm getCanvas
>>>  line: x1 @ y1
>>> to: x2 @ y2
>>> width: 1
>>> color: XsAndOsGameColors cellBorderColor
>>>
>>> =>
>>> CellRenderer >> renderBorderBottom
>>> | delta offset x1 y1 x2 y2 |
>>> delta := self class cellExtent - 1.
>>>  offset := self offsetWithinGridForm.
>>> x1 := offset x.
>>> x2 := x1 + delta x.
>>>  y1 := offset y + delta y.
>>> y2 := y1.
>>> self targetForm getCanvas
>>>  line: x1 @ y1
>>> to: x2 @ y2
>>> width: 1
>>> color: XsAndOsGameColors cellBorderColor
>>>
>>>
>>> I was wondering why you need Grid (I would rename it CellGrid) and do
>>> not use a Matrix.
>>>
>>> grid sizeOfGrid
>>>  -> I would rename sizeOfGrid into size like that your grid can be a
>>> bit more polymorphic from its API point of view
>>>
>>>
>>> makeGameBoarMorph
>>>  -> typo :)
>>> Now I want wondering why you do not have an instance variable to hold it
>>>
>>>
>>> Future fun ideas for new versions:
>>> --------------------------------------------
>>> playerVsComputer
>>> self vsComputer
>>> ifTrue: [
>>>  self vsComputer: false.
>>> self stateMorph contents: 'Player 1 VS Player 2' ]
>>> ifFalse: [
>>>  self vsComputer: true.
>>> self stateMorph contents: 'Player VS Computer ---> Difficulty: ' , self
>>> difficulty asString ].
>>>  self vsComputer
>>> ifTrue: [
>>> self easyBtn enable.
>>> self normalBtn enable.
>>>  self impBtn enable ]
>>> ifFalse: [
>>> self easyBtn disable.
>>>  self normalBtn disable.
>>> self impBtn disable ]
>>> This kind of code may be think that may be you need another object that
>>> represent the
>>>  TwoUsers
>>> vsComputer
>>> strategy
>>>  I'm not sure but clicked look quite long.
>>> May be you should create another class that can represent the logic of
>>> the game.
>>>
>>> A really interesting exercise would be to see how you can create a
>>> boardGame for 15*15 and see how it breaks some hidden rules.
>>> On 08 Feb 2014, at 15:07, Маркіян Різун <mri...@gmail.com> wrote:
>>>
>>> Updated XsAndOsGame: added AI, also fixed some problems, that Damien
>>> mentioned in his comments.
>>> Btw, thanks to Damien, because I learned for myself a lot of new useful
>>> things.
>>> Note: The new version is XsAndOsGame (NOT Xs&OsGame) !
>>> To play it type in workspace: XsAndOsGame new openInWorld.
>>> If you want to play vs computer press button "ToggleMode" and choose
>>> difficulty. Initially it is easy.
>>>
>>> Mark
>>>
>>>
>>> 2014-02-05 15:57 GMT+02:00 Маркіян Різун <mri...@gmail.com>:
>>>
>>>> Thanks, I'll certainly take a look at it
>>>>
>>>>
>>>> 2014-02-05 Damien Cassou <damien.cas...@gmail.com>:
>>>>
>>>> On Tue, Feb 4, 2014 at 8:58 PM, Маркіян Різун <mri...@gmail.com> wrote:
>>>>> > I should think how to write this tutorial.
>>>>>
>>>>>
>>>>> on the technical point of view, I advise you to use Pillar:
>>>>> http://www.smalltalkhub.com/#!/~Pier/Pillar
>>>>>
>>>>> --
>>>>> Damien Cassou
>>>>> http://damiencassou.seasidehosting.st
>>>>>
>>>>> "Success is the ability to go from one failure to another without
>>>>> losing enthusiasm."
>>>>> Winston Churchill
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>

Reply via email to