UP | HOME
../../

Wiggly Worms

1 Wiggly Worms in Software Engineering

  1. We used to give this Wiggly Worms as a code design project in "CS 101": Develop a wiggly worms game. Just using the keyboard, and console text display.
  2. In these lecture notes, a "working" version of an implementation is given. GUI is ignored. We do a simple console UI.
  3. We are assuming that we are "done" with requirements and specs. But, practice writing them.
  4. We are focused on the (i) use of Assertions, (ii) Design by Contract (DbC), and (iii) fluency in C++.
  5. Does it have bugs? Probably. What does it take to definitively say that it does or does not have bugs?
  6. Revise the working version so that it is in "proper" OOP form. As given, it is definitely improper! It is all in one file!
  7. How do we explain to a colleague/ classmate, in just one or two paragraphs, how we discovered and revised the classes?
  8. The implied design + code as-given do not do anything about the z-axis. Suggest ideas and implement.
  9. This being an interactive game, how do we test it?

2 Source Code Details

  1. The file ../Wiggly-Worms/worms-one-file.cpp.html implements a grass roots game example of wiggly worms (scissor heads, cannibals, or vegetarian kind) moving about. sloccount cpp 373 (100.00%)
  2. The ./worms12-doc.html file has a few more details on the internals.
  3. There is a little JavaScript that colorizes the worms.cpp into ../Wiggly-Worms/worms-one-file.cpp.html. Here is a link to the plain text source code file: ./worms-one-file.cpp .
  4. ./GEN contains doxygen-erated listings.

2.1 Linux

  1. If you work on Linux, you will need to install ncurses related development files. https://www.cyberciti.biz/faq/linux-install-ncurses-library-headers-on-debian-ubuntu-centos-fedora/ is a decent tutorial.
  2. thor.cs.wright.edu is a large Linux server located in CECS.
  3. Login to thor.cs.wright.edu. All grad students can obtain an account. From outside campus, you need VPN.
  4. g++ worms-one-file.cpp -o worms -lncurses will compile and link the program.
  5. % file worms The command named file identifies the content of the named file.

    worms: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
    dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not
    stripped
    
  6. % ldd worms The command named ldd lists the dynamic libraries that the named program is linked with.

    linux-vdso.so.1 =>  (0x00007ffcfe126000)
    libncurses.so.5 => /lib64/libncurses.so.5 (0x000000382c000000)
    libstdc++.so.6 => /usr/local/lib64/libstdc++.so.6 (0x00002acef3b16000)
    libm.so.6 => /lib64/libm.so.6 (0x000000381b200000)
    libgcc_s.so.1 => /usr/local/lib64/libgcc_s.so.1 (0x00002acef3e27000)
    libc.so.6 => /lib64/libc.so.6 (0x000000381ae00000)
    libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003829000000)
    libdl.so.2 => /lib64/libdl.so.2 (0x000000381b600000)
    ld.so => /lib64/ld-linux-x86-64.so.2 (0x000055d912f1c000)
    

2.2 Windows

  1. If you wish to work on Windows, use Windows-equivalents of ncurses. E.g., https://pdcurses.org/ or https://github.com/peterbrittain/asciimatics .
  2. There is also a contributed version ./worms-ktsalva-2013.cpp.html, by a past student that should be buildable on Windows. Here is a link to the plain text source code file: ./worms-ktsalva-2013.cpp .

3 Exercises

  1. Consider our Wiggly Worms program. (i) (10 points) Intuitively describe the "connectedness" of a worm's body from head to the tail. (ii) (10 points) State this as an assertion in mathematical notation using the typedefs originally given (see the link) or the class definitions you have derived from it.
  2. Consider our Wiggly Worms. We wish to describe how a worm crawls. First, in English prose. Then, state this as pre- and post-conditions for the method named void live(WORM * wp)
  3. [After Debugging Lectures] Does our Wiggly Worms code have any bugs? We certainly did not do a spec. What def of bugs shall we use? Should we just use some tools, and copy-paste their output as an answer to this question? Note that some tools (eg PMD) show some questionable coding style, not bugs.

4 References

  1. Prabhaker Mateti, Lecture Notes on Design by Contract and SOLID Principles
  2. Prabhaker Mateti, Lecture Notes on Assertions in C++

5 End


Copyright © 2016 pmateti@wright.edu www.wright.edu/~pmateti 2020-09-11