[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#682454: RFS: cows-and-bulls/1.0-1 [ITP] - Words-based cows and bulls guessing game



(I don't intend to sponsor this package.)

* Guruprasad <lgp171188@gmail.com>, 2012-07-23, 02:46:
   dget -x http://mentors.debian.net/debian/pool/main/c/cows-and-bulls/cows-and-bulls_1.0-1.dsc

It doesn't work in a minimal environment:
| $ cows-and-bulls
| Unable to open the dictionary file

Perhaps some dependencies are missing?

The game segfaults if stdin ends prematurely:
| $ cows-and-bulls </dev/null
| Enter the length of the word to be used to play(3-8):Enter a valid length to be used (3-8)
| Segmentation fault

Or it falls into infinite loop:
| $ echo 4 | cows-and-bulls
| Enter the length of the word to be used to play(3-8):Guess the word:The guessed word should be 4 characters long
| Guess the word:The guessed word should be 4 characters long
| Guess the word:The guessed word should be 4 characters long
| Guess the word:The guessed word should be 4 characters long
| Guess the word:The guessed word should be 4 characters long
| Guess the word:The guessed word should be 4 characters long
| Guess the word:The guessed word should be 4 characters long
[snip - ad infinitum...]

If I enter invalid length, the game continues:
| $ cows-and-bulls
| Enter the length of the word to be used to play(3-8):1
| Enter a valid length to be used (3-8)
| Guess the word:what?
| The guessed word should be 1 characters long

It appears to me that you count bytes, not characters. This is incorrect, as some words in /usr/share/dict/words are non-ASCII. Perhaps you should filter them out, to avoid surprises.

Now looking at the source:

 srand(time(0));

You should normally call srand only once, at the start of the program.

 int n = (rand() % (words_of_length_n.size()-1)) + 1;
 return words_of_length_n[n];

As far as I can see, this exclude the very first (0th) word. Why?

 cout<<cows<<" Cows and "<<bulls<<" bulls"<<endl;

Is there a reason "Cows" is capitalized?

   cout<<"Enter the length of the word to be used to play("<<MIN_WORD_LENGTH

Missing space before "(" and after ":".

     cout<<"Guess the word:";

Missing space after ":".

   cout<<"Do you want to play again(y/n)?:";

Ditto.


All in all, I found it relatively low quality, especially if you take into account that it's a game that one could be implement in 5 minutes in a scripting language. Sorry.

--
Jakub Wilk


Reply to: