how to save and load the state of a game in scheme
- by user3667664
I'm creating the game of chess in scheme, but do not know how to save and load game state is a part I have this code
(define-struct ficha(color se-movio? tipo-ficha ))
;;tablero lista de listas de fichas
(define-struct estado (tablero turno fichaSel))
(define bpawn (bitmap "b-peon.png"))
(define brook (bitmap "b-torre.png"))
(define bcaballo (bitmap "b-caballo.png"))
(define bbish (bitmap "b-arfil.png"))
(define bquee (bitmap "b-reina.png"))
(define bking (bitmap "b-rey.png"))
(define wpawn (bitmap "w-peon.png"))
(define wrook (bitmap "w-torre.png"))
(define wcaballo (bitmap "w-caballo.png"))
(define wbish (bitmap "w-arfil.png"))
(define wquee (bitmap "w-reina.png"))
(define wking (bitmap "w-rey.png"))
(define board (bitmap "board.jpg"))
This is the board that is a list of lists
(define tableroini (list (list torreb caballob arfilb reinab reyb arfilb caballob torreb)
(list peonb peonb peonb peonb peonb peonb peonb peonb)
(list empty empty empty empty empty empty empty empty)
(list empty empty empty empty empty empty empty empty)
(list empty empty empty empty empty empty empty empty)
(list empty empty empty empty empty empty empty empty)
(list peonw peonw peonw peonw peonw peonw peonw peonw)
(list torrew caballow arfilw reinaw reyw arfilw caballow torrew)))
I did this to save the state of the game:
(define (Guardar-en-archivo archivo)
(write-file (string-append Subcarpeta archivo ".txt")
"game state" ))
But not as you insert the game state on "game state" for me to save the game
How I can do this ?