Timeline for Tic-tac-toe OOP Minimax Algorithm
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 4 at 23:41 | comment | added | J_H |
@stefan In this context, it would not be sensible for caller to pass in an empty str or empty list , so the board or ... idiom makes sense. OTOH in a different application which e.g. could make good use of "" or [] , that idiom would be plain wrong. It would be a code defect. But that's not the tic-tac-toe application being examined ATM.
|
|
May 4 at 23:23 | comment | added | stefan | The fact is - your advice is plain wrong. | |
May 4 at 16:41 | comment | added | J_H |
@stefan, a param or some_param_value() idiom is easily read, and is a direct translation of the much older Common Lisp (setf x (or param (some_param_value))) expression using generalized predicates. I confess that in a python context the idiom requires the Author to devote a moment's thought about truthiness, in order to spare the Reader a bit of effort. Occasionally passing in a zero-length dict vs list is of interest. Here it is immediately clear that a passed in vector full of zeros will definitely be True .
|
|
May 4 at 9:48 | comment | added | stefan |
mutable args - I strongly disagree with your "usual" advice. While yours is working correctly here, I strongly advice to use the ìs None test which works for empty lists and strings. I claim ìs None is standard way.
|
|
Apr 27 at 4:29 | vote | accept | flakpm | ||
Apr 24 at 6:30 | comment | added | J_H |
The former: remove it from the class entirely and put it in its own function outside of the class. Think about that beautiful docstring you wrote: "Represents the state of a tictactoe board." We write down such things so we can later decide "does this belong in here?", "does that belong?" I claim that def random() is a Kitchen Sink method, unrelated to the Single Responsibility of the class. Rather, it is a very nice consumer of what the class offers. We could add this, that, and the kitchen sink, but then we'd have a big mess, right? Keep it organized, and it will be maintainable.
|
|
Apr 24 at 5:01 | comment | added | flakpm |
I have addressed pretty much everything you mentioned. Regarding the Board.random() method, are you recommending removing it from the class entirely and putting it in its own function outside of the class, or are you recommending having a function outside of the class that calls the random method?
|
|
Apr 23 at 4:12 | history | edited | J_H | CC BY-SA 4.0 |
deleted 2 characters in body
|
Apr 23 at 0:43 | history | edited | J_H | CC BY-SA 4.0 |
added 142 characters in body
|
Apr 23 at 0:35 | history | answered | J_H | CC BY-SA 4.0 |