[Kde-games-devel] kshisen request - show different tiles!

Ian Wadham ianw2 at optusnet.com.au
Wed Mar 11 12:48:59 CET 2009


On Wed, 11 Mar 2009 5:26:58 pm Matthew Woehlke wrote:
> Ian Wadham wrote:
> > On Wed, 11 Mar 2009 3:24:02 pm Matthew Woehlke wrote:
> >> Ian Wadham wrote:
> >>> Or maybe you could (locally) change
> >>> the line "if (++tileCount >= 4) {" to "if (++tileCount >= 2) {" ... ;-)
> >>> to get 2 of each tile in the 14x6 layout.
> >>
> >> Um... that would change the game play pretty radically, methinks :-).
> >
> > Errrmmm ... I said "locally" (i.e. never committed) didn't I? :-)
>
> Yes, but still ;-). (Also since I'm fairly sure it would break... how do
> you will a 144-tile board with 84 tiles?)

MHO = (will == fill) ? readOn() : skipParagraph();
On further thought, my guess is that changing the magic number 4 to 2
might be an improvement, but the only way to be sure is to test it.  The
algorithm would just keep dealing pairs of tiles till the required number
has been dealt.  On a 144-tile board without Chinese rules you would
get two of every tile for the first 84, then two of each member of each
suit for the next 54 (tiles 1-27), then 3 pairs of seasons to finish up.

Mind you, I hate and am deeply suspicious of code that has magic
numbers in it.  What if that 4 is meaningful somewhere else in the
code?  Then the code might break if you change 4  to 2.  If there is
a 4 somewhere else, is it used for the same purpose or another
purpose?  How can you be sure?  This is just one kind of stuff that
makes it hard for people other than the original author to maintain
code and maybe even he/she has trouble.

Cheers, Ian W.


More information about the kde-games-devel mailing list