NAME
    SfExpress - ICFP 2002 Programming Contest Submission

AUTHOR
    W R Somsky <*wrsomsky@speakeasy.org*>

SYNOPSIS
    SfExpress [-qv] [-t *trace*,*...*] [-m *msg-socket*] [-g] *server*
    *port*

OPTIONS
    -q  Run silently.

    -v  Print informational output. Multiple invocations of this option will
        give increasing amounts of output.

    -t trace,...
        Turn on tracing/debugging information for the specified subsystems.
        The subsystems currently traceable are: "IO", "Board", "Config",
        "BotUpd", "Bots", "PkgList", "Pkgs", "Turns".

    -m msg-socket
        Change the unix-domain socket used for stderr redirection. By
        default, the socket "/tmp/SfEx_msg" is used. See the DESCRIPTION
        section for details.

    -g  Invoke the curses-based graphical display.

    *server*
        The game server hostname/IP address

    *port*
        The port number of the game server socket

DESCRIPTION
    SfExpress is my submission for the ICFP 2002 Programming Contest. The
    challenge task which this program attempts to accomplish might best be
    described as a "package delivery service" game, where one controls a
    robot which moves over a playing field of rectangular cells, picking up
    and dropping packages. The task description should be consulted for
    further details.

    The program is written entirely in *perl*. It should require only core
    modules for it's basic functionality, although if the "Curses" module is
    available, a graphical is available.

    SfExpress has a number of interesting features:

    Graphical Display
        If run from a terminal and invoked w/ the -g option, SfExpress will
        display a graphical real-time representation of the playing field as
        the game progresses. This display will be in color if the the
        displaying terminal supports this. (Note that on some machines a
        "term" setting of "xterm-color" is required to obtain access to
        color effects.) Selecting a font with nearly square aspect ration
        improves the appearance of the display -- try "lucidasans-8",
        "lucidasans-10" or "lucidasans-12".

        This graphical display is based on the perl "Curses" module, but the
        program is coded such a way that it should run successfully even if
        the "Curses" module is not present, although without graphical
        display abilities.

    Socket Redirection of Standard Error
        If a unix-domain socket "/tmp/SfEx_msg" exits, SfExpress will divert
        its standard error output to this socket. This is useful when used
        in conjunction with SfExpress's curses-based graphical output to
        keep the two output streams from interfering with each other.

        A simple script (included as monitor in the tar package) which may
        be used to create and display this messaging-socket is :

            #!/usr/bin/perl -w
            use strict qw (subs refs vars) ;

            use IO::Socket ;

            $SIG{INT} = sub { die ; } ;

            my $socket = $ARGV[0] || "/tmp/SfEx_msg" ;

            my $server = IO::Socket::UNIX->new
              (Local => $socket, Type=>SOCK_STREAM, Listen=>1)
                or die "Cannot establish socket $socket: $!\n" ;

            END { unlink $socket if $server ; }

            print "Monitoring established on $socket\n" ;

            while (my $client = $server->accept())
              {
              $client->autoflush (1) ;
              STDOUT->autoflush (1) ;
              print '+ ', '='x50, "\n" ;
              while (<$client>) { print ; }
              print '- ', '='x50, "\n" ;
              close $client ;
              }

    Gameplay Logic
        The gameplay logic of SfExpress is totally simplistic. If you can
        deliver a package here, do so. Else, if you can pick up a package
        here, do that. Otherwise if you have any packages to deliver move
        towards the delivery point of one of them. If you have none, head
        for a base to pick up more.

        There are many things one could try to do to optimize delivery paths
        and strategies, but I first concentrated on trying to get the
        underlying mechanisms working. The framework of the program would
        support more elaborate AI, however, "clever" schemes should always
        be examined quite closely to make sure they actually perform as
        desired. The graphical display feature of SfExpress is particularly
        useful for this. Even with the simplistic logic implemented thus
        far, observation of the robot's behavior during its operation shows
        interesting and unexpected effects that one would need to take into
        account for any more intelligent control logic.

    Coding Style
        *It's not a bug, it's a feature.* While not completely excreable,
        the coding style used in SfExpress is hardly what one would consider
        *high style*. In particular, the lack of useful comments makes the
        code particularly ill-suited for ongoing maintainance. However, the
        terse style does posess a certain "hack factor" suited for the quick
        code modification and changeout typical of programming contests and
        off-the-cuff prototyping.

BUGS
    Probably too many to shake a stick at. Not to mention more than a few
    rough edges one might bark one's shin upon.

