[aisleriot] guile: Make sol.scm a module
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aisleriot] guile: Make sol.scm a module
- Date: Sat, 3 Dec 2011 16:49:35 +0000 (UTC)
commit f59aff79ab6c63629cdfd179cf80e1ea6a74d8a4
Author: Christian Persch <chpe gnome org>
Date: Wed Nov 30 19:03:54 2011 +0100
guile: Make sol.scm a module
games/Makefile.am | 9 +-
games/accordion.scm | 2 +
games/agnes.scm | 6 +-
games/{sol.scm => api.scm} | 250 +++++++++++++++++++++---------------------
games/athena.scm | 2 +
games/auld_lang_syne.scm | 2 +
games/aunt_mary.scm | 6 +-
games/backbone.scm | 2 +
games/bakers_dozen.scm | 2 +
games/bakers_game.scm | 2 +
games/bear_river.scm | 2 +-
games/beleaguered_castle.scm | 2 +
games/block_ten.scm | 2 +
games/bristol.scm | 2 +
games/camelot.scm | 2 +
games/canfield.scm | 2 +
games/carpet.scm | 2 +
games/chessboard.scm | 2 +
games/clock.scm | 2 +
games/cover.scm | 2 +
games/cruel.scm | 2 +
games/diamond_mine.scm | 2 +
games/doublets.scm | 2 +
games/eagle_wing.scm | 2 +
games/easthaven.scm | 2 +
games/eight_off.scm | 2 +
games/elevator.scm | 2 +
games/eliminator.scm | 2 +
games/escalator.scm | 2 +
games/first_law.scm | 2 +
games/fortress.scm | 2 +
games/fortunes.scm | 2 +
games/forty_thieves.scm | 2 +
games/fourteen.scm | 2 +
games/freecell.scm | 2 +
games/gaps.scm | 2 +
games/gay_gordons.scm | 2 +
games/giant.scm | 2 +
games/glenwood.scm | 2 +
games/gold_mine.scm | 2 +
games/golf.scm | 2 +
games/gypsy.scm | 2 +
games/helsinki.scm | 2 +
games/hopscotch.scm | 2 +
games/isabel.scm | 2 +
games/jamestown.scm | 2 +
games/jumbo.scm | 2 +
games/kansas.scm | 2 +
games/king_albert.scm | 2 +
games/kings_audience.scm | 2 +
games/klondike.scm | 2 +
games/labyrinth.scm | 2 +
games/lady_jane.scm | 2 +
games/maze.scm | 2 +
games/monte_carlo.scm | 2 +
games/napoleons_tomb.scm | 2 +
games/neighbor.scm | 2 +
games/odessa.scm | 2 +
games/osmosis.scm | 2 +
games/peek.scm | 2 +
games/pileon.scm | 2 +
games/plait.scm | 2 +
games/poker.scm | 2 +
games/quatorze.scm | 2 +
games/royal_east.scm | 2 +
games/saratoga.scm | 2 +
games/scorpion.scm | 2 +
games/scuffle.scm | 2 +
games/seahaven.scm | 2 +
games/sir_tommy.scm | 2 +
games/spider.scm | 2 +
games/spider_three_decks.scm | 2 +
games/spiderette.scm | 2 +
games/straight_up.scm | 2 +
games/streets_and_alleys.scm | 2 +
games/template.scm | 2 +
games/ten_across.scm | 2 +
games/terrace.scm | 2 +
games/thieves.scm | 2 +
games/thirteen.scm | 2 +
games/thumb_and_pouch.scm | 2 +
games/treize.scm | 2 +
games/triple_peaks.scm | 2 +
games/union_square.scm | 2 +
games/valentine.scm | 2 +
games/westhaven.scm | 2 +
games/whitehead.scm | 2 +
games/will_o_the_wisp.scm | 2 +
games/yield.scm | 2 +
games/yukon.scm | 2 +
games/zebra.scm | 2 +
src/ar-game-chooser.c | 2 +-
src/game.c | 26 +++-
src/window.c | 2 +-
94 files changed, 332 insertions(+), 143 deletions(-)
---
diff --git a/games/Makefile.am b/games/Makefile.am
index e69404b..85111bb 100644
--- a/games/Makefile.am
+++ b/games/Makefile.am
@@ -1,10 +1,14 @@
NULL =
+guiledir = $(pkgdatadir)/aisleriot
+
+guile_DATA = \
+ api.scm \
+ $(NULL)
+
rulesdir = $(pkgdatadir)/games
rules_DATA = \
- sol.scm \
- \
accordion.scm \
agnes.scm \
athena.scm \
@@ -101,6 +105,7 @@ rules_DATA = \
EXTRA_DIST = \
$(rules_DATA) \
+ $(guile_DATA) \
template.scm \
Rules.HOWTO \
$(NULL)
diff --git a/games/accordion.scm b/games/accordion.scm
index b0636f0..d9626a6 100644
--- a/games/accordion.scm
+++ b/games/accordion.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define row1 '(0 1 2 3 4 5 6 7 8 ))
(define row2 '(9 10 11 12 13 14 15 16 17 ))
(define row3 '(18 19 20 21 22 23 24 25 26 ))
diff --git a/games/agnes.scm b/games/agnes.scm
index d92893d..461cb34 100644
--- a/games/agnes.scm
+++ b/games/agnes.scm
@@ -13,9 +13,9 @@
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
-;
-;
-; Andersca claims that seed 1791329065 wins
+
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define BASE-VAL 0)
(define stock 0)
diff --git a/games/sol.scm b/games/api.scm
similarity index 83%
rename from games/sol.scm
rename to games/api.scm
index 9d7cafb..2963037 100644
--- a/games/sol.scm
+++ b/games/api.scm
@@ -1,4 +1,4 @@
-; AisleRiot - sol.scm
+; AisleRiot API
; Copyright (C) 1998, 2003 Jonathan Blandford <jrb mit edu>
;
; This program is free software: you can redistribute it and/or modify
@@ -14,40 +14,42 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
-(use-modules (ice-9 format) (aisleriot interface))
+(define-module (aisleriot api))
+
+(use-modules (aisleriot interface) (ice-9 format))
;; Feature masks:
-(define droppable-feature 1)
-(define scores-disabled 2)
-(define dealable-feature 4)
+(define-public droppable-feature 1)
+(define-public scores-disabled 2)
+(define-public dealable-feature 4)
-(define (set-features . feature-list)
+(define-public (set-features . feature-list)
(set-feature-word! (+ (get-feature-word)
(apply + feature-list))))
-(define jack 11)
-(define queen 12)
-(define king 13)
-(define ace 1)
-(define joker 0)
+(define-public jack 11)
+(define-public queen 12)
+(define-public king 13)
+(define-public ace 1)
+(define-public joker 0)
-(define club 0)
-(define diamond 1)
-(define heart 2)
-(define spade 3)
+(define-public club 0)
+(define-public diamond 1)
+(define-public heart 2)
+(define-public spade 3)
-(define black 0)
-(define red 1)
+(define-public black 0)
+(define-public red 1)
-(define down 0)
-(define right 1)
+(define-public down 0)
+(define-public right 1)
;; Global variables:
-(define DECK '())
+(define-public DECK '())
; The list of variables to save when saving the game state
-(define variable-list '())
+(define-public variable-list '())
;; NEW-GAME PROCEDURES
; these may be used in game files during the new-game procedure.
@@ -58,7 +60,7 @@
; done before calling this and we would loose our variable list. At worst
; case we end up saving and restoring variables that are not currently in use
; (but will be defined) so it will work out OK.
-(define (initialize-playing-area)
+(define-public (initialize-playing-area)
(reset-surface)
(set! FLIP-COUNTER 0)
(set! SLOTS 0)
@@ -80,18 +82,18 @@
; Use this instead of define for variables which determine the state of
; the game. i.e. anything that isn't a constant. This is so undo/redo
; is transparent. It should behave otherwise identically to define.
-(defmacro def-save-var (nm value)
+(defmacro-public def-save-var (nm value)
`(begin (define ,nm ,value)
(set! variable-list (cons ',nm variable-list))))
; create a 52 card deck (puts list of cards into DECK)
-(define (make-standard-deck)
+(define-public (make-standard-deck)
(if (= ace 14)
(set! DECK (make-standard-deck-list-ace-high 2 club))
(set! DECK (make-standard-deck-list-ace-low ace club))))
; create a 54 card deck with 2 jokers.
-(define (make-joker-deck)
+(define-public (make-joker-deck)
(if (= ace 14)
(set! DECK (cons (make-card joker club) (cons (make-card joker diamond)
(make-standard-deck-list-ace-high 2 club))))
@@ -99,13 +101,13 @@
(make-standard-deck-list-ace-low ace club))))))
; create a double deck of 104 cards (puts list of cards into DECK)
-(define (make-standard-double-deck)
+(define-public (make-standard-double-deck)
(if (= ace 14)
(set! DECK (append (make-standard-deck-list-ace-high 2 club) (make-standard-deck-list-ace-high 2 club)))
(set! DECK (append (make-standard-deck-list-ace-low ace club) (make-standard-deck-list-ace-low ace club)))))
; makes a deck from init-value to kings
-(define (make-deck-list-ace-low init-value value suit)
+(define-public (make-deck-list-ace-low init-value value suit)
(if (eq? king value)
(if (eq? spade suit)
(list (make-card king spade))
@@ -116,7 +118,7 @@
(make-deck-list-ace-low init-value (+ 1 value) suit))))
; makes a deck from init-value to aces
-(define (make-deck-list-ace-high init-value value suit)
+(define-public (make-deck-list-ace-high init-value value suit)
(if (eq? 14 value)
(if (eq? spade suit)
(list (make-card ace spade))
@@ -129,7 +131,7 @@
; shuffle the card list in DECK
-(define (shuffle-deck)
+(define-public (shuffle-deck)
(let* ((vec (list->vector DECK))
(len (vector-length vec)))
(set! DECK (shuffle-deck-helper vec '() 0 len))))
@@ -145,21 +147,21 @@
; A space may be added using the add-blank-slot procedure. These false
; slots are not assigned identifiers.
-(define (add-blank-slot)
+(define-public (add-blank-slot)
(get-and-increment-position))
-(define (add-carriage-return-slot)
+(define-public (add-carriage-return-slot)
(linefeed-position))
; The real slots come in three varieties:
; A slot in which only the topmost card is visible:
-(define (add-normal-slot cards . type)
+(define-public (add-normal-slot cards . type)
(add-slot (set-tag! (new-slot cards
(list 'normal (get-and-increment-position)) type))))
; A slot in which all the cards are visible, arranged as an overlapped pile:
; (either proceeding to the right or down).
-(define (add-extended-slot cards direction . type)
+(define-public (add-extended-slot cards direction . type)
(if (= right direction)
(add-slot (set-tag! (new-slot cards
(list 'expanded-right
@@ -169,7 +171,7 @@
(get-and-increment-position)) type)))))
; A slot in only the n topmost cards are visible:
-(define (add-partially-extended-slot cards direction n . type)
+(define-public (add-partially-extended-slot cards direction n . type)
(if (= right direction)
(add-slot (set-tag! (new-slot cards
(list 'partially-expanded-right
@@ -180,13 +182,13 @@
; Cards may be dealt off one slot (usually the one containing the deck)
; and onto a list of other slots using these procedures:
-(define (deal-cards target-slot-id slot-list)
+(define-public (deal-cards target-slot-id slot-list)
(if (not (null? slot-list))
(begin
(add-card! (car slot-list) (remove-card target-slot-id))
(deal-cards target-slot-id (cdr slot-list)))))
-(define (deal-cards-face-up target-slot-id slot-list)
+(define-public (deal-cards-face-up target-slot-id slot-list)
(if (not (null? slot-list))
(begin
(add-card! (car slot-list) (make-visible (remove-card target-slot-id)))
@@ -198,30 +200,30 @@
;; Procedures that change slot contents:
; turn the top card of a slot over (face up to face down and vice versa)
-(define (flip-top-card slot-id)
+(define-public (flip-top-card slot-id)
(add-card! slot-id (flip-card (remove-card slot-id))))
; turn the top card of a slot face side up
-(define (make-visible-top-card slot-id)
+(define-public (make-visible-top-card slot-id)
(add-card! slot-id (make-visible (remove-card slot-id))))
; add a card onto the top of a slot
-(define (add-card! slot-id card)
+(define-public (add-card! slot-id card)
(set-cards! slot-id (cons card (get-cards slot-id))))
; add a list of cards onto the top of a slot
-(define (add-cards! slot-id cards)
+(define-public (add-cards! slot-id cards)
(set-cards! slot-id (append cards (get-cards slot-id))))
; remove (and return) the top card from a slot
-(define (remove-card slot-id)
+(define-public (remove-card slot-id)
(let ((cards (get-cards slot-id)))
(set-cards! slot-id (cdr cards))
(car cards)))
;; Utilities
-(define (flippable? stock-slot waste-slot flip-limit)
+(define-public (flippable? stock-slot waste-slot flip-limit)
(or (not (empty-slot? stock-slot))
(and (not (empty-slot? waste-slot))
(or (< flip-limit 0)
@@ -232,7 +234,7 @@
; onto the stock unless the flip limit has been reached.
; an optional forth argument indicates the number of cards to deal.
; If the flip limit is negative, it is treated as infinite.
-(define (flip-stock stock-slot waste-slot flip-limit . rest)
+(define-public (flip-stock stock-slot waste-slot flip-limit . rest)
(if (empty-slot? stock-slot)
(and (not (empty-slot? waste-slot))
(or (< flip-limit 0)
@@ -247,7 +249,7 @@
#t)))
; turn the cards in the waste slot over and add them to the stock-slot.
-(define (flip-deck stock-slot waste-slot)
+(define-public (flip-deck stock-slot waste-slot)
(and (not (empty-slot? waste-slot))
(add-card! stock-slot (flip-card (remove-card waste-slot)))
(or (flip-deck stock-slot waste-slot)
@@ -258,137 +260,137 @@
; NB: In order to use these procedures you must remove the cards
; from their slots and then replace them after applying the procedure
; (as in the make-top-card-visible procedure above)
-(define (flip-card card)
+(define-public (flip-card card)
(list (car card) (cadr card) (not (caddr card))))
-(define (make-visible card)
+(define-public (make-visible card)
(list (car card) (cadr card) #t))
;; Procedures that provide information only:
; card procedures
-(define (is-visible? card)
+(define-public (is-visible? card)
(caddr card))
-(define (get-suit card)
+(define-public (get-suit card)
(cadr card))
-(define (get-color card)
+(define-public (get-color card)
(cond ((eq? (get-suit card) club) black)
((eq? (get-suit card) spade) black)
((eq? (get-suit card) heart) red)
((eq? (get-suit card) diamond) red)
(#t (_"Unknown color"))))
-(define (get-value card)
+(define-public (get-value card)
(car card))
;; WARNING: This generates a synthetic card that isn't part of the game.
;; See gaps.scm for an example of its intended use.
-(define (add-to-value card n)
+(define-public (add-to-value card n)
(cons (+ (car card) n) (cdr card)))
; slot procedures
-(define (get-cards slot-id)
+(define-public (get-cards slot-id)
(cadr (get-slot slot-id)))
-(define (empty-slot? slot-id)
+(define-public (empty-slot? slot-id)
(null? (get-cards slot-id)))
-(define (any-slot-empty? slots)
+(define-public (any-slot-empty? slots)
(if (eq? slots '())
#f
(or (empty-slot? (car slots))
(any-slot-empty? (cdr slots)))))
-(define (find-empty-slot slots)
+(define-public (find-empty-slot slots)
(cond ((null? slots) #f)
((empty-slot? (car slots)) (car slots))
(#t (find-empty-slot (cdr slots)))))
-(define (find-card-helper card cards n)
+(define-public (find-card-helper card cards n)
(if (null? cards)
#f
(if (equal? (car cards) card)
n
(find-card-helper card (cdr cards) (+ n 1)))))
-(define (find-card slot card)
+(define-public (find-card slot card)
(find-card-helper card (get-cards slot) 1))
; Get the nth card from a slot. Returns #f if n is out of range.
-(define (get-nth-card slot-id n)
+(define-public (get-nth-card slot-id n)
(let ((cards (get-cards slot-id)))
(cond ((< n 1) #f)
((> n (length cards)) #f)
(#t (list-ref cards (- n 1))))))
-(define (get-top-card slot-id)
+(define-public (get-top-card slot-id)
(let ((cards (get-cards slot-id)))
(if (null? cards)
'()
(car cards))))
;; Utilities - need more of these:
-(define (suit-eq? card1 card2)
+(define-public (suit-eq? card1 card2)
(eq? (get-suit card1) (get-suit card2)))
-(define (color-eq? card1 card2)
+(define-public (color-eq? card1 card2)
(eq? (get-color card1) (get-color card2)))
-(define (value-eq? card1 card2)
+(define-public (value-eq? card1 card2)
(eq? (get-value card1) (get-value card2)))
-(define (cards-eq? card1 card2)
+(define-public (cards-eq? card1 card2)
(and (eq? (get-value card1) (get-value card2))
(eq? (get-suit card1) (get-suit card2))))
-(define (is-red? card)
+(define-public (is-red? card)
(eq? red (get-color card)))
-(define (is-black? card)
+(define-public (is-black? card)
(eq? black (get-color card)))
-(define (is-joker? card)
+(define-public (is-joker? card)
(= (get-value card) joker))
-(define (set-ace-low) (set! ace 1))
+(define-public (set-ace-low) (set! ace 1))
-(define (set-ace-high) (set! ace 14))
+(define-public (set-ace-high) (set! ace 14))
; use to compare two cards when aces are treated as high:
-(define (ace-high-order value)
+(define-public (ace-high-order value)
(remainder (+ 11 value) 13))
-(define (check-same-suit-list card-list)
+(define-public (check-same-suit-list card-list)
(or (< (length card-list) 2)
(and (= (get-suit (car card-list)) (get-suit (cadr card-list)))
(check-same-suit-list (cdr card-list)))))
-(define (check-same-color-list card-list)
+(define-public (check-same-color-list card-list)
(or (< (length card-list) 2)
(and (eq? (is-red? (car card-list)) (is-red? (cadr card-list)))
(check-same-color-list (cdr card-list)))))
-(define (check-alternating-color-list card-list)
+(define-public (check-alternating-color-list card-list)
(or (< (length card-list) 2)
(and (eq? (is-black? (car card-list)) (is-red? (cadr card-list)))
(check-alternating-color-list (cdr card-list)))))
-(define (check-straight-descending-list card-list)
+(define-public (check-straight-descending-list card-list)
(or (< (length card-list) 2)
(and (= (get-value (car card-list)) (- (get-value (cadr card-list)) 1))
(check-straight-descending-list (cdr card-list)))))
; debugging aid:
-(define (display-list . objs)
+(define-public (display-list . objs)
(map display objs) (newline))
; hint procedures
-(define (get-joker-name card)
+(define-public (get-joker-name card)
(if (is-black? card) (_"the black joker") (_"the red joker")))
-(define (get-name card)
+(define-public (get-name card)
; Do not use this function directly. To create a hint for moving a card or
; stack of cards, use (hint-move).
(let ((value (get-value card)) (suit (get-suit card)))
@@ -456,7 +458,7 @@
(#t (_"the unknown card"))))
(#t (_"the unknown card"))))))
-(define (hint-get-dest-format to-slot)
+(define-public (hint-get-dest-format to-slot)
(if (empty-slot? to-slot)
(cond ((member to-slot FOUNDATION-SLOTS) (if (= (length FOUNDATION-SLOTS) 1) (_"Move ~a onto the foundation.") (_"Move ~a onto an empty foundation slot.")))
((member to-slot TABLEAU-SLOTS) (if (= (length TABLEAU-SLOTS) 1) (_"Move ~a onto the tableau.") (_"Move ~a onto an empty tableau slot.")))
@@ -532,38 +534,38 @@
(#t (_"Move ~a onto the unknown card."))))
(#t (_"Move ~a onto the unknown card."))))))
-(define (hint-move from-slot from-slot-count to-slot)
+(define-public (hint-move from-slot from-slot-count to-slot)
(list 0 (format (hint-get-dest-format to-slot) (get-name (get-nth-card from-slot from-slot-count)))))
-(define (hint-click slot-id hint-string)
+(define-public (hint-click slot-id hint-string)
(list 0 hint-string))
-(define (move-n-cards! start-slot end-slot cards)
+(define-public (move-n-cards! start-slot end-slot cards)
(add-cards! end-slot cards))
-(define (remove-n-cards slot-id n)
+(define-public (remove-n-cards slot-id n)
(set-cards! slot-id (nthcdr n (get-cards slot-id))))
-(define (deal-cards-from-deck deck slot-list)
+(define-public (deal-cards-from-deck deck slot-list)
(if (not (null? slot-list))
(begin
(add-card! (car slot-list) (car deck))
(deal-cards-from-deck (cdr deck) (cdr slot-list)))))
-(define (deal-cards-face-up-from-deck deck slot-list)
+(define-public (deal-cards-face-up-from-deck deck slot-list)
(if (not (null? slot-list))
(begin
(add-card! (car slot-list) (make-visible (car deck)))
(deal-cards-face-up-from-deck (cdr deck) (cdr slot-list)))))
-(define (set-cards! slot-id new_cards)
+(define-public (set-cards! slot-id new_cards)
(set-cards-c! slot-id new_cards))
-(define (make-card value suit)
+(define-public (make-card value suit)
(list value suit #f))
-(define (make-standard-deck-list-ace-high value suit)
+(define-public (make-standard-deck-list-ace-high value suit)
(if (eq? ace value)
(if (eq? spade suit)
(list (make-card ace spade))
@@ -572,7 +574,7 @@
(cons (make-card value suit)
(make-standard-deck-list-ace-high (+ 1 value) suit))))
-(define (make-standard-deck-list-ace-low value suit)
+(define-public (make-standard-deck-list-ace-low value suit)
(if (eq? king value)
(if (eq? spade suit)
(list (make-card king spade))
@@ -581,7 +583,7 @@
(cons (make-card value suit)
(make-standard-deck-list-ace-low (+ 1 value) suit))))
-(define (shuffle-deck-helper deck result ref1 len)
+(define-public (shuffle-deck-helper deck result ref1 len)
(if (zero? len)
result
(let* ((ref2 (+ ref1 (aisleriot-random len)))
@@ -589,10 +591,10 @@
(vector-set! deck ref2 (vector-ref deck ref1))
(shuffle-deck-helper deck (cons val-at-ref2 result) (+ ref1 1) (- len 1)))))
-(define (new-slot deck placement type)
+(define-public (new-slot deck placement type)
(list #f deck placement (if (null? type) 'unknown (car type))))
-(define (set-tag! slot)
+(define-public (set-tag! slot)
(case (cadddr slot)
((tableau) (set! TABLEAU-SLOTS (cons SLOTS TABLEAU-SLOTS)))
((edge) (set! EDGE-SLOTS (cons SLOTS EDGE-SLOTS)))
@@ -605,24 +607,24 @@
(set! SLOTS (+ 1 SLOTS))
(cons (- SLOTS 1) (cdr slot)))
-(define (get-and-increment-position)
+(define-public (get-and-increment-position)
(let ((retval (list HORIZPOS VERTPOS)))
(set! HORIZPOS (+ HORIZPOS 1))
retval))
-(define (linefeed-position)
+(define-public (linefeed-position)
(set! HORIZPOS 0)
(set! VERTPOS (+ VERTPOS 1)))
-(define (register-undo-function function data)
+(define-public (register-undo-function function data)
(set! MOVE (cons '(function data) (cdr MOVE))))
; common lisp procedure not provided in guile 1.3
-(define (nthcdr n lst)
+(define-public (nthcdr n lst)
(if (zero? n) lst (nthcdr (+ -1 n) (cdr lst))))
; guile library function I'm not sure I can rely on
-(define (list-head lst k)
+(define-public (list-head lst k)
(if (= k 0)
'()
(cons (car lst) (list-head (cdr lst) (- k 1)))))
@@ -630,29 +632,29 @@
;; INTERNAL procedures
; global variables
-(define FLIP-COUNTER 0)
-(define SLOTS 0)
-(define HORIZPOS 0)
-(define VERTPOS 0)
-(define MOVE '())
-(define HISTORY '())
-(define FUTURE '())
-(define IN-GAME #f)
-(define FOUNDATION-SLOTS '())
-(define TABLEAU-SLOTS '())
-(define EDGE-SLOTS '())
-(define CORNER-SLOTS '())
-(define TOP-SLOTS '())
-(define BOTTOM-SLOTS '())
-(define LEFT-SLOTS '())
-(define RIGHT-SLOTS '())
+(define-public FLIP-COUNTER 0)
+(define-public SLOTS 0)
+(define-public HORIZPOS 0)
+(define-public VERTPOS 0)
+(define-public MOVE '())
+(define-public HISTORY '())
+(define-public FUTURE '())
+(define-public IN-GAME #f)
+(define-public FOUNDATION-SLOTS '())
+(define-public TABLEAU-SLOTS '())
+(define-public EDGE-SLOTS '())
+(define-public CORNER-SLOTS '())
+(define-public TOP-SLOTS '())
+(define-public BOTTOM-SLOTS '())
+(define-public LEFT-SLOTS '())
+(define-public RIGHT-SLOTS '())
; called from C:
-(define (start-game)
+(define-public (start-game)
(set! IN-GAME #t))
; called from C:
-(define (end-move)
+(define-public (end-move)
(if (not (= 0 (length MOVE)))
(begin
(set! HISTORY (cons MOVE HISTORY))
@@ -665,21 +667,21 @@
(redo-set-sensitive #f)
(redo-set-sensitive #t)))))
-(define (return-cards card-positions slot-id)
+(define-public (return-cards card-positions slot-id)
(and (not (= 0 (length card-positions)))
(set-cards! slot-id (car card-positions))
(return-cards (cdr card-positions) (+ 1 slot-id))))
-(define (give-status-message)
+(define-public (give-status-message)
#t)
-(define (eval-move move)
+(define-public (eval-move move)
(return-cards (caddr move) 0)
((car move) (cadr move))
(give-status-message))
; called from C:
-(define (undo)
+(define-public (undo)
(and (not (null? HISTORY))
(record-move -1 '())
(eval-move (car HISTORY))
@@ -691,7 +693,7 @@
(undo-set-sensitive #f))))
; called from C:
-(define (redo)
+(define-public (redo)
(and (not (null? FUTURE))
(record-move -1 '())
(eval-move (car FUTURE))
@@ -702,13 +704,13 @@
(if (null? FUTURE)
(redo-set-sensitive #f))))
-(define (undo-func data)
+(define-public (undo-func data)
(set-score! (car data))
(set! FLIP-COUNTER (cadr data))
(restore-variables variable-list (caddr data)))
;(register-undo-function undo-func '(score FLIP-COUNTER))
-(define (snapshot-board slot-id moving-slot old-cards)
+(define-public (snapshot-board slot-id moving-slot old-cards)
(cond ((>= slot-id SLOTS)
'())
((= slot-id moving-slot)
@@ -719,20 +721,20 @@
(snapshot-board (+ 1 slot-id) moving-slot old-cards)))))
; called from C:
-(define (record-move slot-id old-cards)
+(define-public (record-move slot-id old-cards)
(set! MOVE (list undo-func
(list (get-score) FLIP-COUNTER
(save-variables variable-list))
(snapshot-board 0 slot-id old-cards))))
; called from C:
-(define (discard-move)
+(define-public (discard-move)
(set! MOVE '()))
;; Routines for saving/restoring generic variables
; Get a list of values for the variables we wish to save.
-(define save-variables
+(define-public save-variables
(lambda (names)
(if (equal? '() names)
'()
@@ -740,7 +742,7 @@
(save-variables (cdr names))))))
; Restore all the state variables for a game
-(define restore-variables
+(define-public restore-variables
(lambda (names values)
(or (equal? '() names)
(begin
diff --git a/games/athena.scm b/games/athena.scm
index 2c2b7e7..0d306e1 100644
--- a/games/athena.scm
+++ b/games/athena.scm
@@ -16,6 +16,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
;; Athena differs from Klondike only in the intial layout
;; including 1 or 3 card deal, and any other options like ...
;; Optional "King Only" enabled by default [TODO]
diff --git a/games/auld_lang_syne.scm b/games/auld_lang_syne.scm
index 65b6beb..997aff7 100644
--- a/games/auld_lang_syne.scm
+++ b/games/auld_lang_syne.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/aunt_mary.scm b/games/aunt_mary.scm
index 51b0e84..f0a0425 100644
--- a/games/aunt_mary.scm
+++ b/games/aunt_mary.scm
@@ -14,10 +14,8 @@
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-;;
-;;
-;; Goodsol gives odds as < 1%. It is possible to win in theory.
-;; In practice I've only ever won when the deck wasn't shuffled
+
+(use-modules (aisleriot interface) (aisleriot api))
(load "klondike.scm")
diff --git a/games/backbone.scm b/games/backbone.scm
index b0dcc0b..bfd4c70 100644
--- a/games/backbone.scm
+++ b/games/backbone.scm
@@ -15,6 +15,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define tableau '(0 1 6 7 12 13 16 17))
(define foundation '(2 3 4 5 8 9 10 11))
(define stock 14)
diff --git a/games/bakers_dozen.scm b/games/bakers_dozen.scm
index 1fe1c1b..4bc6bde 100644
--- a/games/bakers_dozen.scm
+++ b/games/bakers_dozen.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/bakers_game.scm b/games/bakers_game.scm
index a9c7d64..c160cc2 100644
--- a/games/bakers_game.scm
+++ b/games/bakers_game.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(load "freecell.scm")
(define (field-join? lower upper)
diff --git a/games/bear_river.scm b/games/bear_river.scm
index 4dacc8b..0b45834 100644
--- a/games/bear_river.scm
+++ b/games/bear_river.scm
@@ -14,7 +14,7 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
-
+(use-modules (aisleriot interface) (aisleriot api))
(define tableau '(4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21))
(define foundation '(0 1 2 3))
diff --git a/games/beleaguered_castle.scm b/games/beleaguered_castle.scm
index 428ae9e..eb00ae5 100644
--- a/games/beleaguered_castle.scm
+++ b/games/beleaguered_castle.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/block_ten.scm b/games/block_ten.scm
index 6300b51..f00a608 100644
--- a/games/block_ten.scm
+++ b/games/block_ten.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(make-standard-deck)
diff --git a/games/bristol.scm b/games/bristol.scm
index 354c8e0..8520c14 100644
--- a/games/bristol.scm
+++ b/games/bristol.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/camelot.scm b/games/camelot.scm
index ffab392..0b8c3d3 100644
--- a/games/camelot.scm
+++ b/games/camelot.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(def-save-var add-stage #t)
(def-save-var fill-count 0)
diff --git a/games/canfield.scm b/games/canfield.scm
index fc99a3a..2a80ec7 100644
--- a/games/canfield.scm
+++ b/games/canfield.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define BASE-VAL 0)
(define (new-game)
diff --git a/games/carpet.scm b/games/carpet.scm
index 9d992f3..35ac96e 100644
--- a/games/carpet.scm
+++ b/games/carpet.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (tableau? slot-id)
(< 5 slot-id))
(define foundation '(2 3 4 5))
diff --git a/games/chessboard.scm b/games/chessboard.scm
index 76b0152..e3c874f 100644
--- a/games/chessboard.scm
+++ b/games/chessboard.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(def-save-var BASE-VAL 0)
(def-save-var base-set? #f)
diff --git a/games/clock.scm b/games/clock.scm
index 69b9ee5..f5a1a06 100644
--- a/games/clock.scm
+++ b/games/clock.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(make-standard-deck)
diff --git a/games/cover.scm b/games/cover.scm
index f60b5f9..7e1b235 100644
--- a/games/cover.scm
+++ b/games/cover.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/cruel.scm b/games/cruel.scm
index 6df8fee..27f7541 100644
--- a/games/cruel.scm
+++ b/games/cruel.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define stock 0)
(define foundations '(1 2 3 4))
(define from-list '(5 6 7 8 9 10 11 12 13 14 15 16))
diff --git a/games/diamond_mine.scm b/games/diamond_mine.scm
index c536993..29f2442 100644
--- a/games/diamond_mine.scm
+++ b/games/diamond_mine.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/doublets.scm b/games/doublets.scm
index 8b35888..25f6723 100644
--- a/games/doublets.scm
+++ b/games/doublets.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
diff --git a/games/eagle_wing.scm b/games/eagle_wing.scm
index c59ba89..a7d440e 100644
--- a/games/eagle_wing.scm
+++ b/games/eagle_wing.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define BASE-VAL 0)
(define (new-game)
diff --git a/games/easthaven.scm b/games/easthaven.scm
index b9655f4..7f55ab4 100644
--- a/games/easthaven.scm
+++ b/games/easthaven.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/eight_off.scm b/games/eight_off.scm
index 9073c83..003fc96 100644
--- a/games/eight_off.scm
+++ b/games/eight_off.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(def-save-var free-reserves 0)
(define (new-game)
diff --git a/games/elevator.scm b/games/elevator.scm
index 28f3114..dc787c8 100644
--- a/games/elevator.scm
+++ b/games/elevator.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/eliminator.scm b/games/eliminator.scm
index afdb912..c3687ad 100644
--- a/games/eliminator.scm
+++ b/games/eliminator.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define foundation '(0 1 2 3 4 5))
(define found-amt 6)
(define tableau '(6 7 8 9))
diff --git a/games/escalator.scm b/games/escalator.scm
index 0a0cefa..0a5d528 100644
--- a/games/escalator.scm
+++ b/games/escalator.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define covering-vector '#(
(2 . (3 . 4))
(3 . (5 . 6))
diff --git a/games/first_law.scm b/games/first_law.scm
index 38192c6..3145ea8 100644
--- a/games/first_law.scm
+++ b/games/first_law.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/fortress.scm b/games/fortress.scm
index da47642..ffc2d45 100644
--- a/games/fortress.scm
+++ b/games/fortress.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/fortunes.scm b/games/fortunes.scm
index fd62420..c97494e 100644
--- a/games/fortunes.scm
+++ b/games/fortunes.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define (new-game)
(initialize-playing-area)
diff --git a/games/forty_thieves.scm b/games/forty_thieves.scm
index f6341ca..cc7e957 100644
--- a/games/forty_thieves.scm
+++ b/games/forty_thieves.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/fourteen.scm b/games/fourteen.scm
index bb2090d..224e872 100644
--- a/games/fourteen.scm
+++ b/games/fourteen.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/freecell.scm b/games/freecell.scm
index 7557a5d..64970c3 100644
--- a/games/freecell.scm
+++ b/games/freecell.scm
@@ -17,6 +17,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
;;; Commentary:
;; FREECELL
diff --git a/games/gaps.scm b/games/gaps.scm
index 99b7421..d5c7cf7 100644
--- a/games/gaps.scm
+++ b/games/gaps.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define row1 '(0 1 2 3 4 5 6 7 8 9 10 11 12))
(define row2 '(13 14 15 16 17 18 19 20 21 22 23 24 25))
(define row3 '(26 27 28 29 30 31 32 33 34 35 36 37 38))
diff --git a/games/gay_gordons.scm b/games/gay_gordons.scm
index 1588fde..5150160 100644
--- a/games/gay_gordons.scm
+++ b/games/gay_gordons.scm
@@ -17,6 +17,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
; Check if two cards match within the rules of the game.
;
; Note that we can use simple sums for normal matches and
diff --git a/games/giant.scm b/games/giant.scm
index b60ce75..7cf5527 100644
--- a/games/giant.scm
+++ b/games/giant.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
;set up the deck
(set-ace-low)
diff --git a/games/glenwood.scm b/games/glenwood.scm
index e121733..167437f 100644
--- a/games/glenwood.scm
+++ b/games/glenwood.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(def-save-var BASE-VAL 0)
(define (new-game)
diff --git a/games/gold_mine.scm b/games/gold_mine.scm
index 9a084db..a12539f 100644
--- a/games/gold_mine.scm
+++ b/games/gold_mine.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(load "klondike.scm")
(define deal-one #f)
diff --git a/games/golf.scm b/games/golf.scm
index cc0b621..7c8018c 100644
--- a/games/golf.scm
+++ b/games/golf.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define extend-waste #t)
(define stock 0)
diff --git a/games/gypsy.scm b/games/gypsy.scm
index 9ed41d4..8f5f755 100644
--- a/games/gypsy.scm
+++ b/games/gypsy.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define foundation '(1 2 3 4 5 6 7 8))
(define (new-game)
diff --git a/games/helsinki.scm b/games/helsinki.scm
index eceef0c..180868e 100644
--- a/games/helsinki.scm
+++ b/games/helsinki.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/hopscotch.scm b/games/hopscotch.scm
index 42892c9..c06e791 100644
--- a/games/hopscotch.scm
+++ b/games/hopscotch.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/isabel.scm b/games/isabel.scm
index 4327115..ad145f1 100644
--- a/games/isabel.scm
+++ b/games/isabel.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(make-standard-deck)
diff --git a/games/jamestown.scm b/games/jamestown.scm
index ac306ea..7a4b92d 100644
--- a/games/jamestown.scm
+++ b/games/jamestown.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(make-standard-deck)
diff --git a/games/jumbo.scm b/games/jumbo.scm
index 4fab6de..08b54f3 100644
--- a/games/jumbo.scm
+++ b/games/jumbo.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/kansas.scm b/games/kansas.scm
index 06f4b3c..0036927 100644
--- a/games/kansas.scm
+++ b/games/kansas.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define BASE-VAL 0)
(define stock 0)
diff --git a/games/king_albert.scm b/games/king_albert.scm
index 88827e0..4cfe8e9 100644
--- a/games/king_albert.scm
+++ b/games/king_albert.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/kings_audience.scm b/games/kings_audience.scm
index 70a5683..1abc31c 100644
--- a/games/kings_audience.scm
+++ b/games/kings_audience.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define stock 11)
(define waste 12)
(define reserves '(0 1 2 3 4 9 10 13 14 19 20 21 22 23 24 25))
diff --git a/games/klondike.scm b/games/klondike.scm
index 64724f9..5981115 100644
--- a/games/klondike.scm
+++ b/games/klondike.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define deal-one #t) ;deal one card at a time from stock to waste
(define deal-three #f) ;deal three cards at a time from stock to waste
(define no-redeal #f) ;stock deals a card face-up to each pile in the tableau instead of to waste
diff --git a/games/labyrinth.scm b/games/labyrinth.scm
index 07257de..5fbe1d1 100644
--- a/games/labyrinth.scm
+++ b/games/labyrinth.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(def-save-var first-row #f)
(define (new-game)
diff --git a/games/lady_jane.scm b/games/lady_jane.scm
index 7ba6a4c..f6ae898 100644
--- a/games/lady_jane.scm
+++ b/games/lady_jane.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define BASE-VAL 0)
(define (new-game)
diff --git a/games/maze.scm b/games/maze.scm
index 3d0285d..67e5cc9 100644
--- a/games/maze.scm
+++ b/games/maze.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define card '())
(define (add-line)
diff --git a/games/monte_carlo.scm b/games/monte_carlo.scm
index 0c43467..86b27e3 100644
--- a/games/monte_carlo.scm
+++ b/games/monte_carlo.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/napoleons_tomb.scm b/games/napoleons_tomb.scm
index a0a6c22..6a67725 100644
--- a/games/napoleons_tomb.scm
+++ b/games/napoleons_tomb.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
;;;;
;; Settings:
diff --git a/games/neighbor.scm b/games/neighbor.scm
index ebee160..9335c15 100644
--- a/games/neighbor.scm
+++ b/games/neighbor.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/odessa.scm b/games/odessa.scm
index f4e402b..cc8ecde 100644
--- a/games/odessa.scm
+++ b/games/odessa.scm
@@ -15,6 +15,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
;set up the deck
(set-ace-low)
diff --git a/games/osmosis.scm b/games/osmosis.scm
index 4aeadbd..29b5da6 100644
--- a/games/osmosis.scm
+++ b/games/osmosis.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define deal-three #f)
(define (new-game)
diff --git a/games/peek.scm b/games/peek.scm
index 3b14791..3cd78c6 100644
--- a/games/peek.scm
+++ b/games/peek.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(load "osmosis.scm")
(define (initial-deal)
diff --git a/games/pileon.scm b/games/pileon.scm
index 2725bb7..2dffa10 100644
--- a/games/pileon.scm
+++ b/games/pileon.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/plait.scm b/games/plait.scm
index c1f1670..b3b1154 100644
--- a/games/plait.scm
+++ b/games/plait.scm
@@ -17,6 +17,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
;; @(#) $Id: plait.scm,v 1.14 2005/07/10 07:08:54 callum Exp $
;; Constants
diff --git a/games/poker.scm b/games/poker.scm
index 2bb5c1b..688f1ea 100644
--- a/games/poker.scm
+++ b/games/poker.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define shuffle-mode #f)
(define ORDERED-LIST '())
diff --git a/games/quatorze.scm b/games/quatorze.scm
index 176dc71..328056e 100644
--- a/games/quatorze.scm
+++ b/games/quatorze.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/royal_east.scm b/games/royal_east.scm
index 527aae4..7650527 100644
--- a/games/royal_east.scm
+++ b/games/royal_east.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define BASE-VAL 0)
(define stock 0)
diff --git a/games/saratoga.scm b/games/saratoga.scm
index 66aac13..b7edac5 100644
--- a/games/saratoga.scm
+++ b/games/saratoga.scm
@@ -23,6 +23,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(load "klondike.scm")
(define deal-one #t)
diff --git a/games/scorpion.scm b/games/scorpion.scm
index d8a43fd..33bf17c 100644
--- a/games/scorpion.scm
+++ b/games/scorpion.scm
@@ -13,6 +13,8 @@
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(use-modules (aisleriot interface) (aisleriot api))
; winning game seed: 2036201447
(define (new-game)
diff --git a/games/scuffle.scm b/games/scuffle.scm
index b5b53bc..f5fa479 100644
--- a/games/scuffle.scm
+++ b/games/scuffle.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/seahaven.scm b/games/seahaven.scm
index f0dcd29..c1a697a 100644
--- a/games/seahaven.scm
+++ b/games/seahaven.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(def-save-var free-reserves 0)
(define foundation '(0 1 6 7))
diff --git a/games/sir_tommy.scm b/games/sir_tommy.scm
index d8a60d5..c4d46be 100644
--- a/games/sir_tommy.scm
+++ b/games/sir_tommy.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/spider.scm b/games/spider.scm
index 2026986..9ef600c 100644
--- a/games/spider.scm
+++ b/games/spider.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define suits-one #f)
(define suits-two #f)
(define suits-four #t)
diff --git a/games/spider_three_decks.scm b/games/spider_three_decks.scm
index 67cb535..f423451 100644
--- a/games/spider_three_decks.scm
+++ b/games/spider_three_decks.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(load "spider.scm")
(define tableau '(13 14 15 16 17 18 19 20 21 22 23 24))
diff --git a/games/spiderette.scm b/games/spiderette.scm
index 69cc89c..16352fe 100644
--- a/games/spiderette.scm
+++ b/games/spiderette.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(load "spider.scm")
(define stock 0)
diff --git a/games/straight_up.scm b/games/straight_up.scm
index 2186985..e1d5400 100644
--- a/games/straight_up.scm
+++ b/games/straight_up.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-high)
diff --git a/games/streets_and_alleys.scm b/games/streets_and_alleys.scm
index 4058be7..091084f 100644
--- a/games/streets_and_alleys.scm
+++ b/games/streets_and_alleys.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/template.scm b/games/template.scm
index ff74fbd..6b8a86f 100644
--- a/games/template.scm
+++ b/games/template.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
diff --git a/games/ten_across.scm b/games/ten_across.scm
index a1874cb..891eb48 100644
--- a/games/ten_across.scm
+++ b/games/ten_across.scm
@@ -16,6 +16,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define allow-two-spot-use #t)
; The set up:
diff --git a/games/terrace.scm b/games/terrace.scm
index a66fb9c..e21b56e 100644
--- a/games/terrace.scm
+++ b/games/terrace.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api) (ice-9 format))
+
(define reserve-size 11)
(define tableau-size 9)
(define build-foundation-in-suit #f)
diff --git a/games/thieves.scm b/games/thieves.scm
index 5be7061..8dbb9c1 100644
--- a/games/thieves.scm
+++ b/games/thieves.scm
@@ -15,6 +15,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/thirteen.scm b/games/thirteen.scm
index 8ef231e..d02805c 100644
--- a/games/thirteen.scm
+++ b/games/thirteen.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define magic-total 13)
(define waste-slot 1)
diff --git a/games/thumb_and_pouch.scm b/games/thumb_and_pouch.scm
index a1b3bba..54ce9d0 100644
--- a/games/thumb_and_pouch.scm
+++ b/games/thumb_and_pouch.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define tableau '(6 7 8 9 10 11 12))
(define foundation '(2 3 4 5))
diff --git a/games/treize.scm b/games/treize.scm
index c112868..d4ef54b 100644
--- a/games/treize.scm
+++ b/games/treize.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/triple_peaks.scm b/games/triple_peaks.scm
index 94691d2..387dfc7 100644
--- a/games/triple_peaks.scm
+++ b/games/triple_peaks.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define progressive-rounds #f)
(define multiplier-scoring #f)
diff --git a/games/union_square.scm b/games/union_square.scm
index d4bd5af..9384eff 100644
--- a/games/union_square.scm
+++ b/games/union_square.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define stock 0)
(define waste 1)
(define tableau '(2 3 4 5 7 8 9 10 12 13 14 15 17 18 19 20))
diff --git a/games/valentine.scm b/games/valentine.scm
index d9a16fc..8080007 100644
--- a/games/valentine.scm
+++ b/games/valentine.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/westhaven.scm b/games/westhaven.scm
index 459c41f..47115f9 100644
--- a/games/westhaven.scm
+++ b/games/westhaven.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define stock 0)
(define waste 1)
(define foundation '(2 3 4 5))
diff --git a/games/whitehead.scm b/games/whitehead.scm
index 2c31207..8a2873c 100644
--- a/games/whitehead.scm
+++ b/games/whitehead.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define foundation '(2 3 4 5))
(define (new-game)
diff --git a/games/will_o_the_wisp.scm b/games/will_o_the_wisp.scm
index 69869e8..1416f54 100644
--- a/games/will_o_the_wisp.scm
+++ b/games/will_o_the_wisp.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(load "spider.scm")
diff --git a/games/yield.scm b/games/yield.scm
index 328471e..8f59ff1 100644
--- a/games/yield.scm
+++ b/games/yield.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/games/yukon.scm b/games/yukon.scm
index 20f27f7..af97a0a 100644
--- a/games/yukon.scm
+++ b/games/yukon.scm
@@ -13,6 +13,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
diff --git a/games/zebra.scm b/games/zebra.scm
index e0cba34..f805ee2 100644
--- a/games/zebra.scm
+++ b/games/zebra.scm
@@ -14,6 +14,8 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (aisleriot interface) (aisleriot api))
+
(define (new-game)
(initialize-playing-area)
(set-ace-low)
diff --git a/src/ar-game-chooser.c b/src/ar-game-chooser.c
index c9abad9..0db3f11 100644
--- a/src/ar-game-chooser.c
+++ b/src/ar-game-chooser.c
@@ -158,7 +158,7 @@ ar_game_chooser_constructor (GType type,
GtkTreeIter iter;
if (!g_str_has_suffix (game_file, ".scm") ||
- strcmp (game_file, "sol.scm") == 0)
+ strcmp (game_file, "api.scm") == 0)
continue;
game_name = ar_filename_to_display_name (game_file);
diff --git a/src/game.c b/src/game.c
index cea6242..3e995f4 100644
--- a/src/game.c
+++ b/src/game.c
@@ -44,6 +44,10 @@
#define I_(string) g_intern_static_string (string)
+#ifndef SCM_MAJOR_VERSION
+#define SCM_MAJOR_VERSION 1
+#endif
+
struct _AisleriotGameClass
{
GObjectClass parent_class;
@@ -1243,6 +1247,8 @@ aisleriot_game_class_init (AisleriotGameClass *klass)
GType param_types[] = { G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE };
GType error_types[] = { G_TYPE_ERROR | G_SIGNAL_TYPE_STATIC_SCOPE };
GType ptr_types[] = { G_TYPE_POINTER };
+ SCM variable;
+ const char *path;
gobject_class->constructor = aisleriot_game_constructor;
gobject_class->finalize = aisleriot_game_finalize;
@@ -1357,6 +1363,19 @@ aisleriot_game_class_init (AisleriotGameClass *klass)
G_PARAM_STATIC_STRINGS));
scm_c_define_module ("aisleriot interface", cscm_init, NULL);
+
+ /* Append load-path */
+ path = ar_runtime_get_directory (AR_RUNTIME_PKG_DATA_DIRECTORY);
+ variable = scm_c_module_lookup (scm_the_root_module (), "%load-path");
+ scm_variable_set_x (variable, scm_append_x (scm_list_2 (scm_variable_ref (variable),
+ scm_list_1 (scm_from_locale_string (path)))));
+
+#if SCM_MAJOR_VERSION >= 2
+ path = ar_runtime_get_directory (AR_RUNTIME_PKG_LIBRARY_DIRECTORY);
+ variable = scm_c_module_lookup (scm_the_root_module (), "%load-compiled-path");
+ scm_variable_set_x (variable, scm_append_x (scm_list_2 (scm_variable_ref (variable),
+ scm_list_1 (scm_from_locale_string (path)))));
+#endif
}
/* public API */
@@ -1643,13 +1662,6 @@ game_scm_load_game (void *user_data)
scm_dynwind_begin (0);
- /* Although this line slows down game switching by a noticeable amount, we
- * add it here in order to make sure all the original functions are
- * "clean". */
- path = ar_runtime_get_file (AR_RUNTIME_GAMES_DIRECTORY, "sol.scm");
- scm_dynwind_unwind_handler (g_free, path, SCM_F_WIND_EXPLICITLY);
- scm_c_primitive_load (path);
-
path = ar_runtime_get_file (AR_RUNTIME_GAMES_DIRECTORY, game_file);
scm_dynwind_unwind_handler (g_free, path, SCM_F_WIND_EXPLICITLY);
scm_c_primitive_load (path);
diff --git a/src/window.c b/src/window.c
index 061eb0e..6539a87 100644
--- a/src/window.c
+++ b/src/window.c
@@ -605,7 +605,7 @@ debug_ensure_game_list (AisleriotWindow *window)
while ((game_file = g_dir_read_name (dir)) != NULL) {
if (!g_str_has_suffix (game_file, ".scm") ||
- strcmp (game_file, "sol.scm") == 0)
+ strcmp (game_file, "api.scm") == 0)
continue;
list = g_list_prepend (list, g_strdup (game_file));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]