README_from_ttt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ttt
  2. ===
  3. Simple arbitrary-size tic-tac-toe game.
  4. History
  5. -------
  6. ttt was designed and written in response to a challenge from a colleague who
  7. wrote a console tic-tac-toe game in C++. The code was (frankly) written
  8. sloppily, and the program's structure severely limited its
  9. modularity. Furthermore, it was dependent on external commands unique to
  10. Microsoft operating systems (such as `cls` to clear the console).
  11. I decided I would rewrite the game using clean C code, require no outside
  12. dependencies (besides the standard C library), and allow a board of variable
  13. size. I achieved a program with significant improvements in runtime efficiency
  14. (measured with controlled tests and inputs on one machine) which could be
  15. recompiled to use different board sizes.
  16. I'm very pleased with the result, and I now use this as a test program when
  17. developing on new systems.
  18. Usefulness
  19. ----------
  20. This program makes for an advanced "hello world" program for aspiring hackers
  21. that want a good sample to study and change.
  22. The C code complies with GNU and C standards, and it can be compiled and run on
  23. any compliant system. It makes use of several standard library features and
  24. showcases their uses. Since the code is documented using a standard format,
  25. readers can understand a function's purpose before reading it, thus better
  26. understanding the code as a whole.
  27. I used GNU Make to automate compilation not because compiling is hard (I could
  28. easily have written the instructions in this README file) but as a "hello
  29. world" for Makefiles, since hackers will no doubt need build automation tools
  30. for their more significant software.
  31. Since the source is controlled using Git, I also provided a way for new hackers
  32. to practice using Git and learn the advantages to source control. It also
  33. allows them to easily submit their changes and improvements to me to benefit
  34. future hackers.
  35. Lastly, I included a license file which describes the core ideals of free
  36. (libre) software, which I find to be very important for both new and
  37. experienced computer users everywhere.
  38. To Build
  39. --------
  40. You will need a standards-compliant C compiler, the standard C library with
  41. header files, and GNU Make. On Debian GNU/Linux and derivatives, you can
  42. install these with
  43. # apt-get install build-essential
  44. After that, build with
  45. $ make
  46. To Install
  47. ----------
  48. If you want to install this program, just run
  49. # make install
  50. Usage
  51. -----
  52. The board is labeled with coordinates of letters and numbers. When placing a
  53. move, write the letter and then the number. For example, to put your mark in
  54. the very first cell, type `a0` as your position.
  55. Custom Boards
  56. -------------
  57. To change the size of the game board, you must define `BOARD_SIZE` at compile
  58. time. When compiling, add `-DBOARD_SIZE=X` to the `CFLAGS` where `X` is the
  59. desired size. For example, to set the board size to 6, run
  60. $ make CFLAGS=-DBOARD_SIZE=6
  61. Hacking
  62. -------
  63. ttt uses the GNU coding style for C with a strict 79-column limit in the source
  64. code. All functions and fields outside of `main()` should be documented using
  65. Doxygen comment formatting, and all variable symbolic constants should be
  66. optionally definable using the `CFLAGS` field in the Makefile.
  67. Avoid depending on external libraries with your changes. You will need to
  68. discuss with me (David McMackins II) if you want new dependencies to be added
  69. to the main program.
  70. License
  71. -------
  72. ttt is free software. You are free to use, copy, modify, and redistribute it
  73. under the terms of the GNU Affero General Public License, version 3 only.