X-Git-Url: https://git.cworth.org/git?p=wordgame;a=blobdiff_plain;f=grid4.c;h=9e686834fa5d29a8555b0c109e96ca51fcc20852;hp=96cb5e387283d651eedf1da4440ab0fd706a3fd5;hb=HEAD;hpb=896bfd48616953ca8cbe848953b46abdb20f78a3 diff --git a/grid4.c b/grid4.c index 96cb5e3..9e68683 100644 --- a/grid4.c +++ b/grid4.c @@ -1,7 +1,7 @@ /* * Copyright © 2006 Carl Worth * - * This program is free software; you can redistribute it and\/or modify + * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. @@ -19,16 +19,28 @@ #include "grid.h" #include "word-game.h" +#include #include #include #define GAME_LENGTH (3 * 60) int -main (void) +main (int argc, char *argv[]) { dict_t dict, solution; grid_t grid; struct timeval tv; + const char *letters = NULL; + + if (argc > 1) { + if (argc == 2) { + letters = argv[1]; + } else { + fprintf (stderr, "Usage: %s [letters]\n", argv[0]); + fprintf (stderr, "Uses the given 16 letters or else a random grid.\n"); + return 1; + } + } gettimeofday (&tv, NULL); srand (tv.tv_sec ^ tv.tv_usec); @@ -36,7 +48,9 @@ main (void) dict_init (&dict); dict_add_words_from_file (&dict, "words.txt"); - grid_init (&grid); + grid_init (&grid, 4); + if (letters) + grid_set_letters (&grid, letters); dict_init (&solution); grid_solve (&grid, &dict, &solution);