X-Git-Url: https://git.cworth.org/git?p=wordgame;a=blobdiff_plain;f=grid4.c;h=9e686834fa5d29a8555b0c109e96ca51fcc20852;hp=cd1e90b7f245c50e7e9e16ee44c20a22029d3528;hb=HEAD;hpb=c0136554ee870455bf1d1b527d7a724beda989b3 diff --git a/grid4.c b/grid4.c index cd1e90b..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); @@ -37,6 +49,8 @@ main (void) dict_add_words_from_file (&dict, "words.txt"); grid_init (&grid, 4); + if (letters) + grid_set_letters (&grid, letters); dict_init (&solution); grid_solve (&grid, &dict, &solution);