* read-xpilot-robots
@ 2002-09-29 1:25 Thien-Thi Nguyen
0 siblings, 0 replies; only message in thread
From: Thien-Thi Nguyen @ 2002-09-29 1:25 UTC (permalink / raw)
Cc: guile-user
ok, next thing to fiddle w/ (still in the guile-xlib vein) would be some
kind of tank-crawling-over-landscape 3d wire-frame (vector graphics, woo
hoo!). rather than design vehicles, i thought perhaps we could borrow
xpilot robots and play w/ some depth-addition heuristics. below is an
executable module (aka script) to read /usr/share/games/xpilot/robots
into memory, which is a start.
i notice systas has fps. anyone want to tweak that for guile?
thi
____________________________________
#!/bin/sh
# aside from this initial boilerplate, this is actually -*- scheme -*- code
main='(module-ref (resolve-module '\''(read-xpilot-robots)) '\'main')'
exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
!#
;;; read-xpilot-robots --- Read xpilot "robots" file
;; Copyright (C) 2002 Thien-Thi Nguyen
;;
;; 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.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;;; Commentary:
;; Usage: read-xpilot-robots FILE
;;
;; Read xpilot robots file FILE into a list, each element of which
;; having the form:
;;
;; (NAME TYPE SHIP PARA)
;;
;; where NAME and TYPE are strings, SHIP is a list of sublists of
;; integers, and PARA is a list of integers. When invoked from the
;; shell, display each form to stdout, one per line.
;;; Code:
(debug-enable 'debug 'backtrace)
(define-module (read-xpilot-robots)
:use-module ((scripts PROGRAM) :select (script-MAIN))
:use-module (ice-9 rdelim)
:use-module (ice-9 regex)
:use-module (srfi srfi-13)
:export (read-xpilot-robots))
(define trigger-rx (make-regexp "^type:[ \t]*([^ \t]+)"))
(define next-rx (make-regexp "^[a-z]+:[ \t]*"))
(define (make-next port)
(lambda ()
(match:suffix (regexp-exec next-rx (read-line port)))))
(define (read-string string)
(with-input-from-string string read))
(define (read-xpilot-robots port)
(define next (make-next port))
(let loop ((line (read-line port)) (acc '()))
(if (eof-object? line)
(reverse acc)
(cond ((regexp-exec trigger-rx line)
=> (lambda (m)
(let ((type (match:substring m 1))
(para (read-string (format #f "(~A)" (next))))
(ship (read-string
(format #f "(~A)"
(string-map
(lambda (c)
(if (char=? #\, c)
#\space
c))
(next)))))
(name (next)))
(loop (read-line port)
(cons (list name type ship para) acc)))))
(else (loop (read-line port) acc))))))
(define (read-xpilot-robots/main . args)
(let ((file (car args)))
(for-each (lambda (robot)
(format #t "~S\n" robot))
(read-xpilot-robots (open-input-file file))))
#t)
(define (main . args)
(script-MAIN args
"read-xpilot-robots" read-xpilot-robots/main
'(usage . commentary)))
;;; read-xpilot-robots ends here
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-09-29 1:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-29 1:25 read-xpilot-robots Thien-Thi Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).