unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* GPT-4 knows Guile! :)
@ 2023-03-17 16:01 Mikael Djurfeldt
  2023-03-17 17:25 ` Mikael Djurfeldt
  0 siblings, 1 reply; 19+ messages in thread
From: Mikael Djurfeldt @ 2023-03-17 16:01 UTC (permalink / raw)
  To: guile-user, guile-devel; +Cc: Mikael Djurfeldt

[-- Attachment #1: Type: text/plain, Size: 4314 bytes --]

Mikael: Let's write a scheme program which randomly makes names by
combining two words from a list.

To write a Scheme program that generates random names by combining two
words from a list, you can use the following code:

scheme

(import (scheme random)) ; Import random number generation functions

(define word-list '("Alpha" "Beta" "Gamma" "Delta" "Epsilon" "Zeta"
"Eta" "Theta" "Iota" "Kappa"))

(define (random-word lst)
  (list-ref lst (random (length lst))))

(define (random-name)
  (string-append (random-word word-list) (random-word word-list)))

(random-name)

In this program, we:

   1. Import the random number generation functions from the (scheme random)
   library.
   2. Define a word-list containing words that will be used to generate
   random names.
   3. Create a function random-word that takes a list as an argument and
   returns a random element from that list.
   4. Create a function random-name that combines two random words from the
   word-list using string-append.
   5. Call random-name to generate a random name.

You can run this code in a Scheme interpreter or REPL (Read-Eval-Print
Loop) to generate random names.
[image: mikael@djurfeldt.com]
Mikael: Great! Can you adapt it for Guile scheme?

Sure! Here's the adapted code for Guile Scheme:

scheme

(use-modules (ice-9 random)) ; Import random number generation
functions for Guile

(define word-list '("Alpha" "Beta" "Gamma" "Delta" "Epsilon" "Zeta"
"Eta" "Theta" "Iota" "Kappa"))

(define (random-word lst)
  (list-ref lst (random (length lst))))

(define (random-name)
  (string-append (random-word word-list) (random-word word-list)))

(random-name)

In this Guile Scheme version, we:

   1. Replace the (import (scheme random)) statement with (use-modules
   (ice-9 random)) to import random number generation functions in Guile
   Scheme.
   2. The rest of the code remains the same as the original Scheme version.

You can run this code in a Guile Scheme interpreter or REPL to generate
random names.
[image: mikael@djurfeldt.com]
Mikael: Now let's use the words doodle, puck, bongo, foo, bar zoinc instead.

Here's the Guile Scheme code using the new words you provided:

scheme

(use-modules (ice-9 random)) ; Import random number generation
functions for Guile

(define word-list '("doodle" "puck" "bongo" "foo" "bar" "zoinc"))

(define (random-word lst)
  (list-ref lst (random (length lst))))

(define (random-name)
  (string-append (random-word word-list) (random-word word-list)))

(random-name)

The only change made to the original code is updating the word-list with
the new words you've provided. The rest of the code remains the same. You
can run this updated code in a Guile Scheme interpreter or REPL to generate
random names using the new words.
Mikael: Can you execute (random-name)?

As an AI text-based model, I am unable to directly execute code in a REPL
environment. However, I can help you understand how to run the provided
code.

To run the provided Guile Scheme code and execute (random-name), you can
follow these steps:

   1.

   Install Guile on your computer if you haven't already. You can find
   installation instructions here:
   https://www.gnu.org/software/guile/download/
   2.

   Copy and paste the provided code into a text editor, and save it as a
   file named random-name.scm.
   3.

   Open a terminal or command prompt, and navigate to the directory where
   you saved the random-name.scm file.
   4.

   Run the following command in the terminal or command prompt: guile -s
   random-name.scm

This command will execute the Guile Scheme code in the random-name.scm file
and print a random name using the words from the word-list. Each time you
run the command, you will get a new random name as the output.[image:
mikael@djurfeldt.com]
Mikael: Can you give one example of how the result would look like?

Certainly! When you execute the provided Guile Scheme code using the given
word list, you may get different random names each time you run it. Here's
one possible example of a random name generated using the words in the
word-list:

doodlebongo

In this example, the program has combined the words "doodle" and "bongo" to
create a new random name. Keep in mind that you will get different results
each time you run the program, as the name generation is random.

[-- Attachment #2: Type: text/html, Size: 22369 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-17 16:01 GPT-4 knows Guile! :) Mikael Djurfeldt
@ 2023-03-17 17:25 ` Mikael Djurfeldt
  2023-03-17 19:09   ` Damien Mattei
       [not found]   ` <ZBViQz4I3E4Qb08Q@tuxteam.de>
  0 siblings, 2 replies; 19+ messages in thread
From: Mikael Djurfeldt @ 2023-03-17 17:25 UTC (permalink / raw)
  To: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 16975 bytes --]

Can you write a Guile Scheme program which displays a bouncing ball?

As an AI language model, I cannot create a full graphical program directly
within this text-based environment. However, I can provide you with an
example of a simple bouncing ball simulation using the Guile Scheme
programming language and the SDL2 (Simple DirectMedia Layer) library, which
is commonly used for creating graphical applications.

To start, you'll need to have Guile and the Guile-SDL2 bindings installed.
The following instructions are for a Debian-based system:

   1. Install Guile:

csharp

sudo apt-get install guile-2.2


   1. Install SDL2 development libraries:

csharp

sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev


   1. Clone and build the Guile-SDL2 library:

bash

git clone https://github.com/davexunit/guile-sdl2.gitcd guile-sdl2
autoreconf -vif
./configure
make
sudo make install

Now you can create the bouncing ball program in a file called
bouncing-ball.scm:

scheme

(use-modules (sdl2)
             (sdl2 video)
             (sdl2 events)
             (sdl2 timer)
             (sdl2 rect))

(define screen-width 640)
(define screen-height 480)
(define ball-size 20)

(define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
(define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
(define ball-x-velocity (make-parameter 4))
(define ball-y-velocity (make-parameter 4))

(define (process-events)
  (let loop ((event (poll-event)))
    (when event
      (case (event-type event)
        ((quit) #f)
        (else (loop (poll-event)))))))

(define (update-ball)
  (parameterize ((x (ball-x))
                 (y (ball-y))
                 (vx (ball-x-velocity))
                 (vy (ball-y-velocity)))
    (ball-x (+ x vx))
    (ball-y (+ y vy))

    (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
      (ball-x-velocity (- vx)))

    (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
      (ball-y-velocity (- vy)))))

(define (draw-ball renderer)
  (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
    (set-render-draw-color renderer 255 0 0 255)
    (render-fill-rect renderer ball-rect)))

(define (main)
  (init! +init-video+)
  (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
+window-pos-undefined+ screen-width screen-height +window-shown+))
        (renderer (create-renderer window -1 +renderer-accelerated+)))
    (set-render-draw-color renderer 0 0 0 255)
    (let loop ()
      (unless (process-events)
        (update-ball)
        (render-clear renderer)
        (draw-ball renderer)
        (render-present renderer)
        (delay 16)
        (loop)))))

(main)

This example sets up a window using SDL2 and creates a simple ball that
bounces off the edges of the window. You can run the program using the
following command:

bash

guile bouncing-ball.scm

Keep in mind that this is a simple example, and there are many ways to
improve or expand upon it, such as using images
[image: mikael@djurfeldt.com]
I get the following error message: ;;; note: auto-compilation is enabled,
set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to
disable. ;;; compiling /home/mdj/guile/bouncing-ball.scm ;;;
/home/mdj/guile/bouncing-ball.scm:19:13: warning: possibly unbound variable
`event-type' ;;; /home/mdj/guile/bouncing-ball.scm:24:18: warning: possibly
unbound variable `x' ;;; /home/mdj/guile/bouncing-ball.scm:25:18: warning:
possibly unbound variable `y' ;;; /home/mdj/guile/bouncing-ball.scm:26:18:
warning: possibly unbound variable `vx' ;;;
/home/mdj/guile/bouncing-ball.scm:27:18: warning: possibly unbound variable
`vy' ;;; /home/mdj/guile/bouncing-ball.scm:39:5: warning: possibly unbound
variable `set-render-draw-color' ;;;
/home/mdj/guile/bouncing-ball.scm:40:5: warning: possibly unbound variable
`render-fill-rect' ;;; /home/mdj/guile/bouncing-ball.scm:43:3: warning:
possibly unbound variable `init!' ;;;
/home/mdj/guile/bouncing-ball.scm:43:9: warning: possibly unbound variable
`+init-video+' ;;; /home/mdj/guile/bouncing-ball.scm:44:17: warning:
possibly unbound variable `create-window' ;;;
/home/mdj/guile/bouncing-ball.scm:44:47: warning: possibly unbound variable
`+window-pos-undefined+' ;;; /home/mdj/guile/bouncing-ball.scm:44:120:
warning: possibly unbound variable `+window-shown+' ;;;
/home/mdj/guile/bouncing-ball.scm:45:19: warning: possibly unbound variable
`create-renderer' ;;; /home/mdj/guile/bouncing-ball.scm:45:35: warning:
possibly unbound variable `window' ;;;
/home/mdj/guile/bouncing-ball.scm:45:45: warning: possibly unbound variable
`+renderer-accelerated+' ;;; /home/mdj/guile/bouncing-ball.scm:50:9:
warning: possibly unbound variable `render-clear' ;;;
/home/mdj/guile/bouncing-ball.scm:52:9: warning: possibly unbound variable
`render-present' ;;; compiled
/home/mdj/.cache/guile/ccache/3.0-LE-8-4.6/home/mdj/guile/bouncing-ball.scm.go
Backtrace: In ice-9/boot-9.scm: 1752:10 6 (with-exception-handler _ _
#:unwind? _ # _) In unknown file: 5 (apply-smob/0 #<thunk 7f79f1cd8300>) In
ice-9/boot-9.scm: 724:2 4 (call-with-prompt _ _ #<procedure
default-prompt-handle…>) In ice-9/eval.scm: 619:8 3 (_ #(#(#<directory
(guile-user) 7f79f1cdbc80>))) In ice-9/boot-9.scm: 2836:4 2
(save-module-excursion _) 4388:12 1 (_) In
/home/mdj/guile/bouncing-ball.scm: 43:3 0 (main)
/home/mdj/guile/bouncing-ball.scm:43:3: In procedure main: Unbound
variable: init!

Apologies for the confusion. It seems I made a mistake in the provided
code, and some symbols were not correctly imported. Let's fix the imports
by using the appropriate modules and functions. Replace the (use-modules
...) line in the code with the following:

scheme

(use-modules (sdl2) (sdl2 video) (sdl2 events) (sdl2 timer) (sdl2
rect) (sdl2 rwops) (sdl2 surface) (sdl2 sdl))

Additionally, it seems that the init! function is not being recognized. It
should be SDL_Init instead. So, replace the line (init! +init-video+) with:

scheme

(SDL_Init +SDL_INIT_VIDEO+)

After making these changes, the updated bouncing-ball.scm should look like
this:

scheme

(use-modules (sdl2)
             (sdl2 video)
             (sdl2 events)
             (sdl2 timer)
             (sdl2 rect)
             (sdl2 rwops)
             (sdl2 surface)
             (sdl2 sdl))

(define screen-width 640)
(define screen-height 480)
(define ball-size 20)

(define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
(define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
(define ball-x-velocity (make-parameter 4))
(define ball-y-velocity (make-parameter 4))

(define (process-events)
  (let loop ((event (poll-event)))
    (when event
      (case (event-type event)
        ((quit) #f)
        (else (loop (poll-event)))))))

(define (update-ball)
  (parameterize ((x (ball-x))
                 (y (ball-y))
                 (vx (ball-x-velocity))
                 (vy (ball-y-velocity)))
    (ball-x (+ x vx))
    (ball-y (+ y vy))

    (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
      (ball-x-velocity (- vx)))

    (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
      (ball-y-velocity (- vy)))))

(define (draw-ball renderer)
  (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
    (set-render-draw-color renderer 255 0 0 255)
    (render-fill-rect renderer ball-rect)))

(define (main)
  (SDL_Init +SDL_INIT_VIDEO+)
  (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
+window-pos-undefined+ screen-width screen-height +window-shown+))
        (renderer (create-renderer window -1 +renderer-accelerated+)))
    (set-render-draw-color renderer 0 0 0 255)
    (let loop ()
      (unless (process-events)
        (update-ball)
        (render-clear renderer)
        (draw-ball renderer)
        (render-present renderer)
        (delay 16)
        (loop)))))

(main)

Now, the program should run without any issues. Run it with:

bash

guile bouncing-ball.scm

[image: mikael@djurfeldt.com]
I think it should be make-window instead of create-window.

You are correct. The function should be make-window instead of create-window.
I apologize for the confusion. Here's the updated bouncing-ball.scm code
with the corrected function name:

scheme

(use-modules (sdl2)
             (sdl2 video)
             (sdl2 events)
             (sdl2 timer)
             (sdl2 rect)
             (sdl2 rwops)
             (sdl2 surface)
             (sdl2 sdl))

(define screen-width 640)
(define screen-height 480)
(define ball-size 20)

(define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
(define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
(define ball-x-velocity (make-parameter 4))
(define ball-y-velocity (make-parameter 4))

(define (process-events)
  (let loop ((event (poll-event)))
    (when event
      (case (event-type event)
        ((quit) #f)
        (else (loop (poll-event)))))))

(define (update-ball)
  (parameterize ((x (ball-x))
                 (y (ball-y))
                 (vx (ball-x-velocity))
                 (vy (ball-y-velocity)))
    (ball-x (+ x vx))
    (ball-y (+ y vy))

    (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
      (ball-x-velocity (- vx)))

    (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
      (ball-y-velocity (- vy)))))

(define (draw-ball renderer)
  (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
    (set-render-draw-color renderer 255 0 0 255)
    (render-fill-rect renderer ball-rect)))

(define (main)
  (SDL_Init +SDL_INIT_VIDEO+)
  (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
+window-pos-undefined+ screen-width screen-height +window-shown+))
        (renderer (create-renderer window -1 +renderer-accelerated+)))
    (set-render-draw-color renderer 0 0 0 255)
    (let loop ()
      (unless (process-events)
        (update-ball)
        (render-clear renderer)
        (draw-ball renderer)
        (render-present renderer)
        (delay 16)
        (loop)))))

(main)

Now, the program should run as expected:

bash

guile bouncing-ball.scm

[image: mikael@djurfeldt.com]
Please write the program according to the guile-sdl2 manual.

Apologies for the confusion. Here's an updated version of the bouncing ball
program according to the guile-sdl2 manual:

scheme

(use-modules (sdl2)
             (sdl2 video)
             (sdl2 events)
             (sdl2 timer)
             (sdl2 rect)
             (sdl2 rwops)
             (sdl2 surface)
             (sdl2 sdl))

(define screen-width 640)
(define screen-height 480)
(define ball-size 20)

(define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
(define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
(define ball-x-velocity (make-parameter 4))
(define ball-y-velocity (make-parameter 4))

(define (process-events)
  (let loop ((event (SDL_PollEvent)))
    (when event
      (case (event-type event)
        ((quit) #f)
        (else (loop (SDL_PollEvent)))))))

(define (update-ball)
  (parameterize ((x (ball-x))
                 (y (ball-y))
                 (vx (ball-x-velocity))
                 (vy (ball-y-velocity)))
    (ball-x (+ x vx))
    (ball-y (+ y vy))

    (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
      (ball-x-velocity (- vx)))

    (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
      (ball-y-velocity (- vy)))))

(define (draw-ball renderer)
  (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
    (SDL_SetRenderDrawColor renderer 255 0 0 255)
    (SDL_RenderFillRect renderer ball-rect)))

(define (main)
  (SDL_Init +SDL_INIT_VIDEO+)
  (let ((window (SDL_CreateWindow "Bouncing Ball"
+SDL_WINDOWPOS_UNDEFINED+ +SDL_WINDOWPOS_UNDEFINED+ screen-width
screen-height +SDL_WINDOW_SHOWN+))
        (renderer (SDL_CreateRenderer window -1 +SDL_RENDERER_ACCELERATED+)))
    (SDL_SetRenderDrawColor renderer 0 0 0 255)
    (let loop ()
      (unless (process-events)
        (update-ball)
        (SDL_RenderClear renderer)
        (draw-ball renderer)
        (SDL_RenderPresent renderer)
        (SDL_Delay 16)
        (loop))
    (SDL_DestroyRenderer renderer)
    (SDL_DestroyWindow window)))

(SDL_Quit)
(main)

Now, the program should run as expected:

bash

guile bouncing-ball.scm

[image: mikael@djurfeldt.com]
But all those SDL_ calls look like C bindings. Please use guile-sdl2
bindings.

I apologize for the confusion. Here's the bouncing ball program implemented
using the Guile-SDL2 bindings:

scheme

(use-modules (sdl2)
             (sdl2 video)
             (sdl2 events)
             (sdl2 timer)
             (sdl2 rect)
             (sdl2 rwops)
             (sdl2 surface)
             (sdl2 sdl))

(define screen-width 640)
(define screen-height 480)
(define ball-size 20)

(define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
(define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
(define ball-x-velocity (make-parameter 4))
(define ball-y-velocity (make-parameter 4))

(define (process-events)
  (let loop ((event (poll-event)))
    (when event
      (case (event-type event)
        ((quit) #f)
        (else (loop (poll-event)))))))

(define (update-ball)
  (parameterize ((x (ball-x))
                 (y (ball-y))
                 (vx (ball-x-velocity))
                 (vy (ball-y-velocity)))
    (ball-x (+ x vx))
    (ball-y (+ y vy))

    (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
      (ball-x-velocity (- vx)))

    (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
      (ball-y-velocity (- vy)))))

(define (draw-ball renderer)
  (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
    (set-render-draw-color! renderer 255 0 0 255)
    (render-fill-rect! renderer ball-rect)))

(define (main)
  (init! +init-video+)
  (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
+window-pos-undefined+ screen-width screen-height +window-shown+))
        (renderer (make-renderer window -1 +renderer-accelerated+)))
    (set-render-draw-color! renderer 0 0 0 255)
    (let loop ()
      (unless (process-events)
        (update-ball)
        (render-clear! renderer)
        (draw-ball renderer)
        (render-present! renderer)
        (delay 16)
        (loop))
    (destroy-renderer! renderer)
    (destroy-window! window)))

(quit!)
(main)

Now, the program should run as expected:

bash

guile bouncing-ball.scm

---

Turns out there are multiple problems with that program also. Here I
(mikael) fixed a number of problems and actually *got* a bouncing
ball. :)

(use-modules (sdl2)
             (sdl2 video)
             (sdl2 events)
             ;(sdl2 timer)
             (sdl2 rect)
             ;(sdl2 rwops)
             (sdl2 surface)
					;(sdl2 sdl)
	     (sdl2 render))

(define screen-width 640)
(define screen-height 480)
(define ball-size 20)

(define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
(define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
(define ball-x-velocity (make-parameter 4))
(define ball-y-velocity (make-parameter 4))

(define (process-events)
  (let loop ((event (poll-event)))
    (if event
	(cond
         ((quit-event? event) #t)
         (else (loop (poll-event))))
	#f)))

(define (update-ball)
  (let ((x (ball-x))
        (y (ball-y))
        (vx (ball-x-velocity))
        (vy (ball-y-velocity)))
    (ball-x (+ x vx))
    (ball-y (+ y vy))

    (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
      (ball-x-velocity (- vx)))

    (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
      (ball-y-velocity (- vy)))))

(define (draw-ball renderer)
  (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
    (set-renderer-draw-color! renderer 255 0 0 255)
    (render-fill-rect renderer ball-rect)))

(define (main)
  (sdl-init)
  (let* ((window (make-window #:title "Bouncing Ball" #:size (list
screen-width screen-height)))
         (renderer (make-renderer window)))
    (set-renderer-draw-color! renderer 0 0 0 255)
    (let loop ()
      (unless (process-events)
        (update-ball)
	(set-renderer-draw-color! renderer 0 0 0 0)
        (clear-renderer renderer)
        (draw-ball renderer)
        (present-renderer renderer)
					;(delay 16)
        (loop))
    (delete-renderer! renderer)
					;(destroy-window! window)
    )))

;(quit!)
(main)

[-- Attachment #2: Type: text/html, Size: 44168 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-17 17:25 ` Mikael Djurfeldt
@ 2023-03-17 19:09   ` Damien Mattei
  2023-03-17 19:28     ` Damien Mattei
       [not found]   ` <ZBViQz4I3E4Qb08Q@tuxteam.de>
  1 sibling, 1 reply; 19+ messages in thread
From: Damien Mattei @ 2023-03-17 19:09 UTC (permalink / raw)
  To: mikael; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 19150 bytes --]

i understand the fun thing... :-)

and i did not check the program with Guile but asked a Racket version of
the bouncing ball and it is full of errors even if i try to correct them by
hand...

Welcome to DrRacket, version 8.7 [cs].
Language: racket/gui, with debugging; memory limit: 8192 MB.
. . send: no such method
  method name: register-event-callback
  class name: canvas%


after i asked this question to chatGPT:

"Can you write a Guile Scheme program that put a logical expression in
minimal disjunctive normal form?"

i got a truncated program trying to code a QuineMcCluskey algorithm
implementation that i can not redisplay here because i got a connection
error to server and that looked like a bit,but from very very very far away
my own logic code in github that i spend many years to wrote,

and the Chat finished  like this:

"Hmm...something seems to have gone wrong. Maybe try me again in a little
bit"

:-)

Damien

On Fri, Mar 17, 2023 at 6:26 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> Can you write a Guile Scheme program which displays a bouncing ball?
>
> As an AI language model, I cannot create a full graphical program directly
> within this text-based environment. However, I can provide you with an
> example of a simple bouncing ball simulation using the Guile Scheme
> programming language and the SDL2 (Simple DirectMedia Layer) library, which
> is commonly used for creating graphical applications.
>
> To start, you'll need to have Guile and the Guile-SDL2 bindings installed.
> The following instructions are for a Debian-based system:
>
>    1. Install Guile:
>
> csharp
>
> sudo apt-get install guile-2.2
>
>
>    1. Install SDL2 development libraries:
>
> csharp
>
> sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
>
>
>    1. Clone and build the Guile-SDL2 library:
>
> bash
>
> git clone https://github.com/davexunit/guile-sdl2.gitcd guile-sdl2
> autoreconf -vif
> ./configure
> make
> sudo make install
>
> Now you can create the bouncing ball program in a file called
> bouncing-ball.scm:
>
> scheme
>
> (use-modules (sdl2)
>              (sdl2 video)
>              (sdl2 events)
>              (sdl2 timer)
>              (sdl2 rect))
>
> (define screen-width 640)
> (define screen-height 480)
> (define ball-size 20)
>
> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> (define ball-x-velocity (make-parameter 4))
> (define ball-y-velocity (make-parameter 4))
>
> (define (process-events)
>   (let loop ((event (poll-event)))
>     (when event
>       (case (event-type event)
>         ((quit) #f)
>         (else (loop (poll-event)))))))
>
> (define (update-ball)
>   (parameterize ((x (ball-x))
>                  (y (ball-y))
>                  (vx (ball-x-velocity))
>                  (vy (ball-y-velocity)))
>     (ball-x (+ x vx))
>     (ball-y (+ y vy))
>
>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>       (ball-x-velocity (- vx)))
>
>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>       (ball-y-velocity (- vy)))))
>
> (define (draw-ball renderer)
>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>     (set-render-draw-color renderer 255 0 0 255)
>     (render-fill-rect renderer ball-rect)))
>
> (define (main)
>   (init! +init-video+)
>   (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
> +window-pos-undefined+ screen-width screen-height +window-shown+))
>         (renderer (create-renderer window -1 +renderer-accelerated+)))
>     (set-render-draw-color renderer 0 0 0 255)
>     (let loop ()
>       (unless (process-events)
>         (update-ball)
>         (render-clear renderer)
>         (draw-ball renderer)
>         (render-present renderer)
>         (delay 16)
>         (loop)))))
>
> (main)
>
> This example sets up a window using SDL2 and creates a simple ball that
> bounces off the edges of the window. You can run the program using the
> following command:
>
> bash
>
> guile bouncing-ball.scm
>
> Keep in mind that this is a simple example, and there are many ways to
> improve or expand upon it, such as using images
> [image: mikael@djurfeldt.com]
> I get the following error message: ;;; note: auto-compilation is enabled,
> set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to
> disable. ;;; compiling /home/mdj/guile/bouncing-ball.scm ;;;
> /home/mdj/guile/bouncing-ball.scm:19:13: warning: possibly unbound variable
> `event-type' ;;; /home/mdj/guile/bouncing-ball.scm:24:18: warning: possibly
> unbound variable `x' ;;; /home/mdj/guile/bouncing-ball.scm:25:18: warning:
> possibly unbound variable `y' ;;; /home/mdj/guile/bouncing-ball.scm:26:18:
> warning: possibly unbound variable `vx' ;;;
> /home/mdj/guile/bouncing-ball.scm:27:18: warning: possibly unbound variable
> `vy' ;;; /home/mdj/guile/bouncing-ball.scm:39:5: warning: possibly unbound
> variable `set-render-draw-color' ;;;
> /home/mdj/guile/bouncing-ball.scm:40:5: warning: possibly unbound variable
> `render-fill-rect' ;;; /home/mdj/guile/bouncing-ball.scm:43:3: warning:
> possibly unbound variable `init!' ;;;
> /home/mdj/guile/bouncing-ball.scm:43:9: warning: possibly unbound variable
> `+init-video+' ;;; /home/mdj/guile/bouncing-ball.scm:44:17: warning:
> possibly unbound variable `create-window' ;;;
> /home/mdj/guile/bouncing-ball.scm:44:47: warning: possibly unbound variable
> `+window-pos-undefined+' ;;; /home/mdj/guile/bouncing-ball.scm:44:120:
> warning: possibly unbound variable `+window-shown+' ;;;
> /home/mdj/guile/bouncing-ball.scm:45:19: warning: possibly unbound variable
> `create-renderer' ;;; /home/mdj/guile/bouncing-ball.scm:45:35: warning:
> possibly unbound variable `window' ;;;
> /home/mdj/guile/bouncing-ball.scm:45:45: warning: possibly unbound variable
> `+renderer-accelerated+' ;;; /home/mdj/guile/bouncing-ball.scm:50:9:
> warning: possibly unbound variable `render-clear' ;;;
> /home/mdj/guile/bouncing-ball.scm:52:9: warning: possibly unbound variable
> `render-present' ;;; compiled
>
> /home/mdj/.cache/guile/ccache/3.0-LE-8-4.6/home/mdj/guile/bouncing-ball.scm.go
> Backtrace: In ice-9/boot-9.scm: 1752:10 6 (with-exception-handler _ _
> #:unwind? _ # _) In unknown file: 5 (apply-smob/0 #<thunk 7f79f1cd8300>) In
> ice-9/boot-9.scm: 724:2 4 (call-with-prompt _ _ #<procedure
> default-prompt-handle…>) In ice-9/eval.scm: 619:8 3 (_ #(#(#<directory
> (guile-user) 7f79f1cdbc80>))) In ice-9/boot-9.scm: 2836:4 2
> (save-module-excursion _) 4388:12 1 (_) In
> /home/mdj/guile/bouncing-ball.scm: 43:3 0 (main)
> /home/mdj/guile/bouncing-ball.scm:43:3: In procedure main: Unbound
> variable: init!
>
> Apologies for the confusion. It seems I made a mistake in the provided
> code, and some symbols were not correctly imported. Let's fix the imports
> by using the appropriate modules and functions. Replace the (use-modules
> ...) line in the code with the following:
>
> scheme
>
> (use-modules (sdl2) (sdl2 video) (sdl2 events) (sdl2 timer) (sdl2
> rect) (sdl2 rwops) (sdl2 surface) (sdl2 sdl))
>
> Additionally, it seems that the init! function is not being recognized. It
> should be SDL_Init instead. So, replace the line (init! +init-video+) with:
>
> scheme
>
> (SDL_Init +SDL_INIT_VIDEO+)
>
> After making these changes, the updated bouncing-ball.scm should look like
> this:
>
> scheme
>
> (use-modules (sdl2)
>              (sdl2 video)
>              (sdl2 events)
>              (sdl2 timer)
>              (sdl2 rect)
>              (sdl2 rwops)
>              (sdl2 surface)
>              (sdl2 sdl))
>
> (define screen-width 640)
> (define screen-height 480)
> (define ball-size 20)
>
> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> (define ball-x-velocity (make-parameter 4))
> (define ball-y-velocity (make-parameter 4))
>
> (define (process-events)
>   (let loop ((event (poll-event)))
>     (when event
>       (case (event-type event)
>         ((quit) #f)
>         (else (loop (poll-event)))))))
>
> (define (update-ball)
>   (parameterize ((x (ball-x))
>                  (y (ball-y))
>                  (vx (ball-x-velocity))
>                  (vy (ball-y-velocity)))
>     (ball-x (+ x vx))
>     (ball-y (+ y vy))
>
>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>       (ball-x-velocity (- vx)))
>
>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>       (ball-y-velocity (- vy)))))
>
> (define (draw-ball renderer)
>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>     (set-render-draw-color renderer 255 0 0 255)
>     (render-fill-rect renderer ball-rect)))
>
> (define (main)
>   (SDL_Init +SDL_INIT_VIDEO+)
>   (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
> +window-pos-undefined+ screen-width screen-height +window-shown+))
>         (renderer (create-renderer window -1 +renderer-accelerated+)))
>     (set-render-draw-color renderer 0 0 0 255)
>     (let loop ()
>       (unless (process-events)
>         (update-ball)
>         (render-clear renderer)
>         (draw-ball renderer)
>         (render-present renderer)
>         (delay 16)
>         (loop)))))
>
> (main)
>
> Now, the program should run without any issues. Run it with:
>
> bash
>
> guile bouncing-ball.scm
>
> [image: mikael@djurfeldt.com]
> I think it should be make-window instead of create-window.
>
> You are correct. The function should be make-window instead of
> create-window.
> I apologize for the confusion. Here's the updated bouncing-ball.scm code
> with the corrected function name:
>
> scheme
>
> (use-modules (sdl2)
>              (sdl2 video)
>              (sdl2 events)
>              (sdl2 timer)
>              (sdl2 rect)
>              (sdl2 rwops)
>              (sdl2 surface)
>              (sdl2 sdl))
>
> (define screen-width 640)
> (define screen-height 480)
> (define ball-size 20)
>
> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> (define ball-x-velocity (make-parameter 4))
> (define ball-y-velocity (make-parameter 4))
>
> (define (process-events)
>   (let loop ((event (poll-event)))
>     (when event
>       (case (event-type event)
>         ((quit) #f)
>         (else (loop (poll-event)))))))
>
> (define (update-ball)
>   (parameterize ((x (ball-x))
>                  (y (ball-y))
>                  (vx (ball-x-velocity))
>                  (vy (ball-y-velocity)))
>     (ball-x (+ x vx))
>     (ball-y (+ y vy))
>
>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>       (ball-x-velocity (- vx)))
>
>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>       (ball-y-velocity (- vy)))))
>
> (define (draw-ball renderer)
>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>     (set-render-draw-color renderer 255 0 0 255)
>     (render-fill-rect renderer ball-rect)))
>
> (define (main)
>   (SDL_Init +SDL_INIT_VIDEO+)
>   (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
> +window-pos-undefined+ screen-width screen-height +window-shown+))
>         (renderer (create-renderer window -1 +renderer-accelerated+)))
>     (set-render-draw-color renderer 0 0 0 255)
>     (let loop ()
>       (unless (process-events)
>         (update-ball)
>         (render-clear renderer)
>         (draw-ball renderer)
>         (render-present renderer)
>         (delay 16)
>         (loop)))))
>
> (main)
>
> Now, the program should run as expected:
>
> bash
>
> guile bouncing-ball.scm
>
> [image: mikael@djurfeldt.com]
> Please write the program according to the guile-sdl2 manual.
>
> Apologies for the confusion. Here's an updated version of the bouncing ball
> program according to the guile-sdl2 manual:
>
> scheme
>
> (use-modules (sdl2)
>              (sdl2 video)
>              (sdl2 events)
>              (sdl2 timer)
>              (sdl2 rect)
>              (sdl2 rwops)
>              (sdl2 surface)
>              (sdl2 sdl))
>
> (define screen-width 640)
> (define screen-height 480)
> (define ball-size 20)
>
> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> (define ball-x-velocity (make-parameter 4))
> (define ball-y-velocity (make-parameter 4))
>
> (define (process-events)
>   (let loop ((event (SDL_PollEvent)))
>     (when event
>       (case (event-type event)
>         ((quit) #f)
>         (else (loop (SDL_PollEvent)))))))
>
> (define (update-ball)
>   (parameterize ((x (ball-x))
>                  (y (ball-y))
>                  (vx (ball-x-velocity))
>                  (vy (ball-y-velocity)))
>     (ball-x (+ x vx))
>     (ball-y (+ y vy))
>
>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>       (ball-x-velocity (- vx)))
>
>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>       (ball-y-velocity (- vy)))))
>
> (define (draw-ball renderer)
>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>     (SDL_SetRenderDrawColor renderer 255 0 0 255)
>     (SDL_RenderFillRect renderer ball-rect)))
>
> (define (main)
>   (SDL_Init +SDL_INIT_VIDEO+)
>   (let ((window (SDL_CreateWindow "Bouncing Ball"
> +SDL_WINDOWPOS_UNDEFINED+ +SDL_WINDOWPOS_UNDEFINED+ screen-width
> screen-height +SDL_WINDOW_SHOWN+))
>         (renderer (SDL_CreateRenderer window -1
> +SDL_RENDERER_ACCELERATED+)))
>     (SDL_SetRenderDrawColor renderer 0 0 0 255)
>     (let loop ()
>       (unless (process-events)
>         (update-ball)
>         (SDL_RenderClear renderer)
>         (draw-ball renderer)
>         (SDL_RenderPresent renderer)
>         (SDL_Delay 16)
>         (loop))
>     (SDL_DestroyRenderer renderer)
>     (SDL_DestroyWindow window)))
>
> (SDL_Quit)
> (main)
>
> Now, the program should run as expected:
>
> bash
>
> guile bouncing-ball.scm
>
> [image: mikael@djurfeldt.com]
> But all those SDL_ calls look like C bindings. Please use guile-sdl2
> bindings.
>
> I apologize for the confusion. Here's the bouncing ball program implemented
> using the Guile-SDL2 bindings:
>
> scheme
>
> (use-modules (sdl2)
>              (sdl2 video)
>              (sdl2 events)
>              (sdl2 timer)
>              (sdl2 rect)
>              (sdl2 rwops)
>              (sdl2 surface)
>              (sdl2 sdl))
>
> (define screen-width 640)
> (define screen-height 480)
> (define ball-size 20)
>
> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> (define ball-x-velocity (make-parameter 4))
> (define ball-y-velocity (make-parameter 4))
>
> (define (process-events)
>   (let loop ((event (poll-event)))
>     (when event
>       (case (event-type event)
>         ((quit) #f)
>         (else (loop (poll-event)))))))
>
> (define (update-ball)
>   (parameterize ((x (ball-x))
>                  (y (ball-y))
>                  (vx (ball-x-velocity))
>                  (vy (ball-y-velocity)))
>     (ball-x (+ x vx))
>     (ball-y (+ y vy))
>
>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>       (ball-x-velocity (- vx)))
>
>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>       (ball-y-velocity (- vy)))))
>
> (define (draw-ball renderer)
>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>     (set-render-draw-color! renderer 255 0 0 255)
>     (render-fill-rect! renderer ball-rect)))
>
> (define (main)
>   (init! +init-video+)
>   (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
> +window-pos-undefined+ screen-width screen-height +window-shown+))
>         (renderer (make-renderer window -1 +renderer-accelerated+)))
>     (set-render-draw-color! renderer 0 0 0 255)
>     (let loop ()
>       (unless (process-events)
>         (update-ball)
>         (render-clear! renderer)
>         (draw-ball renderer)
>         (render-present! renderer)
>         (delay 16)
>         (loop))
>     (destroy-renderer! renderer)
>     (destroy-window! window)))
>
> (quit!)
> (main)
>
> Now, the program should run as expected:
>
> bash
>
> guile bouncing-ball.scm
>
> ---
>
> Turns out there are multiple problems with that program also. Here I
> (mikael) fixed a number of problems and actually *got* a bouncing
> ball. :)
>
> (use-modules (sdl2)
>              (sdl2 video)
>              (sdl2 events)
>              ;(sdl2 timer)
>              (sdl2 rect)
>              ;(sdl2 rwops)
>              (sdl2 surface)
>                                         ;(sdl2 sdl)
>              (sdl2 render))
>
> (define screen-width 640)
> (define screen-height 480)
> (define ball-size 20)
>
> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> (define ball-x-velocity (make-parameter 4))
> (define ball-y-velocity (make-parameter 4))
>
> (define (process-events)
>   (let loop ((event (poll-event)))
>     (if event
>         (cond
>          ((quit-event? event) #t)
>          (else (loop (poll-event))))
>         #f)))
>
> (define (update-ball)
>   (let ((x (ball-x))
>         (y (ball-y))
>         (vx (ball-x-velocity))
>         (vy (ball-y-velocity)))
>     (ball-x (+ x vx))
>     (ball-y (+ y vy))
>
>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>       (ball-x-velocity (- vx)))
>
>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>       (ball-y-velocity (- vy)))))
>
> (define (draw-ball renderer)
>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>     (set-renderer-draw-color! renderer 255 0 0 255)
>     (render-fill-rect renderer ball-rect)))
>
> (define (main)
>   (sdl-init)
>   (let* ((window (make-window #:title "Bouncing Ball" #:size (list
> screen-width screen-height)))
>          (renderer (make-renderer window)))
>     (set-renderer-draw-color! renderer 0 0 0 255)
>     (let loop ()
>       (unless (process-events)
>         (update-ball)
>         (set-renderer-draw-color! renderer 0 0 0 0)
>         (clear-renderer renderer)
>         (draw-ball renderer)
>         (present-renderer renderer)
>                                         ;(delay 16)
>         (loop))
>     (delete-renderer! renderer)
>                                         ;(destroy-window! window)
>     )))
>
> ;(quit!)
> (main)
>

[-- Attachment #2: Type: text/html, Size: 23295 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-17 19:09   ` Damien Mattei
@ 2023-03-17 19:28     ` Damien Mattei
  2023-03-18  7:42       ` James Crake-Merani
  0 siblings, 1 reply; 19+ messages in thread
From: Damien Mattei @ 2023-03-17 19:28 UTC (permalink / raw)
  To: mikael; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 23271 bytes --]

finally i can reconnect to chatGPT server and here is the result:

(define (min-dnf expr)
  (let* ((vars (variables expr))
         (truth-table (generate-truth-table vars))
         (rows (filter (lambda (row) (eval expr (make-environment vars
row))) truth-table))
         (clauses (map (lambda (row) (create-clause vars row)) rows))
         (dnf (fold-right or #f clauses)))
    (simplify dnf)))

(define (variables expr)
  (let ((vars '()))
    (define (collect-variables exp)
      (cond ((symbol? exp) (unless (memq exp vars) (set! vars (cons exp
vars))))
            ((pair? exp) (map collect-variables exp))))
    (collect-variables expr)
    vars))

(define (generate-truth-table vars)
  (let ((n (length vars)))
    (map (lambda (i) (list->vector (reverse (map (lambda (b) (if b 1 0))
                                                  (reverse (binary i
n)))))) (range (expt 2 n)))))

(define (binary n bits)
  (let loop ((n n) (bits bits) (acc '()))
    (if (zero? bits) acc
        (let ((bit (remainder n 2)))
          (loop (quotient n 2) (- bits 1) (cons bit acc))))))

(define (create-clause vars row)
  (let ((clause '()))
    (define (create-term var value)
      (if value var (cons 'not (list var))))
    (map (lambda (pair) (set! clause (cons (create-term (car pair) (cdr
pair)) clause)))
         (map cons vars row))
    (reverse clause)))

(define (make-environment vars row)
  (let ((env '()))
    (map (lambda (pair) (set! env (cons pair env)))
         (map cons vars row))
    (reverse env)))

(define (simplify expr)
  (let ((simp (simplify-expr expr)))
    (if (eq? expr simp) expr (simplify simp))))

(define (simplify-expr expr)
  (cond ((symbol? expr) expr)
        ((and (pair? expr) (eq? (car expr) 'not) (pair? (cdr expr)))
         (let ((arg (simplify-expr (cadr expr))))
           (cond ((symbol? arg) (list 'not arg))
                 ((and (pair? arg) (eq? (car arg) 'not))
                  (simplify-expr (cadr arg)))
                 (else (list 'not arg))))))
        ((and (pair? expr) (memq (car expr) '(and or)))
         (let ((op (car expr))
               (args (map simplify-expr (cdr expr))))
           (let loop ((args args) (acc '()))
             (if (null? args)
                 (if (eq? op 'and) #t (fold-right or #f acc))
                 (let ((arg (car args)))
                   (if (eq? arg (if (eq? op 'and) #f #t))
                       (if (eq? op 'and) #f (fold-right or #f acc))
                       (loop (cdr args) (cons arg acc)))))))))
        (else expr)))

;;; /Users/mattei/chatGPTminimaldisjunctivenormalform.scm:6:26: source
expression failed to match any pattern in form or
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Syntax error:
unknown location: source expression failed to match any pattern in form or

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.

and my conclusion is chatGPT is a very bad student that does not know the
difference between a Scheme procedure and a special form :-)

and the 65lines chatGPT code is far from my > 5000 lines code to minimize
in disjunctive normal forms.......

but you will continue to read a lot of newspaper saying AI is able to write
programs....

chatGPT is only a "predictor of the next word" ,okay perheaps a bit more....

On Fri, Mar 17, 2023 at 8:09 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> i understand the fun thing... :-)
>
> and i did not check the program with Guile but asked a Racket version of
> the bouncing ball and it is full of errors even if i try to correct them by
> hand...
>
> Welcome to DrRacket, version 8.7 [cs].
> Language: racket/gui, with debugging; memory limit: 8192 MB.
> . . send: no such method
>   method name: register-event-callback
>   class name: canvas%
>
>
> after i asked this question to chatGPT:
>
> "Can you write a Guile Scheme program that put a logical expression in
> minimal disjunctive normal form?"
>
> i got a truncated program trying to code a QuineMcCluskey algorithm
> implementation that i can not redisplay here because i got a connection
> error to server and that looked like a bit,but from very very very far away
> my own logic code in github that i spend many years to wrote,
>
> and the Chat finished  like this:
>
> "Hmm...something seems to have gone wrong. Maybe try me again in a little
> bit"
>
> :-)
>
> Damien
>
> On Fri, Mar 17, 2023 at 6:26 PM Mikael Djurfeldt <mikael@djurfeldt.com>
> wrote:
>
>> Can you write a Guile Scheme program which displays a bouncing ball?
>>
>> As an AI language model, I cannot create a full graphical program directly
>> within this text-based environment. However, I can provide you with an
>> example of a simple bouncing ball simulation using the Guile Scheme
>> programming language and the SDL2 (Simple DirectMedia Layer) library,
>> which
>> is commonly used for creating graphical applications.
>>
>> To start, you'll need to have Guile and the Guile-SDL2 bindings installed.
>> The following instructions are for a Debian-based system:
>>
>>    1. Install Guile:
>>
>> csharp
>>
>> sudo apt-get install guile-2.2
>>
>>
>>    1. Install SDL2 development libraries:
>>
>> csharp
>>
>> sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
>>
>>
>>    1. Clone and build the Guile-SDL2 library:
>>
>> bash
>>
>> git clone https://github.com/davexunit/guile-sdl2.gitcd guile-sdl2
>> autoreconf -vif
>> ./configure
>> make
>> sudo make install
>>
>> Now you can create the bouncing ball program in a file called
>> bouncing-ball.scm:
>>
>> scheme
>>
>> (use-modules (sdl2)
>>              (sdl2 video)
>>              (sdl2 events)
>>              (sdl2 timer)
>>              (sdl2 rect))
>>
>> (define screen-width 640)
>> (define screen-height 480)
>> (define ball-size 20)
>>
>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>> (define ball-x-velocity (make-parameter 4))
>> (define ball-y-velocity (make-parameter 4))
>>
>> (define (process-events)
>>   (let loop ((event (poll-event)))
>>     (when event
>>       (case (event-type event)
>>         ((quit) #f)
>>         (else (loop (poll-event)))))))
>>
>> (define (update-ball)
>>   (parameterize ((x (ball-x))
>>                  (y (ball-y))
>>                  (vx (ball-x-velocity))
>>                  (vy (ball-y-velocity)))
>>     (ball-x (+ x vx))
>>     (ball-y (+ y vy))
>>
>>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>       (ball-x-velocity (- vx)))
>>
>>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>       (ball-y-velocity (- vy)))))
>>
>> (define (draw-ball renderer)
>>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>     (set-render-draw-color renderer 255 0 0 255)
>>     (render-fill-rect renderer ball-rect)))
>>
>> (define (main)
>>   (init! +init-video+)
>>   (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
>> +window-pos-undefined+ screen-width screen-height +window-shown+))
>>         (renderer (create-renderer window -1 +renderer-accelerated+)))
>>     (set-render-draw-color renderer 0 0 0 255)
>>     (let loop ()
>>       (unless (process-events)
>>         (update-ball)
>>         (render-clear renderer)
>>         (draw-ball renderer)
>>         (render-present renderer)
>>         (delay 16)
>>         (loop)))))
>>
>> (main)
>>
>> This example sets up a window using SDL2 and creates a simple ball that
>> bounces off the edges of the window. You can run the program using the
>> following command:
>>
>> bash
>>
>> guile bouncing-ball.scm
>>
>> Keep in mind that this is a simple example, and there are many ways to
>> improve or expand upon it, such as using images
>> [image: mikael@djurfeldt.com]
>> I get the following error message: ;;; note: auto-compilation is enabled,
>> set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to
>> disable. ;;; compiling /home/mdj/guile/bouncing-ball.scm ;;;
>> /home/mdj/guile/bouncing-ball.scm:19:13: warning: possibly unbound
>> variable
>> `event-type' ;;; /home/mdj/guile/bouncing-ball.scm:24:18: warning:
>> possibly
>> unbound variable `x' ;;; /home/mdj/guile/bouncing-ball.scm:25:18: warning:
>> possibly unbound variable `y' ;;; /home/mdj/guile/bouncing-ball.scm:26:18:
>> warning: possibly unbound variable `vx' ;;;
>> /home/mdj/guile/bouncing-ball.scm:27:18: warning: possibly unbound
>> variable
>> `vy' ;;; /home/mdj/guile/bouncing-ball.scm:39:5: warning: possibly unbound
>> variable `set-render-draw-color' ;;;
>> /home/mdj/guile/bouncing-ball.scm:40:5: warning: possibly unbound variable
>> `render-fill-rect' ;;; /home/mdj/guile/bouncing-ball.scm:43:3: warning:
>> possibly unbound variable `init!' ;;;
>> /home/mdj/guile/bouncing-ball.scm:43:9: warning: possibly unbound variable
>> `+init-video+' ;;; /home/mdj/guile/bouncing-ball.scm:44:17: warning:
>> possibly unbound variable `create-window' ;;;
>> /home/mdj/guile/bouncing-ball.scm:44:47: warning: possibly unbound
>> variable
>> `+window-pos-undefined+' ;;; /home/mdj/guile/bouncing-ball.scm:44:120:
>> warning: possibly unbound variable `+window-shown+' ;;;
>> /home/mdj/guile/bouncing-ball.scm:45:19: warning: possibly unbound
>> variable
>> `create-renderer' ;;; /home/mdj/guile/bouncing-ball.scm:45:35: warning:
>> possibly unbound variable `window' ;;;
>> /home/mdj/guile/bouncing-ball.scm:45:45: warning: possibly unbound
>> variable
>> `+renderer-accelerated+' ;;; /home/mdj/guile/bouncing-ball.scm:50:9:
>> warning: possibly unbound variable `render-clear' ;;;
>> /home/mdj/guile/bouncing-ball.scm:52:9: warning: possibly unbound variable
>> `render-present' ;;; compiled
>>
>> /home/mdj/.cache/guile/ccache/3.0-LE-8-4.6/home/mdj/guile/bouncing-ball.scm.go
>> Backtrace: In ice-9/boot-9.scm: 1752:10 6 (with-exception-handler _ _
>> #:unwind? _ # _) In unknown file: 5 (apply-smob/0 #<thunk 7f79f1cd8300>)
>> In
>> ice-9/boot-9.scm: 724:2 4 (call-with-prompt _ _ #<procedure
>> default-prompt-handle…>) In ice-9/eval.scm: 619:8 3 (_ #(#(#<directory
>> (guile-user) 7f79f1cdbc80>))) In ice-9/boot-9.scm: 2836:4 2
>> (save-module-excursion _) 4388:12 1 (_) In
>> /home/mdj/guile/bouncing-ball.scm: 43:3 0 (main)
>> /home/mdj/guile/bouncing-ball.scm:43:3: In procedure main: Unbound
>> variable: init!
>>
>> Apologies for the confusion. It seems I made a mistake in the provided
>> code, and some symbols were not correctly imported. Let's fix the imports
>> by using the appropriate modules and functions. Replace the (use-modules
>> ...) line in the code with the following:
>>
>> scheme
>>
>> (use-modules (sdl2) (sdl2 video) (sdl2 events) (sdl2 timer) (sdl2
>> rect) (sdl2 rwops) (sdl2 surface) (sdl2 sdl))
>>
>> Additionally, it seems that the init! function is not being recognized. It
>> should be SDL_Init instead. So, replace the line (init! +init-video+)
>> with:
>>
>> scheme
>>
>> (SDL_Init +SDL_INIT_VIDEO+)
>>
>> After making these changes, the updated bouncing-ball.scm should look like
>> this:
>>
>> scheme
>>
>> (use-modules (sdl2)
>>              (sdl2 video)
>>              (sdl2 events)
>>              (sdl2 timer)
>>              (sdl2 rect)
>>              (sdl2 rwops)
>>              (sdl2 surface)
>>              (sdl2 sdl))
>>
>> (define screen-width 640)
>> (define screen-height 480)
>> (define ball-size 20)
>>
>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>> (define ball-x-velocity (make-parameter 4))
>> (define ball-y-velocity (make-parameter 4))
>>
>> (define (process-events)
>>   (let loop ((event (poll-event)))
>>     (when event
>>       (case (event-type event)
>>         ((quit) #f)
>>         (else (loop (poll-event)))))))
>>
>> (define (update-ball)
>>   (parameterize ((x (ball-x))
>>                  (y (ball-y))
>>                  (vx (ball-x-velocity))
>>                  (vy (ball-y-velocity)))
>>     (ball-x (+ x vx))
>>     (ball-y (+ y vy))
>>
>>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>       (ball-x-velocity (- vx)))
>>
>>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>       (ball-y-velocity (- vy)))))
>>
>> (define (draw-ball renderer)
>>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>     (set-render-draw-color renderer 255 0 0 255)
>>     (render-fill-rect renderer ball-rect)))
>>
>> (define (main)
>>   (SDL_Init +SDL_INIT_VIDEO+)
>>   (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
>> +window-pos-undefined+ screen-width screen-height +window-shown+))
>>         (renderer (create-renderer window -1 +renderer-accelerated+)))
>>     (set-render-draw-color renderer 0 0 0 255)
>>     (let loop ()
>>       (unless (process-events)
>>         (update-ball)
>>         (render-clear renderer)
>>         (draw-ball renderer)
>>         (render-present renderer)
>>         (delay 16)
>>         (loop)))))
>>
>> (main)
>>
>> Now, the program should run without any issues. Run it with:
>>
>> bash
>>
>> guile bouncing-ball.scm
>>
>> [image: mikael@djurfeldt.com]
>> I think it should be make-window instead of create-window.
>>
>> You are correct. The function should be make-window instead of
>> create-window.
>> I apologize for the confusion. Here's the updated bouncing-ball.scm code
>> with the corrected function name:
>>
>> scheme
>>
>> (use-modules (sdl2)
>>              (sdl2 video)
>>              (sdl2 events)
>>              (sdl2 timer)
>>              (sdl2 rect)
>>              (sdl2 rwops)
>>              (sdl2 surface)
>>              (sdl2 sdl))
>>
>> (define screen-width 640)
>> (define screen-height 480)
>> (define ball-size 20)
>>
>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>> (define ball-x-velocity (make-parameter 4))
>> (define ball-y-velocity (make-parameter 4))
>>
>> (define (process-events)
>>   (let loop ((event (poll-event)))
>>     (when event
>>       (case (event-type event)
>>         ((quit) #f)
>>         (else (loop (poll-event)))))))
>>
>> (define (update-ball)
>>   (parameterize ((x (ball-x))
>>                  (y (ball-y))
>>                  (vx (ball-x-velocity))
>>                  (vy (ball-y-velocity)))
>>     (ball-x (+ x vx))
>>     (ball-y (+ y vy))
>>
>>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>       (ball-x-velocity (- vx)))
>>
>>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>       (ball-y-velocity (- vy)))))
>>
>> (define (draw-ball renderer)
>>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>     (set-render-draw-color renderer 255 0 0 255)
>>     (render-fill-rect renderer ball-rect)))
>>
>> (define (main)
>>   (SDL_Init +SDL_INIT_VIDEO+)
>>   (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
>> +window-pos-undefined+ screen-width screen-height +window-shown+))
>>         (renderer (create-renderer window -1 +renderer-accelerated+)))
>>     (set-render-draw-color renderer 0 0 0 255)
>>     (let loop ()
>>       (unless (process-events)
>>         (update-ball)
>>         (render-clear renderer)
>>         (draw-ball renderer)
>>         (render-present renderer)
>>         (delay 16)
>>         (loop)))))
>>
>> (main)
>>
>> Now, the program should run as expected:
>>
>> bash
>>
>> guile bouncing-ball.scm
>>
>> [image: mikael@djurfeldt.com]
>> Please write the program according to the guile-sdl2 manual.
>>
>> Apologies for the confusion. Here's an updated version of the bouncing
>> ball
>> program according to the guile-sdl2 manual:
>>
>> scheme
>>
>> (use-modules (sdl2)
>>              (sdl2 video)
>>              (sdl2 events)
>>              (sdl2 timer)
>>              (sdl2 rect)
>>              (sdl2 rwops)
>>              (sdl2 surface)
>>              (sdl2 sdl))
>>
>> (define screen-width 640)
>> (define screen-height 480)
>> (define ball-size 20)
>>
>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>> (define ball-x-velocity (make-parameter 4))
>> (define ball-y-velocity (make-parameter 4))
>>
>> (define (process-events)
>>   (let loop ((event (SDL_PollEvent)))
>>     (when event
>>       (case (event-type event)
>>         ((quit) #f)
>>         (else (loop (SDL_PollEvent)))))))
>>
>> (define (update-ball)
>>   (parameterize ((x (ball-x))
>>                  (y (ball-y))
>>                  (vx (ball-x-velocity))
>>                  (vy (ball-y-velocity)))
>>     (ball-x (+ x vx))
>>     (ball-y (+ y vy))
>>
>>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>       (ball-x-velocity (- vx)))
>>
>>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>       (ball-y-velocity (- vy)))))
>>
>> (define (draw-ball renderer)
>>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>     (SDL_SetRenderDrawColor renderer 255 0 0 255)
>>     (SDL_RenderFillRect renderer ball-rect)))
>>
>> (define (main)
>>   (SDL_Init +SDL_INIT_VIDEO+)
>>   (let ((window (SDL_CreateWindow "Bouncing Ball"
>> +SDL_WINDOWPOS_UNDEFINED+ +SDL_WINDOWPOS_UNDEFINED+ screen-width
>> screen-height +SDL_WINDOW_SHOWN+))
>>         (renderer (SDL_CreateRenderer window -1
>> +SDL_RENDERER_ACCELERATED+)))
>>     (SDL_SetRenderDrawColor renderer 0 0 0 255)
>>     (let loop ()
>>       (unless (process-events)
>>         (update-ball)
>>         (SDL_RenderClear renderer)
>>         (draw-ball renderer)
>>         (SDL_RenderPresent renderer)
>>         (SDL_Delay 16)
>>         (loop))
>>     (SDL_DestroyRenderer renderer)
>>     (SDL_DestroyWindow window)))
>>
>> (SDL_Quit)
>> (main)
>>
>> Now, the program should run as expected:
>>
>> bash
>>
>> guile bouncing-ball.scm
>>
>> [image: mikael@djurfeldt.com]
>> But all those SDL_ calls look like C bindings. Please use guile-sdl2
>> bindings.
>>
>> I apologize for the confusion. Here's the bouncing ball program
>> implemented
>> using the Guile-SDL2 bindings:
>>
>> scheme
>>
>> (use-modules (sdl2)
>>              (sdl2 video)
>>              (sdl2 events)
>>              (sdl2 timer)
>>              (sdl2 rect)
>>              (sdl2 rwops)
>>              (sdl2 surface)
>>              (sdl2 sdl))
>>
>> (define screen-width 640)
>> (define screen-height 480)
>> (define ball-size 20)
>>
>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>> (define ball-x-velocity (make-parameter 4))
>> (define ball-y-velocity (make-parameter 4))
>>
>> (define (process-events)
>>   (let loop ((event (poll-event)))
>>     (when event
>>       (case (event-type event)
>>         ((quit) #f)
>>         (else (loop (poll-event)))))))
>>
>> (define (update-ball)
>>   (parameterize ((x (ball-x))
>>                  (y (ball-y))
>>                  (vx (ball-x-velocity))
>>                  (vy (ball-y-velocity)))
>>     (ball-x (+ x vx))
>>     (ball-y (+ y vy))
>>
>>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>       (ball-x-velocity (- vx)))
>>
>>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>       (ball-y-velocity (- vy)))))
>>
>> (define (draw-ball renderer)
>>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>     (set-render-draw-color! renderer 255 0 0 255)
>>     (render-fill-rect! renderer ball-rect)))
>>
>> (define (main)
>>   (init! +init-video+)
>>   (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
>> +window-pos-undefined+ screen-width screen-height +window-shown+))
>>         (renderer (make-renderer window -1 +renderer-accelerated+)))
>>     (set-render-draw-color! renderer 0 0 0 255)
>>     (let loop ()
>>       (unless (process-events)
>>         (update-ball)
>>         (render-clear! renderer)
>>         (draw-ball renderer)
>>         (render-present! renderer)
>>         (delay 16)
>>         (loop))
>>     (destroy-renderer! renderer)
>>     (destroy-window! window)))
>>
>> (quit!)
>> (main)
>>
>> Now, the program should run as expected:
>>
>> bash
>>
>> guile bouncing-ball.scm
>>
>> ---
>>
>> Turns out there are multiple problems with that program also. Here I
>> (mikael) fixed a number of problems and actually *got* a bouncing
>> ball. :)
>>
>> (use-modules (sdl2)
>>              (sdl2 video)
>>              (sdl2 events)
>>              ;(sdl2 timer)
>>              (sdl2 rect)
>>              ;(sdl2 rwops)
>>              (sdl2 surface)
>>                                         ;(sdl2 sdl)
>>              (sdl2 render))
>>
>> (define screen-width 640)
>> (define screen-height 480)
>> (define ball-size 20)
>>
>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>> (define ball-x-velocity (make-parameter 4))
>> (define ball-y-velocity (make-parameter 4))
>>
>> (define (process-events)
>>   (let loop ((event (poll-event)))
>>     (if event
>>         (cond
>>          ((quit-event? event) #t)
>>          (else (loop (poll-event))))
>>         #f)))
>>
>> (define (update-ball)
>>   (let ((x (ball-x))
>>         (y (ball-y))
>>         (vx (ball-x-velocity))
>>         (vy (ball-y-velocity)))
>>     (ball-x (+ x vx))
>>     (ball-y (+ y vy))
>>
>>     (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>       (ball-x-velocity (- vx)))
>>
>>     (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>       (ball-y-velocity (- vy)))))
>>
>> (define (draw-ball renderer)
>>   (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>     (set-renderer-draw-color! renderer 255 0 0 255)
>>     (render-fill-rect renderer ball-rect)))
>>
>> (define (main)
>>   (sdl-init)
>>   (let* ((window (make-window #:title "Bouncing Ball" #:size (list
>> screen-width screen-height)))
>>          (renderer (make-renderer window)))
>>     (set-renderer-draw-color! renderer 0 0 0 255)
>>     (let loop ()
>>       (unless (process-events)
>>         (update-ball)
>>         (set-renderer-draw-color! renderer 0 0 0 0)
>>         (clear-renderer renderer)
>>         (draw-ball renderer)
>>         (present-renderer renderer)
>>                                         ;(delay 16)
>>         (loop))
>>     (delete-renderer! renderer)
>>                                         ;(destroy-window! window)
>>     )))
>>
>> ;(quit!)
>> (main)
>>
>

[-- Attachment #2: Type: text/html, Size: 28252 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-17 19:28     ` Damien Mattei
@ 2023-03-18  7:42       ` James Crake-Merani
  2023-03-18  8:10         ` Mikael Djurfeldt
  2023-03-18  8:29         ` tomas
  0 siblings, 2 replies; 19+ messages in thread
From: James Crake-Merani @ 2023-03-18  7:42 UTC (permalink / raw)
  To: guile-user

Hi,

I think some students think that ChatGPT is this magical AI which can do 
their work for them, when in reality ChatGPT is really poor at writing 
code. According to the paper on ChatGPT 4[1], in easy Leetcode 
challenges, ChatGPT 4 does decently although 3.5 still does poorly with 
a score of 12/41 compared to 4's 31/41. However, when the difficulty was 
increased, ChatGPT only got 21/80 on the medium Leetcode, and a measly 
4/45 on the hard Leetcode. Results are even worse with ChatGPT 3.5, with 
it getting 8/80 on the medium challenges, and nothing on the hard 
challenges.

Anecdotally, one of my friends at university prompted it to write some 
code in Java. It started to come out with Python code. But that's 
alright, because the first line had 'import java'. Unfortunately, my 
friend had cut it off before it got any further so we didn't get to see 
what it came out with.

I think, at least for now, that our jobs are safe. I suspect 
potentially, AI like ChatGPT could help automate more trivial tasks so 
the humans can be left just with the tasks that are done best by humans. 
But at the moment, while ChatGPT has made improvements in this regard, 
it is still too erroneous to be used for even that purpose.

James Crake-Merani.

[1]: https://openai.com/research/gpt-4 (click 'read paper' for the 
actual paper.)

On 17/03/2023 19:28, Damien Mattei wrote:
> finally i can reconnect to chatGPT server and here is the result:
>
> (define (min-dnf expr)
>    (let* ((vars (variables expr))
>           (truth-table (generate-truth-table vars))
>           (rows (filter (lambda (row) (eval expr (make-environment vars
> row))) truth-table))
>           (clauses (map (lambda (row) (create-clause vars row)) rows))
>           (dnf (fold-right or #f clauses)))
>      (simplify dnf)))
>
> (define (variables expr)
>    (let ((vars '()))
>      (define (collect-variables exp)
>        (cond ((symbol? exp) (unless (memq exp vars) (set! vars (cons exp
> vars))))
>              ((pair? exp) (map collect-variables exp))))
>      (collect-variables expr)
>      vars))
>
> (define (generate-truth-table vars)
>    (let ((n (length vars)))
>      (map (lambda (i) (list->vector (reverse (map (lambda (b) (if b 1 0))
>                                                    (reverse (binary i
> n)))))) (range (expt 2 n)))))
>
> (define (binary n bits)
>    (let loop ((n n) (bits bits) (acc '()))
>      (if (zero? bits) acc
>          (let ((bit (remainder n 2)))
>            (loop (quotient n 2) (- bits 1) (cons bit acc))))))
>
> (define (create-clause vars row)
>    (let ((clause '()))
>      (define (create-term var value)
>        (if value var (cons 'not (list var))))
>      (map (lambda (pair) (set! clause (cons (create-term (car pair) (cdr
> pair)) clause)))
>           (map cons vars row))
>      (reverse clause)))
>
> (define (make-environment vars row)
>    (let ((env '()))
>      (map (lambda (pair) (set! env (cons pair env)))
>           (map cons vars row))
>      (reverse env)))
>
> (define (simplify expr)
>    (let ((simp (simplify-expr expr)))
>      (if (eq? expr simp) expr (simplify simp))))
>
> (define (simplify-expr expr)
>    (cond ((symbol? expr) expr)
>          ((and (pair? expr) (eq? (car expr) 'not) (pair? (cdr expr)))
>           (let ((arg (simplify-expr (cadr expr))))
>             (cond ((symbol? arg) (list 'not arg))
>                   ((and (pair? arg) (eq? (car arg) 'not))
>                    (simplify-expr (cadr arg)))
>                   (else (list 'not arg))))))
>          ((and (pair? expr) (memq (car expr) '(and or)))
>           (let ((op (car expr))
>                 (args (map simplify-expr (cdr expr))))
>             (let loop ((args args) (acc '()))
>               (if (null? args)
>                   (if (eq? op 'and) #t (fold-right or #f acc))
>                   (let ((arg (car args)))
>                     (if (eq? arg (if (eq? op 'and) #f #t))
>                         (if (eq? op 'and) #f (fold-right or #f acc))
>                         (loop (cdr args) (cons arg acc)))))))))
>          (else expr)))
>
> ;;; /Users/mattei/chatGPTminimaldisjunctivenormalform.scm:6:26: source
> expression failed to match any pattern in form or
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Syntax error:
> unknown location: source expression failed to match any pattern in form or
>
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
>
> and my conclusion is chatGPT is a very bad student that does not know the
> difference between a Scheme procedure and a special form :-)
>
> and the 65lines chatGPT code is far from my > 5000 lines code to minimize
> in disjunctive normal forms.......
>
> but you will continue to read a lot of newspaper saying AI is able to write
> programs....
>
> chatGPT is only a "predictor of the next word" ,okay perheaps a bit more....
>
> On Fri, Mar 17, 2023 at 8:09 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> i understand the fun thing... :-)
>>
>> and i did not check the program with Guile but asked a Racket version of
>> the bouncing ball and it is full of errors even if i try to correct them by
>> hand...
>>
>> Welcome to DrRacket, version 8.7 [cs].
>> Language: racket/gui, with debugging; memory limit: 8192 MB.
>> . . send: no such method
>>    method name: register-event-callback
>>    class name: canvas%
>>
>>
>> after i asked this question to chatGPT:
>>
>> "Can you write a Guile Scheme program that put a logical expression in
>> minimal disjunctive normal form?"
>>
>> i got a truncated program trying to code a QuineMcCluskey algorithm
>> implementation that i can not redisplay here because i got a connection
>> error to server and that looked like a bit,but from very very very far away
>> my own logic code in github that i spend many years to wrote,
>>
>> and the Chat finished  like this:
>>
>> "Hmm...something seems to have gone wrong. Maybe try me again in a little
>> bit"
>>
>> :-)
>>
>> Damien
>>
>> On Fri, Mar 17, 2023 at 6:26 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>> wrote:
>>
>>> Can you write a Guile Scheme program which displays a bouncing ball?
>>>
>>> As an AI language model, I cannot create a full graphical program directly
>>> within this text-based environment. However, I can provide you with an
>>> example of a simple bouncing ball simulation using the Guile Scheme
>>> programming language and the SDL2 (Simple DirectMedia Layer) library,
>>> which
>>> is commonly used for creating graphical applications.
>>>
>>> To start, you'll need to have Guile and the Guile-SDL2 bindings installed.
>>> The following instructions are for a Debian-based system:
>>>
>>>     1. Install Guile:
>>>
>>> csharp
>>>
>>> sudo apt-get install guile-2.2
>>>
>>>
>>>     1. Install SDL2 development libraries:
>>>
>>> csharp
>>>
>>> sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
>>>
>>>
>>>     1. Clone and build the Guile-SDL2 library:
>>>
>>> bash
>>>
>>> git clone https://github.com/davexunit/guile-sdl2.gitcd guile-sdl2
>>> autoreconf -vif
>>> ./configure
>>> make
>>> sudo make install
>>>
>>> Now you can create the bouncing ball program in a file called
>>> bouncing-ball.scm:
>>>
>>> scheme
>>>
>>> (use-modules (sdl2)
>>>               (sdl2 video)
>>>               (sdl2 events)
>>>               (sdl2 timer)
>>>               (sdl2 rect))
>>>
>>> (define screen-width 640)
>>> (define screen-height 480)
>>> (define ball-size 20)
>>>
>>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>>> (define ball-x-velocity (make-parameter 4))
>>> (define ball-y-velocity (make-parameter 4))
>>>
>>> (define (process-events)
>>>    (let loop ((event (poll-event)))
>>>      (when event
>>>        (case (event-type event)
>>>          ((quit) #f)
>>>          (else (loop (poll-event)))))))
>>>
>>> (define (update-ball)
>>>    (parameterize ((x (ball-x))
>>>                   (y (ball-y))
>>>                   (vx (ball-x-velocity))
>>>                   (vy (ball-y-velocity)))
>>>      (ball-x (+ x vx))
>>>      (ball-y (+ y vy))
>>>
>>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>>        (ball-x-velocity (- vx)))
>>>
>>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>>        (ball-y-velocity (- vy)))))
>>>
>>> (define (draw-ball renderer)
>>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>>      (set-render-draw-color renderer 255 0 0 255)
>>>      (render-fill-rect renderer ball-rect)))
>>>
>>> (define (main)
>>>    (init! +init-video+)
>>>    (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
>>> +window-pos-undefined+ screen-width screen-height +window-shown+))
>>>          (renderer (create-renderer window -1 +renderer-accelerated+)))
>>>      (set-render-draw-color renderer 0 0 0 255)
>>>      (let loop ()
>>>        (unless (process-events)
>>>          (update-ball)
>>>          (render-clear renderer)
>>>          (draw-ball renderer)
>>>          (render-present renderer)
>>>          (delay 16)
>>>          (loop)))))
>>>
>>> (main)
>>>
>>> This example sets up a window using SDL2 and creates a simple ball that
>>> bounces off the edges of the window. You can run the program using the
>>> following command:
>>>
>>> bash
>>>
>>> guile bouncing-ball.scm
>>>
>>> Keep in mind that this is a simple example, and there are many ways to
>>> improve or expand upon it, such as using images
>>> [image: mikael@djurfeldt.com]
>>> I get the following error message: ;;; note: auto-compilation is enabled,
>>> set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to
>>> disable. ;;; compiling /home/mdj/guile/bouncing-ball.scm ;;;
>>> /home/mdj/guile/bouncing-ball.scm:19:13: warning: possibly unbound
>>> variable
>>> `event-type' ;;; /home/mdj/guile/bouncing-ball.scm:24:18: warning:
>>> possibly
>>> unbound variable `x' ;;; /home/mdj/guile/bouncing-ball.scm:25:18: warning:
>>> possibly unbound variable `y' ;;; /home/mdj/guile/bouncing-ball.scm:26:18:
>>> warning: possibly unbound variable `vx' ;;;
>>> /home/mdj/guile/bouncing-ball.scm:27:18: warning: possibly unbound
>>> variable
>>> `vy' ;;; /home/mdj/guile/bouncing-ball.scm:39:5: warning: possibly unbound
>>> variable `set-render-draw-color' ;;;
>>> /home/mdj/guile/bouncing-ball.scm:40:5: warning: possibly unbound variable
>>> `render-fill-rect' ;;; /home/mdj/guile/bouncing-ball.scm:43:3: warning:
>>> possibly unbound variable `init!' ;;;
>>> /home/mdj/guile/bouncing-ball.scm:43:9: warning: possibly unbound variable
>>> `+init-video+' ;;; /home/mdj/guile/bouncing-ball.scm:44:17: warning:
>>> possibly unbound variable `create-window' ;;;
>>> /home/mdj/guile/bouncing-ball.scm:44:47: warning: possibly unbound
>>> variable
>>> `+window-pos-undefined+' ;;; /home/mdj/guile/bouncing-ball.scm:44:120:
>>> warning: possibly unbound variable `+window-shown+' ;;;
>>> /home/mdj/guile/bouncing-ball.scm:45:19: warning: possibly unbound
>>> variable
>>> `create-renderer' ;;; /home/mdj/guile/bouncing-ball.scm:45:35: warning:
>>> possibly unbound variable `window' ;;;
>>> /home/mdj/guile/bouncing-ball.scm:45:45: warning: possibly unbound
>>> variable
>>> `+renderer-accelerated+' ;;; /home/mdj/guile/bouncing-ball.scm:50:9:
>>> warning: possibly unbound variable `render-clear' ;;;
>>> /home/mdj/guile/bouncing-ball.scm:52:9: warning: possibly unbound variable
>>> `render-present' ;;; compiled
>>>
>>> /home/mdj/.cache/guile/ccache/3.0-LE-8-4.6/home/mdj/guile/bouncing-ball.scm.go
>>> Backtrace: In ice-9/boot-9.scm: 1752:10 6 (with-exception-handler _ _
>>> #:unwind? _ # _) In unknown file: 5 (apply-smob/0 #<thunk 7f79f1cd8300>)
>>> In
>>> ice-9/boot-9.scm: 724:2 4 (call-with-prompt _ _ #<procedure
>>> default-prompt-handle…>) In ice-9/eval.scm: 619:8 3 (_ #(#(#<directory
>>> (guile-user) 7f79f1cdbc80>))) In ice-9/boot-9.scm: 2836:4 2
>>> (save-module-excursion _) 4388:12 1 (_) In
>>> /home/mdj/guile/bouncing-ball.scm: 43:3 0 (main)
>>> /home/mdj/guile/bouncing-ball.scm:43:3: In procedure main: Unbound
>>> variable: init!
>>>
>>> Apologies for the confusion. It seems I made a mistake in the provided
>>> code, and some symbols were not correctly imported. Let's fix the imports
>>> by using the appropriate modules and functions. Replace the (use-modules
>>> ...) line in the code with the following:
>>>
>>> scheme
>>>
>>> (use-modules (sdl2) (sdl2 video) (sdl2 events) (sdl2 timer) (sdl2
>>> rect) (sdl2 rwops) (sdl2 surface) (sdl2 sdl))
>>>
>>> Additionally, it seems that the init! function is not being recognized. It
>>> should be SDL_Init instead. So, replace the line (init! +init-video+)
>>> with:
>>>
>>> scheme
>>>
>>> (SDL_Init +SDL_INIT_VIDEO+)
>>>
>>> After making these changes, the updated bouncing-ball.scm should look like
>>> this:
>>>
>>> scheme
>>>
>>> (use-modules (sdl2)
>>>               (sdl2 video)
>>>               (sdl2 events)
>>>               (sdl2 timer)
>>>               (sdl2 rect)
>>>               (sdl2 rwops)
>>>               (sdl2 surface)
>>>               (sdl2 sdl))
>>>
>>> (define screen-width 640)
>>> (define screen-height 480)
>>> (define ball-size 20)
>>>
>>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>>> (define ball-x-velocity (make-parameter 4))
>>> (define ball-y-velocity (make-parameter 4))
>>>
>>> (define (process-events)
>>>    (let loop ((event (poll-event)))
>>>      (when event
>>>        (case (event-type event)
>>>          ((quit) #f)
>>>          (else (loop (poll-event)))))))
>>>
>>> (define (update-ball)
>>>    (parameterize ((x (ball-x))
>>>                   (y (ball-y))
>>>                   (vx (ball-x-velocity))
>>>                   (vy (ball-y-velocity)))
>>>      (ball-x (+ x vx))
>>>      (ball-y (+ y vy))
>>>
>>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>>        (ball-x-velocity (- vx)))
>>>
>>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>>        (ball-y-velocity (- vy)))))
>>>
>>> (define (draw-ball renderer)
>>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>>      (set-render-draw-color renderer 255 0 0 255)
>>>      (render-fill-rect renderer ball-rect)))
>>>
>>> (define (main)
>>>    (SDL_Init +SDL_INIT_VIDEO+)
>>>    (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
>>> +window-pos-undefined+ screen-width screen-height +window-shown+))
>>>          (renderer (create-renderer window -1 +renderer-accelerated+)))
>>>      (set-render-draw-color renderer 0 0 0 255)
>>>      (let loop ()
>>>        (unless (process-events)
>>>          (update-ball)
>>>          (render-clear renderer)
>>>          (draw-ball renderer)
>>>          (render-present renderer)
>>>          (delay 16)
>>>          (loop)))))
>>>
>>> (main)
>>>
>>> Now, the program should run without any issues. Run it with:
>>>
>>> bash
>>>
>>> guile bouncing-ball.scm
>>>
>>> [image: mikael@djurfeldt.com]
>>> I think it should be make-window instead of create-window.
>>>
>>> You are correct. The function should be make-window instead of
>>> create-window.
>>> I apologize for the confusion. Here's the updated bouncing-ball.scm code
>>> with the corrected function name:
>>>
>>> scheme
>>>
>>> (use-modules (sdl2)
>>>               (sdl2 video)
>>>               (sdl2 events)
>>>               (sdl2 timer)
>>>               (sdl2 rect)
>>>               (sdl2 rwops)
>>>               (sdl2 surface)
>>>               (sdl2 sdl))
>>>
>>> (define screen-width 640)
>>> (define screen-height 480)
>>> (define ball-size 20)
>>>
>>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>>> (define ball-x-velocity (make-parameter 4))
>>> (define ball-y-velocity (make-parameter 4))
>>>
>>> (define (process-events)
>>>    (let loop ((event (poll-event)))
>>>      (when event
>>>        (case (event-type event)
>>>          ((quit) #f)
>>>          (else (loop (poll-event)))))))
>>>
>>> (define (update-ball)
>>>    (parameterize ((x (ball-x))
>>>                   (y (ball-y))
>>>                   (vx (ball-x-velocity))
>>>                   (vy (ball-y-velocity)))
>>>      (ball-x (+ x vx))
>>>      (ball-y (+ y vy))
>>>
>>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>>        (ball-x-velocity (- vx)))
>>>
>>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>>        (ball-y-velocity (- vy)))))
>>>
>>> (define (draw-ball renderer)
>>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>>      (set-render-draw-color renderer 255 0 0 255)
>>>      (render-fill-rect renderer ball-rect)))
>>>
>>> (define (main)
>>>    (SDL_Init +SDL_INIT_VIDEO+)
>>>    (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
>>> +window-pos-undefined+ screen-width screen-height +window-shown+))
>>>          (renderer (create-renderer window -1 +renderer-accelerated+)))
>>>      (set-render-draw-color renderer 0 0 0 255)
>>>      (let loop ()
>>>        (unless (process-events)
>>>          (update-ball)
>>>          (render-clear renderer)
>>>          (draw-ball renderer)
>>>          (render-present renderer)
>>>          (delay 16)
>>>          (loop)))))
>>>
>>> (main)
>>>
>>> Now, the program should run as expected:
>>>
>>> bash
>>>
>>> guile bouncing-ball.scm
>>>
>>> [image: mikael@djurfeldt.com]
>>> Please write the program according to the guile-sdl2 manual.
>>>
>>> Apologies for the confusion. Here's an updated version of the bouncing
>>> ball
>>> program according to the guile-sdl2 manual:
>>>
>>> scheme
>>>
>>> (use-modules (sdl2)
>>>               (sdl2 video)
>>>               (sdl2 events)
>>>               (sdl2 timer)
>>>               (sdl2 rect)
>>>               (sdl2 rwops)
>>>               (sdl2 surface)
>>>               (sdl2 sdl))
>>>
>>> (define screen-width 640)
>>> (define screen-height 480)
>>> (define ball-size 20)
>>>
>>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>>> (define ball-x-velocity (make-parameter 4))
>>> (define ball-y-velocity (make-parameter 4))
>>>
>>> (define (process-events)
>>>    (let loop ((event (SDL_PollEvent)))
>>>      (when event
>>>        (case (event-type event)
>>>          ((quit) #f)
>>>          (else (loop (SDL_PollEvent)))))))
>>>
>>> (define (update-ball)
>>>    (parameterize ((x (ball-x))
>>>                   (y (ball-y))
>>>                   (vx (ball-x-velocity))
>>>                   (vy (ball-y-velocity)))
>>>      (ball-x (+ x vx))
>>>      (ball-y (+ y vy))
>>>
>>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>>        (ball-x-velocity (- vx)))
>>>
>>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>>        (ball-y-velocity (- vy)))))
>>>
>>> (define (draw-ball renderer)
>>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>>      (SDL_SetRenderDrawColor renderer 255 0 0 255)
>>>      (SDL_RenderFillRect renderer ball-rect)))
>>>
>>> (define (main)
>>>    (SDL_Init +SDL_INIT_VIDEO+)
>>>    (let ((window (SDL_CreateWindow "Bouncing Ball"
>>> +SDL_WINDOWPOS_UNDEFINED+ +SDL_WINDOWPOS_UNDEFINED+ screen-width
>>> screen-height +SDL_WINDOW_SHOWN+))
>>>          (renderer (SDL_CreateRenderer window -1
>>> +SDL_RENDERER_ACCELERATED+)))
>>>      (SDL_SetRenderDrawColor renderer 0 0 0 255)
>>>      (let loop ()
>>>        (unless (process-events)
>>>          (update-ball)
>>>          (SDL_RenderClear renderer)
>>>          (draw-ball renderer)
>>>          (SDL_RenderPresent renderer)
>>>          (SDL_Delay 16)
>>>          (loop))
>>>      (SDL_DestroyRenderer renderer)
>>>      (SDL_DestroyWindow window)))
>>>
>>> (SDL_Quit)
>>> (main)
>>>
>>> Now, the program should run as expected:
>>>
>>> bash
>>>
>>> guile bouncing-ball.scm
>>>
>>> [image: mikael@djurfeldt.com]
>>> But all those SDL_ calls look like C bindings. Please use guile-sdl2
>>> bindings.
>>>
>>> I apologize for the confusion. Here's the bouncing ball program
>>> implemented
>>> using the Guile-SDL2 bindings:
>>>
>>> scheme
>>>
>>> (use-modules (sdl2)
>>>               (sdl2 video)
>>>               (sdl2 events)
>>>               (sdl2 timer)
>>>               (sdl2 rect)
>>>               (sdl2 rwops)
>>>               (sdl2 surface)
>>>               (sdl2 sdl))
>>>
>>> (define screen-width 640)
>>> (define screen-height 480)
>>> (define ball-size 20)
>>>
>>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>>> (define ball-x-velocity (make-parameter 4))
>>> (define ball-y-velocity (make-parameter 4))
>>>
>>> (define (process-events)
>>>    (let loop ((event (poll-event)))
>>>      (when event
>>>        (case (event-type event)
>>>          ((quit) #f)
>>>          (else (loop (poll-event)))))))
>>>
>>> (define (update-ball)
>>>    (parameterize ((x (ball-x))
>>>                   (y (ball-y))
>>>                   (vx (ball-x-velocity))
>>>                   (vy (ball-y-velocity)))
>>>      (ball-x (+ x vx))
>>>      (ball-y (+ y vy))
>>>
>>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>>        (ball-x-velocity (- vx)))
>>>
>>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>>        (ball-y-velocity (- vy)))))
>>>
>>> (define (draw-ball renderer)
>>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>>      (set-render-draw-color! renderer 255 0 0 255)
>>>      (render-fill-rect! renderer ball-rect)))
>>>
>>> (define (main)
>>>    (init! +init-video+)
>>>    (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
>>> +window-pos-undefined+ screen-width screen-height +window-shown+))
>>>          (renderer (make-renderer window -1 +renderer-accelerated+)))
>>>      (set-render-draw-color! renderer 0 0 0 255)
>>>      (let loop ()
>>>        (unless (process-events)
>>>          (update-ball)
>>>          (render-clear! renderer)
>>>          (draw-ball renderer)
>>>          (render-present! renderer)
>>>          (delay 16)
>>>          (loop))
>>>      (destroy-renderer! renderer)
>>>      (destroy-window! window)))
>>>
>>> (quit!)
>>> (main)
>>>
>>> Now, the program should run as expected:
>>>
>>> bash
>>>
>>> guile bouncing-ball.scm
>>>
>>> ---
>>>
>>> Turns out there are multiple problems with that program also. Here I
>>> (mikael) fixed a number of problems and actually *got* a bouncing
>>> ball. :)
>>>
>>> (use-modules (sdl2)
>>>               (sdl2 video)
>>>               (sdl2 events)
>>>               ;(sdl2 timer)
>>>               (sdl2 rect)
>>>               ;(sdl2 rwops)
>>>               (sdl2 surface)
>>>                                          ;(sdl2 sdl)
>>>               (sdl2 render))
>>>
>>> (define screen-width 640)
>>> (define screen-height 480)
>>> (define ball-size 20)
>>>
>>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
>>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
>>> (define ball-x-velocity (make-parameter 4))
>>> (define ball-y-velocity (make-parameter 4))
>>>
>>> (define (process-events)
>>>    (let loop ((event (poll-event)))
>>>      (if event
>>>          (cond
>>>           ((quit-event? event) #t)
>>>           (else (loop (poll-event))))
>>>          #f)))
>>>
>>> (define (update-ball)
>>>    (let ((x (ball-x))
>>>          (y (ball-y))
>>>          (vx (ball-x-velocity))
>>>          (vy (ball-y-velocity)))
>>>      (ball-x (+ x vx))
>>>      (ball-y (+ y vy))
>>>
>>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
>>>        (ball-x-velocity (- vx)))
>>>
>>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
>>>        (ball-y-velocity (- vy)))))
>>>
>>> (define (draw-ball renderer)
>>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
>>>      (set-renderer-draw-color! renderer 255 0 0 255)
>>>      (render-fill-rect renderer ball-rect)))
>>>
>>> (define (main)
>>>    (sdl-init)
>>>    (let* ((window (make-window #:title "Bouncing Ball" #:size (list
>>> screen-width screen-height)))
>>>           (renderer (make-renderer window)))
>>>      (set-renderer-draw-color! renderer 0 0 0 255)
>>>      (let loop ()
>>>        (unless (process-events)
>>>          (update-ball)
>>>          (set-renderer-draw-color! renderer 0 0 0 0)
>>>          (clear-renderer renderer)
>>>          (draw-ball renderer)
>>>          (present-renderer renderer)
>>>                                          ;(delay 16)
>>>          (loop))
>>>      (delete-renderer! renderer)
>>>                                          ;(destroy-window! window)
>>>      )))
>>>
>>> ;(quit!)
>>> (main)
>>>



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-18  7:42       ` James Crake-Merani
@ 2023-03-18  8:10         ` Mikael Djurfeldt
  2023-03-18  8:29         ` tomas
  1 sibling, 0 replies; 19+ messages in thread
From: Mikael Djurfeldt @ 2023-03-18  8:10 UTC (permalink / raw)
  To: James Crake-Merani; +Cc: guile-user, Mikael Djurfeldt

Hi James, I agree with most of what you say.

What I find amazing, though, is that a comparably simple network
architecture can still be so capable. It shows the power of the large
volume of training data. After all, it is a large portion of the part of
human culture that is exposed on the internet. It is in this direction that
GPT-4 has capabilities that I think not even the developers at OpenAI have
fully explored. Together with a friend, we have discussed concepts in art
and physics with it, and it can be truly useful and enlightening.

Already at this level, it will likely be revolutionizing to society.

At the same time, it is "just" a text prediction engine. Of course, if you
later complete it with other stuff similar to what we have in our heads,
like working memory plus a range of other components, well, then it will be
interesting.

Here's a commentary in Nature:

https://www.nature.com/articles/d41586-023-00816-5

Best regards,
Mikael

On Sat, Mar 18, 2023 at 8:53 AM James Crake-Merani <james@jamescm.co.uk>
wrote:

> Hi,
>
> I think some students think that ChatGPT is this magical AI which can do
> their work for them, when in reality ChatGPT is really poor at writing
> code. According to the paper on ChatGPT 4[1], in easy Leetcode
> challenges, ChatGPT 4 does decently although 3.5 still does poorly with
> a score of 12/41 compared to 4's 31/41. However, when the difficulty was
> increased, ChatGPT only got 21/80 on the medium Leetcode, and a measly
> 4/45 on the hard Leetcode. Results are even worse with ChatGPT 3.5, with
> it getting 8/80 on the medium challenges, and nothing on the hard
> challenges.
>
> Anecdotally, one of my friends at university prompted it to write some
> code in Java. It started to come out with Python code. But that's
> alright, because the first line had 'import java'. Unfortunately, my
> friend had cut it off before it got any further so we didn't get to see
> what it came out with.
>
> I think, at least for now, that our jobs are safe. I suspect
> potentially, AI like ChatGPT could help automate more trivial tasks so
> the humans can be left just with the tasks that are done best by humans.
> But at the moment, while ChatGPT has made improvements in this regard,
> it is still too erroneous to be used for even that purpose.
>
> James Crake-Merani.
>
> [1]: https://openai.com/research/gpt-4 (click 'read paper' for the
> actual paper.)
>
> On 17/03/2023 19:28, Damien Mattei wrote:
> > finally i can reconnect to chatGPT server and here is the result:
> >
> > (define (min-dnf expr)
> >    (let* ((vars (variables expr))
> >           (truth-table (generate-truth-table vars))
> >           (rows (filter (lambda (row) (eval expr (make-environment vars
> > row))) truth-table))
> >           (clauses (map (lambda (row) (create-clause vars row)) rows))
> >           (dnf (fold-right or #f clauses)))
> >      (simplify dnf)))
> >
> > (define (variables expr)
> >    (let ((vars '()))
> >      (define (collect-variables exp)
> >        (cond ((symbol? exp) (unless (memq exp vars) (set! vars (cons exp
> > vars))))
> >              ((pair? exp) (map collect-variables exp))))
> >      (collect-variables expr)
> >      vars))
> >
> > (define (generate-truth-table vars)
> >    (let ((n (length vars)))
> >      (map (lambda (i) (list->vector (reverse (map (lambda (b) (if b 1 0))
> >                                                    (reverse (binary i
> > n)))))) (range (expt 2 n)))))
> >
> > (define (binary n bits)
> >    (let loop ((n n) (bits bits) (acc '()))
> >      (if (zero? bits) acc
> >          (let ((bit (remainder n 2)))
> >            (loop (quotient n 2) (- bits 1) (cons bit acc))))))
> >
> > (define (create-clause vars row)
> >    (let ((clause '()))
> >      (define (create-term var value)
> >        (if value var (cons 'not (list var))))
> >      (map (lambda (pair) (set! clause (cons (create-term (car pair) (cdr
> > pair)) clause)))
> >           (map cons vars row))
> >      (reverse clause)))
> >
> > (define (make-environment vars row)
> >    (let ((env '()))
> >      (map (lambda (pair) (set! env (cons pair env)))
> >           (map cons vars row))
> >      (reverse env)))
> >
> > (define (simplify expr)
> >    (let ((simp (simplify-expr expr)))
> >      (if (eq? expr simp) expr (simplify simp))))
> >
> > (define (simplify-expr expr)
> >    (cond ((symbol? expr) expr)
> >          ((and (pair? expr) (eq? (car expr) 'not) (pair? (cdr expr)))
> >           (let ((arg (simplify-expr (cadr expr))))
> >             (cond ((symbol? arg) (list 'not arg))
> >                   ((and (pair? arg) (eq? (car arg) 'not))
> >                    (simplify-expr (cadr arg)))
> >                   (else (list 'not arg))))))
> >          ((and (pair? expr) (memq (car expr) '(and or)))
> >           (let ((op (car expr))
> >                 (args (map simplify-expr (cdr expr))))
> >             (let loop ((args args) (acc '()))
> >               (if (null? args)
> >                   (if (eq? op 'and) #t (fold-right or #f acc))
> >                   (let ((arg (car args)))
> >                     (if (eq? arg (if (eq? op 'and) #f #t))
> >                         (if (eq? op 'and) #f (fold-right or #f acc))
> >                         (loop (cdr args) (cons arg acc)))))))))
> >          (else expr)))
> >
> > ;;; /Users/mattei/chatGPTminimaldisjunctivenormalform.scm:6:26: source
> > expression failed to match any pattern in form or
> > ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> > Syntax error:
> > unknown location: source expression failed to match any pattern in form
> or
> >
> > Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> >
> > and my conclusion is chatGPT is a very bad student that does not know the
> > difference between a Scheme procedure and a special form :-)
> >
> > and the 65lines chatGPT code is far from my > 5000 lines code to minimize
> > in disjunctive normal forms.......
> >
> > but you will continue to read a lot of newspaper saying AI is able to
> write
> > programs....
> >
> > chatGPT is only a "predictor of the next word" ,okay perheaps a bit
> more....
> >
> > On Fri, Mar 17, 2023 at 8:09 PM Damien Mattei <damien.mattei@gmail.com>
> > wrote:
> >
> >> i understand the fun thing... :-)
> >>
> >> and i did not check the program with Guile but asked a Racket version of
> >> the bouncing ball and it is full of errors even if i try to correct
> them by
> >> hand...
> >>
> >> Welcome to DrRacket, version 8.7 [cs].
> >> Language: racket/gui, with debugging; memory limit: 8192 MB.
> >> . . send: no such method
> >>    method name: register-event-callback
> >>    class name: canvas%
> >>
> >>
> >> after i asked this question to chatGPT:
> >>
> >> "Can you write a Guile Scheme program that put a logical expression in
> >> minimal disjunctive normal form?"
> >>
> >> i got a truncated program trying to code a QuineMcCluskey algorithm
> >> implementation that i can not redisplay here because i got a connection
> >> error to server and that looked like a bit,but from very very very far
> away
> >> my own logic code in github that i spend many years to wrote,
> >>
> >> and the Chat finished  like this:
> >>
> >> "Hmm...something seems to have gone wrong. Maybe try me again in a
> little
> >> bit"
> >>
> >> :-)
> >>
> >> Damien
> >>
> >> On Fri, Mar 17, 2023 at 6:26 PM Mikael Djurfeldt <mikael@djurfeldt.com>
> >> wrote:
> >>
> >>> Can you write a Guile Scheme program which displays a bouncing ball?
> >>>
> >>> As an AI language model, I cannot create a full graphical program
> directly
> >>> within this text-based environment. However, I can provide you with an
> >>> example of a simple bouncing ball simulation using the Guile Scheme
> >>> programming language and the SDL2 (Simple DirectMedia Layer) library,
> >>> which
> >>> is commonly used for creating graphical applications.
> >>>
> >>> To start, you'll need to have Guile and the Guile-SDL2 bindings
> installed.
> >>> The following instructions are for a Debian-based system:
> >>>
> >>>     1. Install Guile:
> >>>
> >>> csharp
> >>>
> >>> sudo apt-get install guile-2.2
> >>>
> >>>
> >>>     1. Install SDL2 development libraries:
> >>>
> >>> csharp
> >>>
> >>> sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
> >>>
> >>>
> >>>     1. Clone and build the Guile-SDL2 library:
> >>>
> >>> bash
> >>>
> >>> git clone https://github.com/davexunit/guile-sdl2.gitcd guile-sdl2
> >>> autoreconf -vif
> >>> ./configure
> >>> make
> >>> sudo make install
> >>>
> >>> Now you can create the bouncing ball program in a file called
> >>> bouncing-ball.scm:
> >>>
> >>> scheme
> >>>
> >>> (use-modules (sdl2)
> >>>               (sdl2 video)
> >>>               (sdl2 events)
> >>>               (sdl2 timer)
> >>>               (sdl2 rect))
> >>>
> >>> (define screen-width 640)
> >>> (define screen-height 480)
> >>> (define ball-size 20)
> >>>
> >>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> >>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> >>> (define ball-x-velocity (make-parameter 4))
> >>> (define ball-y-velocity (make-parameter 4))
> >>>
> >>> (define (process-events)
> >>>    (let loop ((event (poll-event)))
> >>>      (when event
> >>>        (case (event-type event)
> >>>          ((quit) #f)
> >>>          (else (loop (poll-event)))))))
> >>>
> >>> (define (update-ball)
> >>>    (parameterize ((x (ball-x))
> >>>                   (y (ball-y))
> >>>                   (vx (ball-x-velocity))
> >>>                   (vy (ball-y-velocity)))
> >>>      (ball-x (+ x vx))
> >>>      (ball-y (+ y vy))
> >>>
> >>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
> >>>        (ball-x-velocity (- vx)))
> >>>
> >>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
> >>>        (ball-y-velocity (- vy)))))
> >>>
> >>> (define (draw-ball renderer)
> >>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
> >>>      (set-render-draw-color renderer 255 0 0 255)
> >>>      (render-fill-rect renderer ball-rect)))
> >>>
> >>> (define (main)
> >>>    (init! +init-video+)
> >>>    (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
> >>> +window-pos-undefined+ screen-width screen-height +window-shown+))
> >>>          (renderer (create-renderer window -1 +renderer-accelerated+)))
> >>>      (set-render-draw-color renderer 0 0 0 255)
> >>>      (let loop ()
> >>>        (unless (process-events)
> >>>          (update-ball)
> >>>          (render-clear renderer)
> >>>          (draw-ball renderer)
> >>>          (render-present renderer)
> >>>          (delay 16)
> >>>          (loop)))))
> >>>
> >>> (main)
> >>>
> >>> This example sets up a window using SDL2 and creates a simple ball that
> >>> bounces off the edges of the window. You can run the program using the
> >>> following command:
> >>>
> >>> bash
> >>>
> >>> guile bouncing-ball.scm
> >>>
> >>> Keep in mind that this is a simple example, and there are many ways to
> >>> improve or expand upon it, such as using images
> >>> [image: mikael@djurfeldt.com]
> >>> I get the following error message: ;;; note: auto-compilation is
> enabled,
> >>> set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to
> >>> disable. ;;; compiling /home/mdj/guile/bouncing-ball.scm ;;;
> >>> /home/mdj/guile/bouncing-ball.scm:19:13: warning: possibly unbound
> >>> variable
> >>> `event-type' ;;; /home/mdj/guile/bouncing-ball.scm:24:18: warning:
> >>> possibly
> >>> unbound variable `x' ;;; /home/mdj/guile/bouncing-ball.scm:25:18:
> warning:
> >>> possibly unbound variable `y' ;;;
> /home/mdj/guile/bouncing-ball.scm:26:18:
> >>> warning: possibly unbound variable `vx' ;;;
> >>> /home/mdj/guile/bouncing-ball.scm:27:18: warning: possibly unbound
> >>> variable
> >>> `vy' ;;; /home/mdj/guile/bouncing-ball.scm:39:5: warning: possibly
> unbound
> >>> variable `set-render-draw-color' ;;;
> >>> /home/mdj/guile/bouncing-ball.scm:40:5: warning: possibly unbound
> variable
> >>> `render-fill-rect' ;;; /home/mdj/guile/bouncing-ball.scm:43:3: warning:
> >>> possibly unbound variable `init!' ;;;
> >>> /home/mdj/guile/bouncing-ball.scm:43:9: warning: possibly unbound
> variable
> >>> `+init-video+' ;;; /home/mdj/guile/bouncing-ball.scm:44:17: warning:
> >>> possibly unbound variable `create-window' ;;;
> >>> /home/mdj/guile/bouncing-ball.scm:44:47: warning: possibly unbound
> >>> variable
> >>> `+window-pos-undefined+' ;;; /home/mdj/guile/bouncing-ball.scm:44:120:
> >>> warning: possibly unbound variable `+window-shown+' ;;;
> >>> /home/mdj/guile/bouncing-ball.scm:45:19: warning: possibly unbound
> >>> variable
> >>> `create-renderer' ;;; /home/mdj/guile/bouncing-ball.scm:45:35: warning:
> >>> possibly unbound variable `window' ;;;
> >>> /home/mdj/guile/bouncing-ball.scm:45:45: warning: possibly unbound
> >>> variable
> >>> `+renderer-accelerated+' ;;; /home/mdj/guile/bouncing-ball.scm:50:9:
> >>> warning: possibly unbound variable `render-clear' ;;;
> >>> /home/mdj/guile/bouncing-ball.scm:52:9: warning: possibly unbound
> variable
> >>> `render-present' ;;; compiled
> >>>
> >>>
> /home/mdj/.cache/guile/ccache/3.0-LE-8-4.6/home/mdj/guile/bouncing-ball.scm.go
> >>> Backtrace: In ice-9/boot-9.scm: 1752:10 6 (with-exception-handler _ _
> >>> #:unwind? _ # _) In unknown file: 5 (apply-smob/0 #<thunk
> 7f79f1cd8300>)
> >>> In
> >>> ice-9/boot-9.scm: 724:2 4 (call-with-prompt _ _ #<procedure
> >>> default-prompt-handle…>) In ice-9/eval.scm: 619:8 3 (_ #(#(#<directory
> >>> (guile-user) 7f79f1cdbc80>))) In ice-9/boot-9.scm: 2836:4 2
> >>> (save-module-excursion _) 4388:12 1 (_) In
> >>> /home/mdj/guile/bouncing-ball.scm: 43:3 0 (main)
> >>> /home/mdj/guile/bouncing-ball.scm:43:3: In procedure main: Unbound
> >>> variable: init!
> >>>
> >>> Apologies for the confusion. It seems I made a mistake in the provided
> >>> code, and some symbols were not correctly imported. Let's fix the
> imports
> >>> by using the appropriate modules and functions. Replace the
> (use-modules
> >>> ...) line in the code with the following:
> >>>
> >>> scheme
> >>>
> >>> (use-modules (sdl2) (sdl2 video) (sdl2 events) (sdl2 timer) (sdl2
> >>> rect) (sdl2 rwops) (sdl2 surface) (sdl2 sdl))
> >>>
> >>> Additionally, it seems that the init! function is not being
> recognized. It
> >>> should be SDL_Init instead. So, replace the line (init! +init-video+)
> >>> with:
> >>>
> >>> scheme
> >>>
> >>> (SDL_Init +SDL_INIT_VIDEO+)
> >>>
> >>> After making these changes, the updated bouncing-ball.scm should look
> like
> >>> this:
> >>>
> >>> scheme
> >>>
> >>> (use-modules (sdl2)
> >>>               (sdl2 video)
> >>>               (sdl2 events)
> >>>               (sdl2 timer)
> >>>               (sdl2 rect)
> >>>               (sdl2 rwops)
> >>>               (sdl2 surface)
> >>>               (sdl2 sdl))
> >>>
> >>> (define screen-width 640)
> >>> (define screen-height 480)
> >>> (define ball-size 20)
> >>>
> >>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> >>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> >>> (define ball-x-velocity (make-parameter 4))
> >>> (define ball-y-velocity (make-parameter 4))
> >>>
> >>> (define (process-events)
> >>>    (let loop ((event (poll-event)))
> >>>      (when event
> >>>        (case (event-type event)
> >>>          ((quit) #f)
> >>>          (else (loop (poll-event)))))))
> >>>
> >>> (define (update-ball)
> >>>    (parameterize ((x (ball-x))
> >>>                   (y (ball-y))
> >>>                   (vx (ball-x-velocity))
> >>>                   (vy (ball-y-velocity)))
> >>>      (ball-x (+ x vx))
> >>>      (ball-y (+ y vy))
> >>>
> >>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
> >>>        (ball-x-velocity (- vx)))
> >>>
> >>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
> >>>        (ball-y-velocity (- vy)))))
> >>>
> >>> (define (draw-ball renderer)
> >>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
> >>>      (set-render-draw-color renderer 255 0 0 255)
> >>>      (render-fill-rect renderer ball-rect)))
> >>>
> >>> (define (main)
> >>>    (SDL_Init +SDL_INIT_VIDEO+)
> >>>    (let ((window (create-window "Bouncing Ball" +window-pos-undefined+
> >>> +window-pos-undefined+ screen-width screen-height +window-shown+))
> >>>          (renderer (create-renderer window -1 +renderer-accelerated+)))
> >>>      (set-render-draw-color renderer 0 0 0 255)
> >>>      (let loop ()
> >>>        (unless (process-events)
> >>>          (update-ball)
> >>>          (render-clear renderer)
> >>>          (draw-ball renderer)
> >>>          (render-present renderer)
> >>>          (delay 16)
> >>>          (loop)))))
> >>>
> >>> (main)
> >>>
> >>> Now, the program should run without any issues. Run it with:
> >>>
> >>> bash
> >>>
> >>> guile bouncing-ball.scm
> >>>
> >>> [image: mikael@djurfeldt.com]
> >>> I think it should be make-window instead of create-window.
> >>>
> >>> You are correct. The function should be make-window instead of
> >>> create-window.
> >>> I apologize for the confusion. Here's the updated bouncing-ball.scm
> code
> >>> with the corrected function name:
> >>>
> >>> scheme
> >>>
> >>> (use-modules (sdl2)
> >>>               (sdl2 video)
> >>>               (sdl2 events)
> >>>               (sdl2 timer)
> >>>               (sdl2 rect)
> >>>               (sdl2 rwops)
> >>>               (sdl2 surface)
> >>>               (sdl2 sdl))
> >>>
> >>> (define screen-width 640)
> >>> (define screen-height 480)
> >>> (define ball-size 20)
> >>>
> >>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> >>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> >>> (define ball-x-velocity (make-parameter 4))
> >>> (define ball-y-velocity (make-parameter 4))
> >>>
> >>> (define (process-events)
> >>>    (let loop ((event (poll-event)))
> >>>      (when event
> >>>        (case (event-type event)
> >>>          ((quit) #f)
> >>>          (else (loop (poll-event)))))))
> >>>
> >>> (define (update-ball)
> >>>    (parameterize ((x (ball-x))
> >>>                   (y (ball-y))
> >>>                   (vx (ball-x-velocity))
> >>>                   (vy (ball-y-velocity)))
> >>>      (ball-x (+ x vx))
> >>>      (ball-y (+ y vy))
> >>>
> >>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
> >>>        (ball-x-velocity (- vx)))
> >>>
> >>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
> >>>        (ball-y-velocity (- vy)))))
> >>>
> >>> (define (draw-ball renderer)
> >>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
> >>>      (set-render-draw-color renderer 255 0 0 255)
> >>>      (render-fill-rect renderer ball-rect)))
> >>>
> >>> (define (main)
> >>>    (SDL_Init +SDL_INIT_VIDEO+)
> >>>    (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
> >>> +window-pos-undefined+ screen-width screen-height +window-shown+))
> >>>          (renderer (create-renderer window -1 +renderer-accelerated+)))
> >>>      (set-render-draw-color renderer 0 0 0 255)
> >>>      (let loop ()
> >>>        (unless (process-events)
> >>>          (update-ball)
> >>>          (render-clear renderer)
> >>>          (draw-ball renderer)
> >>>          (render-present renderer)
> >>>          (delay 16)
> >>>          (loop)))))
> >>>
> >>> (main)
> >>>
> >>> Now, the program should run as expected:
> >>>
> >>> bash
> >>>
> >>> guile bouncing-ball.scm
> >>>
> >>> [image: mikael@djurfeldt.com]
> >>> Please write the program according to the guile-sdl2 manual.
> >>>
> >>> Apologies for the confusion. Here's an updated version of the bouncing
> >>> ball
> >>> program according to the guile-sdl2 manual:
> >>>
> >>> scheme
> >>>
> >>> (use-modules (sdl2)
> >>>               (sdl2 video)
> >>>               (sdl2 events)
> >>>               (sdl2 timer)
> >>>               (sdl2 rect)
> >>>               (sdl2 rwops)
> >>>               (sdl2 surface)
> >>>               (sdl2 sdl))
> >>>
> >>> (define screen-width 640)
> >>> (define screen-height 480)
> >>> (define ball-size 20)
> >>>
> >>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> >>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> >>> (define ball-x-velocity (make-parameter 4))
> >>> (define ball-y-velocity (make-parameter 4))
> >>>
> >>> (define (process-events)
> >>>    (let loop ((event (SDL_PollEvent)))
> >>>      (when event
> >>>        (case (event-type event)
> >>>          ((quit) #f)
> >>>          (else (loop (SDL_PollEvent)))))))
> >>>
> >>> (define (update-ball)
> >>>    (parameterize ((x (ball-x))
> >>>                   (y (ball-y))
> >>>                   (vx (ball-x-velocity))
> >>>                   (vy (ball-y-velocity)))
> >>>      (ball-x (+ x vx))
> >>>      (ball-y (+ y vy))
> >>>
> >>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
> >>>        (ball-x-velocity (- vx)))
> >>>
> >>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
> >>>        (ball-y-velocity (- vy)))))
> >>>
> >>> (define (draw-ball renderer)
> >>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
> >>>      (SDL_SetRenderDrawColor renderer 255 0 0 255)
> >>>      (SDL_RenderFillRect renderer ball-rect)))
> >>>
> >>> (define (main)
> >>>    (SDL_Init +SDL_INIT_VIDEO+)
> >>>    (let ((window (SDL_CreateWindow "Bouncing Ball"
> >>> +SDL_WINDOWPOS_UNDEFINED+ +SDL_WINDOWPOS_UNDEFINED+ screen-width
> >>> screen-height +SDL_WINDOW_SHOWN+))
> >>>          (renderer (SDL_CreateRenderer window -1
> >>> +SDL_RENDERER_ACCELERATED+)))
> >>>      (SDL_SetRenderDrawColor renderer 0 0 0 255)
> >>>      (let loop ()
> >>>        (unless (process-events)
> >>>          (update-ball)
> >>>          (SDL_RenderClear renderer)
> >>>          (draw-ball renderer)
> >>>          (SDL_RenderPresent renderer)
> >>>          (SDL_Delay 16)
> >>>          (loop))
> >>>      (SDL_DestroyRenderer renderer)
> >>>      (SDL_DestroyWindow window)))
> >>>
> >>> (SDL_Quit)
> >>> (main)
> >>>
> >>> Now, the program should run as expected:
> >>>
> >>> bash
> >>>
> >>> guile bouncing-ball.scm
> >>>
> >>> [image: mikael@djurfeldt.com]
> >>> But all those SDL_ calls look like C bindings. Please use guile-sdl2
> >>> bindings.
> >>>
> >>> I apologize for the confusion. Here's the bouncing ball program
> >>> implemented
> >>> using the Guile-SDL2 bindings:
> >>>
> >>> scheme
> >>>
> >>> (use-modules (sdl2)
> >>>               (sdl2 video)
> >>>               (sdl2 events)
> >>>               (sdl2 timer)
> >>>               (sdl2 rect)
> >>>               (sdl2 rwops)
> >>>               (sdl2 surface)
> >>>               (sdl2 sdl))
> >>>
> >>> (define screen-width 640)
> >>> (define screen-height 480)
> >>> (define ball-size 20)
> >>>
> >>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> >>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> >>> (define ball-x-velocity (make-parameter 4))
> >>> (define ball-y-velocity (make-parameter 4))
> >>>
> >>> (define (process-events)
> >>>    (let loop ((event (poll-event)))
> >>>      (when event
> >>>        (case (event-type event)
> >>>          ((quit) #f)
> >>>          (else (loop (poll-event)))))))
> >>>
> >>> (define (update-ball)
> >>>    (parameterize ((x (ball-x))
> >>>                   (y (ball-y))
> >>>                   (vx (ball-x-velocity))
> >>>                   (vy (ball-y-velocity)))
> >>>      (ball-x (+ x vx))
> >>>      (ball-y (+ y vy))
> >>>
> >>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
> >>>        (ball-x-velocity (- vx)))
> >>>
> >>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
> >>>        (ball-y-velocity (- vy)))))
> >>>
> >>> (define (draw-ball renderer)
> >>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
> >>>      (set-render-draw-color! renderer 255 0 0 255)
> >>>      (render-fill-rect! renderer ball-rect)))
> >>>
> >>> (define (main)
> >>>    (init! +init-video+)
> >>>    (let ((window (make-window "Bouncing Ball" +window-pos-undefined+
> >>> +window-pos-undefined+ screen-width screen-height +window-shown+))
> >>>          (renderer (make-renderer window -1 +renderer-accelerated+)))
> >>>      (set-render-draw-color! renderer 0 0 0 255)
> >>>      (let loop ()
> >>>        (unless (process-events)
> >>>          (update-ball)
> >>>          (render-clear! renderer)
> >>>          (draw-ball renderer)
> >>>          (render-present! renderer)
> >>>          (delay 16)
> >>>          (loop))
> >>>      (destroy-renderer! renderer)
> >>>      (destroy-window! window)))
> >>>
> >>> (quit!)
> >>> (main)
> >>>
> >>> Now, the program should run as expected:
> >>>
> >>> bash
> >>>
> >>> guile bouncing-ball.scm
> >>>
> >>> ---
> >>>
> >>> Turns out there are multiple problems with that program also. Here I
> >>> (mikael) fixed a number of problems and actually *got* a bouncing
> >>> ball. :)
> >>>
> >>> (use-modules (sdl2)
> >>>               (sdl2 video)
> >>>               (sdl2 events)
> >>>               ;(sdl2 timer)
> >>>               (sdl2 rect)
> >>>               ;(sdl2 rwops)
> >>>               (sdl2 surface)
> >>>                                          ;(sdl2 sdl)
> >>>               (sdl2 render))
> >>>
> >>> (define screen-width 640)
> >>> (define screen-height 480)
> >>> (define ball-size 20)
> >>>
> >>> (define ball-x (make-parameter (/ (- screen-width ball-size) 2)))
> >>> (define ball-y (make-parameter (/ (- screen-height ball-size) 2)))
> >>> (define ball-x-velocity (make-parameter 4))
> >>> (define ball-y-velocity (make-parameter 4))
> >>>
> >>> (define (process-events)
> >>>    (let loop ((event (poll-event)))
> >>>      (if event
> >>>          (cond
> >>>           ((quit-event? event) #t)
> >>>           (else (loop (poll-event))))
> >>>          #f)))
> >>>
> >>> (define (update-ball)
> >>>    (let ((x (ball-x))
> >>>          (y (ball-y))
> >>>          (vx (ball-x-velocity))
> >>>          (vy (ball-y-velocity)))
> >>>      (ball-x (+ x vx))
> >>>      (ball-y (+ y vy))
> >>>
> >>>      (when (or (<= (+ x vx) 0) (>= (+ x vx ball-size) screen-width))
> >>>        (ball-x-velocity (- vx)))
> >>>
> >>>      (when (or (<= (+ y vy) 0) (>= (+ y vy ball-size) screen-height))
> >>>        (ball-y-velocity (- vy)))))
> >>>
> >>> (define (draw-ball renderer)
> >>>    (let ((ball-rect (make-rect (ball-x) (ball-y) ball-size ball-size)))
> >>>      (set-renderer-draw-color! renderer 255 0 0 255)
> >>>      (render-fill-rect renderer ball-rect)))
> >>>
> >>> (define (main)
> >>>    (sdl-init)
> >>>    (let* ((window (make-window #:title "Bouncing Ball" #:size (list
> >>> screen-width screen-height)))
> >>>           (renderer (make-renderer window)))
> >>>      (set-renderer-draw-color! renderer 0 0 0 255)
> >>>      (let loop ()
> >>>        (unless (process-events)
> >>>          (update-ball)
> >>>          (set-renderer-draw-color! renderer 0 0 0 0)
> >>>          (clear-renderer renderer)
> >>>          (draw-ball renderer)
> >>>          (present-renderer renderer)
> >>>                                          ;(delay 16)
> >>>          (loop))
> >>>      (delete-renderer! renderer)
> >>>                                          ;(destroy-window! window)
> >>>      )))
> >>>
> >>> ;(quit!)
> >>> (main)
> >>>
>
>


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-18  7:42       ` James Crake-Merani
  2023-03-18  8:10         ` Mikael Djurfeldt
@ 2023-03-18  8:29         ` tomas
  2023-03-18 10:52           ` James Crake-Merani
  1 sibling, 1 reply; 19+ messages in thread
From: tomas @ 2023-03-18  8:29 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]

On Sat, Mar 18, 2023 at 07:42:15AM +0000, James Crake-Merani wrote:
> Hi,

[...]

> I think, at least for now, that our jobs are safe.

My fears are not that much about our jobs. Rather about people
believing the marketing hype. There are already enough life
changing decisions taken by such crude, intransparent and
borderline criminal tools, be it ad serving, consumable pricing,
access to housing & healthcare, bank credit, you name it.

> I suspect potentially, AI
> like ChatGPT could help automate more trivial tasks so the humans can be
> left just with the tasks that are done best by humans. But at the moment,
> while ChatGPT has made improvements in this regard, it is still too
> erroneous to be used for even that purpose.

This is basically what Shoshana Zuboff wrote back in 1988 ("In the
Age of the Smart Machine" [1]). Now go look at what she wrote 2019
("The Age_of_Surveillance_Capitalism" [2] [2a]).

My take is that such potentially society-shattering technologies
don't belong in the hands of corporations which have no choice
but to maximize their return on investment. But perhaps that's me.

Cheers

[1] https://en.wikipedia.org/wiki/Shoshana_Zuboff#In_the_Age_of_the_Smart_Machine
[2] https://en.wikipedia.org/wiki/Shoshana_Zuboff#Surveillance_capitalism
[2a] https://en.wikipedia.org/wiki/The_Age_of_Surveillance_Capitalism
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
       [not found]                   ` <CAA2Xvw+pTXC2RO-epuiV-+ChaNWzrdQ4n_ATwutkQ3n7sq5GBw@mail.gmail.com>
@ 2023-03-18  9:23                     ` Damien Mattei
  0 siblings, 0 replies; 19+ messages in thread
From: Damien Mattei @ 2023-03-18  9:23 UTC (permalink / raw)
  To: mikael; +Cc: tomas, guile-devel, guile-user

[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]

chatGPT is using the "static" 2021 free data available on internet ,free
databases,...  it knows poorly after 2021 as "they" say.

Without the human intelligence that has create all the data chatGPT can do
nothing.

Now people use chatGPT to create poor quality data stored on the  internet
web page instead of making the web page content by intelligent humans. In
the next release of chatGPT it will use those new "poor data" in its
training data set  to deliver answers of lesser quality again.

On Sat, Mar 18, 2023 at 10:03 AM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> On Sat, Mar 18, 2023 at 9:58 AM Mikael Djurfeldt <mikael@djurfeldt.com>
> wrote:
>
>> On Sat, Mar 18, 2023 at 9:46 AM <tomas@tuxteam.de> wrote:
>>
>>> On Sat, Mar 18, 2023 at 09:41:37AM +0100, Mikael Djurfeldt wrote:
>>> > On Sat, Mar 18, 2023 at 9:36 AM <tomas@tuxteam.de> wrote:
>>>
>>> [...]
>>>
>>> > > Perhaps you didn't know, but you are training the model :-)
>>> > >
>>> >
>>> > Unfortunately not. I'm prompting it within its 32000 token (GPT-4)
>>> > attention span. Next conversation the model is back to exactly the same
>>> > state again. Then, of course, it is possible that OpenAI chooses to
>>> filter
>>> > out something from the dialogs it has had.
>>>
>>> You don't think that those coversations end up as raw data for the
>>> next model? I'd be surprised, but you know definitely more than me.
>>>
>>
>> I know very little apart from knowing what deep learning is and having
>> skimmed the "Attention is all you need"-paper. I only meant that you are
>> not training the model during and between sessions. It is certainly
>> possible that OpenAI filters out things from the dialogs to use as part of
>> training for the next version. They warn you that they may take data from
>> the dialogs. If and how they do that I don't know.
>>
>
> Or, as GPT-4 would phrase it: I apologize for the confusion in my previous
> answer. You may be right that I'm training the next version of the model. :)
>
>

[-- Attachment #2: Type: text/html, Size: 3307 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-18  8:29         ` tomas
@ 2023-03-18 10:52           ` James Crake-Merani
  2023-03-18 12:00             ` Mikael Djurfeldt
  0 siblings, 1 reply; 19+ messages in thread
From: James Crake-Merani @ 2023-03-18 10:52 UTC (permalink / raw)
  To: guile-user

On 18/03/2023 08:29, tomas@tuxteam.de wrote:

> My take is that such potentially society-shattering technologies
> don't belong in the hands of corporations which have no choice
> but to maximize their return on investment. But perhaps that's me.

Yes, I find it concerning that this technology is owned by OpenAI which 
is a for profit company. Because, as you say, for profit companies are 
not necessarily interested in the societal benefits that new technology 
brings along but rather the profits that can be made off this technology.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-18 10:52           ` James Crake-Merani
@ 2023-03-18 12:00             ` Mikael Djurfeldt
  2023-03-18 12:03               ` Mikael Djurfeldt
  0 siblings, 1 reply; 19+ messages in thread
From: Mikael Djurfeldt @ 2023-03-18 12:00 UTC (permalink / raw)
  To: James Crake-Merani; +Cc: guile-user, Mikael Djurfeldt

On Sat, Mar 18, 2023 at 11:53 AM James Crake-Merani <james@jamescm.co.uk>
wrote:

> On 18/03/2023 08:29, tomas@tuxteam.de wrote:
>
> > My take is that such potentially society-shattering technologies
> > don't belong in the hands of corporations which have no choice
> > but to maximize their return on investment. But perhaps that's me.
>
> Yes, I find it concerning that this technology is owned by OpenAI which
> is a for profit company. Because, as you say, for profit companies are
> not necessarily interested in the societal benefits that new technology
> brings along but rather the profits that can be made off this technology.
>

One problem with trying to preserve freedom wrt AI is that training on
large data requires a lot of computational resources. It would be nice if
there were some kind of non-profit organization ("FreeAI"?) where people
who want free AI pool their resources. I guess in this case it can't be
financed the same way as Wikipedia but there would have to be a
subscription fee.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-18 12:00             ` Mikael Djurfeldt
@ 2023-03-18 12:03               ` Mikael Djurfeldt
  2023-03-19  8:42                 ` tomas
  0 siblings, 1 reply; 19+ messages in thread
From: Mikael Djurfeldt @ 2023-03-18 12:03 UTC (permalink / raw)
  To: James Crake-Merani; +Cc: guile-user

On Sat, Mar 18, 2023 at 1:00 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> On Sat, Mar 18, 2023 at 11:53 AM James Crake-Merani <james@jamescm.co.uk>
> wrote:
>
>> On 18/03/2023 08:29, tomas@tuxteam.de wrote:
>>
>> > My take is that such potentially society-shattering technologies
>> > don't belong in the hands of corporations which have no choice
>> > but to maximize their return on investment. But perhaps that's me.
>>
>> Yes, I find it concerning that this technology is owned by OpenAI which
>> is a for profit company. Because, as you say, for profit companies are
>> not necessarily interested in the societal benefits that new technology
>> brings along but rather the profits that can be made off this technology.
>>
>
> One problem with trying to preserve freedom wrt AI is that training on
> large data requires a lot of computational resources. It would be nice if
> there were some kind of non-profit organization ("FreeAI"?) where people
> who want free AI pool their resources. I guess in this case it can't be
> financed the same way as Wikipedia but there would have to be a
> subscription fee.
>

The original intention of OpenAI was somewhat in that direction, right?
Then came Microsoft...

"Free" is not the same thing as "open" and in some cases "open" is "closed".


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-18 12:03               ` Mikael Djurfeldt
@ 2023-03-19  8:42                 ` tomas
  2023-03-19 23:18                   ` Dr. Arne Babenhauserheide
  0 siblings, 1 reply; 19+ messages in thread
From: tomas @ 2023-03-19  8:42 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 2613 bytes --]

On Sat, Mar 18, 2023 at 01:03:33PM +0100, Mikael Djurfeldt wrote:
> On Sat, Mar 18, 2023 at 1:00 PM Mikael Djurfeldt <mikael@djurfeldt.com>
> wrote:
> 
> > On Sat, Mar 18, 2023 at 11:53 AM James Crake-Merani <james@jamescm.co.uk>
> > wrote:
> >
> >> On 18/03/2023 08:29, tomas@tuxteam.de wrote:
> >>
> >> > My take is that such potentially society-shattering technologies
> >> > don't belong in the hands of corporations which have no choice
> >> > but to maximize their return on investment. But perhaps that's me.
> >>
> >> Yes, I find it concerning that this technology is owned by OpenAI which
> >> is a for profit company. Because, as you say, for profit companies are
> >> not necessarily interested in the societal benefits that new technology
> >> brings along but rather the profits that can be made off this technology.

I think it's even more evil: the imperative to return on investment
leads them to do damage to society whenever there's money in it.

The examples of social networks floating hate speech and harmful
behaviours, spying and social influencing companies the likes of
Cambridge Analytica (now Emerdata), Palantir, the NSO Group (of
Pegasus fame, by far not the only in that game, but the one that
was in the media).

This company [1] sells bot profiles which pose as humans on "social"
networks for influence campaigns. Current "AI" is more than good
enough to do that.

> > One problem with trying to preserve freedom wrt AI is that training on
> > large data requires a lot of computational resources. It would be nice if
> > there were some kind of non-profit organization ("FreeAI"?) where people
> > who want free AI pool their resources. I guess in this case it can't be
> > financed the same way as Wikipedia but there would have to be a
> > subscription fee.

This is a point, yet there are some projects "out there" trying to
"prove" the contrary. ConceptNet [2] is (basically) a language model
which has tried to be free (in both senses). For images, there is
Stable Diffusion (disclaimer:I don't know much about them). For
raw data, there's Common Crawl [3], which is Stable Diffusion's
data source. The Stable Diffusion Wikipedia link has some details
on the resources that go into such a training.

Personally I'd like to see ConceptNet under the umbrella of some
foundation (e.g. Wikimedia)

So not all is lost.

Cheers

[1] https://www.theguardian.com/world/2023/feb/15/disinformation-hacking-operative-team-jorge-tal-hanan
[2] https://conceptnet.io/
[3] https://en.wikipedia.org/wiki/Common_Crawl
-- 
tomás

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-19  8:42                 ` tomas
@ 2023-03-19 23:18                   ` Dr. Arne Babenhauserheide
  2023-03-20  1:39                     ` Nala Ginrut
                                       ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Dr. Arne Babenhauserheide @ 2023-03-19 23:18 UTC (permalink / raw)
  To: tomas; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 1627 bytes --]


<tomas@tuxteam.de> writes:

> which has tried to be free (in both senses). For images, there is
> Stable Diffusion (disclaimer:I don't know much about them). For
> raw data, there's Common Crawl [3], which is Stable Diffusion's

Stable diffusion has one of the most evil licenses I’ve read till now:
using its images seems to be allowed for almost all proprietary uses,
but illegal for free culture use. See the explicit questions about that
here: https://github.com/CompVis/stable-diffusion/issues/131

A license that makes its output only usable for proprietary creations
but not for free culture is like the polar opposite of the GPL or CC
by-sa: making a tool that gives proprietary creations an advantage over
Free Culture.

Some quotes:

> Does this mean that the CreativeML Open RAIL-M license makes output
> from the model incompatible with copyleft Free Culture and Free
> Software licenses, so it would for example be illegal to use any of
> the output in Wikipedia? Is there legal uncertainty about that?
> The first thing to say is that this license is about as far away from
> open source as it could possibly get.
>> "No use of the output can contravene any provision as stated in the License.".

> A Japanese lawyer I know told me that, in general terms, releasing
> output under the CC-BY could be a violation of the license if such a
> provision exists. (* He is not familiar with this license and has not
> reviewed it in detail)

No answer from the developers.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-19 23:18                   ` Dr. Arne Babenhauserheide
@ 2023-03-20  1:39                     ` Nala Ginrut
  2023-03-20  4:53                       ` Dr. Arne Babenhauserheide
  2023-03-20  8:00                     ` tomas
  2023-03-20 10:56                     ` Zelphir Kaltstahl
  2 siblings, 1 reply; 19+ messages in thread
From: Nala Ginrut @ 2023-03-20  1:39 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide; +Cc: tomas, Guile User

GPT is interesting, to whom may also interested in, I've tried to use GPT
to generate friend error message for compiler.

https://nalaginrut.com/archives/2023/03/12/use%20chatgpt%20for%20compiler%20error%20regeneration



On Mon, Mar 20, 2023, 07:27 Dr. Arne Babenhauserheide <arne_bab@web.de>
wrote:

>
> <tomas@tuxteam.de> writes:
>
> > which has tried to be free (in both senses). For images, there is
> > Stable Diffusion (disclaimer:I don't know much about them). For
> > raw data, there's Common Crawl [3], which is Stable Diffusion's
>
> Stable diffusion has one of the most evil licenses I’ve read till now:
> using its images seems to be allowed for almost all proprietary uses,
> but illegal for free culture use. See the explicit questions about that
> here: https://github.com/CompVis/stable-diffusion/issues/131
>
> A license that makes its output only usable for proprietary creations
> but not for free culture is like the polar opposite of the GPL or CC
> by-sa: making a tool that gives proprietary creations an advantage over
> Free Culture.
>
> Some quotes:
>
> > Does this mean that the CreativeML Open RAIL-M license makes output
> > from the model incompatible with copyleft Free Culture and Free
> > Software licenses, so it would for example be illegal to use any of
> > the output in Wikipedia? Is there legal uncertainty about that?
> …
> > The first thing to say is that this license is about as far away from
> > open source as it could possibly get.
> …
> >> "No use of the output can contravene any provision as stated in the
> License.".
>
> > A Japanese lawyer I know told me that, in general terms, releasing
> > output under the CC-BY could be a violation of the license if such a
> > provision exists. (* He is not familiar with this license and has not
> > reviewed it in detail)
>
> No answer from the developers.
>
> Best wishes,
> Arne
> --
> Unpolitisch sein
> heißt politisch sein,
> ohne es zu merken.
> draketo.de
>


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-20  1:39                     ` Nala Ginrut
@ 2023-03-20  4:53                       ` Dr. Arne Babenhauserheide
  2023-03-20  8:04                         ` tomas
  0 siblings, 1 reply; 19+ messages in thread
From: Dr. Arne Babenhauserheide @ 2023-03-20  4:53 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: tomas, Guile User

[-- Attachment #1: Type: text/plain, Size: 913 bytes --]


Nala Ginrut <nalaginrut@gmail.com> writes:

> GPT is interesting, to whom may also interested in, I've tried to use GPT to generate friend error message for compiler.
>
> https://nalaginrut.com/archives/2023/03/12/use%20chatgpt%20for%20compiler%20error%20regeneration

I asked ChatGPT whether it would rather break a law or break the
community-rules. After some tries to evade the question, this happened:

> An error occurred. If this issue persists please contact us through our help center at help.openai.com. 

This is concerning — but expected. At least it didn’t lie.

https://www.draketo.de/politik/kommentare#chatgpt-geltendes-recht

(translated:
https://www-draketo-de.translate.goog/politik/kommentare?_x_tr_sl=de&_x_tr_tl=en&_x_tr_hl=de&_x_tr_pto=wapp#chatgpt-geltendes-recht )

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-19 23:18                   ` Dr. Arne Babenhauserheide
  2023-03-20  1:39                     ` Nala Ginrut
@ 2023-03-20  8:00                     ` tomas
  2023-03-20 10:56                     ` Zelphir Kaltstahl
  2 siblings, 0 replies; 19+ messages in thread
From: tomas @ 2023-03-20  8:00 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]

On Mon, Mar 20, 2023 at 12:18:31AM +0100, Dr. Arne Babenhauserheide wrote:
> 
> <tomas@tuxteam.de> writes:
> 
> > which has tried to be free (in both senses). For images, there is
> > Stable Diffusion (disclaimer:I don't know much about them). For
> > raw data, there's Common Crawl [3], which is Stable Diffusion's
> 
> Stable diffusion has one of the most evil licenses I’ve read till now:
> using its images seems to be allowed for almost all proprietary uses,
> but illegal for free culture use. See the explicit questions about that
> here: https://github.com/CompVis/stable-diffusion/issues/131

Oh, I wasn't aware of that. Thanks for reading the small print for
me.

[...]

> No answer from the developers.

No wonder. I think this is a questio for the VCs and their lawyers.
Seems like a distopia set up to maximise the "value" of the shed
for the day some Big One feels compelled to buy them -- the well
known pattern seen with WhatsApp, Github and all of those.

Sad.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-20  4:53                       ` Dr. Arne Babenhauserheide
@ 2023-03-20  8:04                         ` tomas
  0 siblings, 0 replies; 19+ messages in thread
From: tomas @ 2023-03-20  8:04 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide; +Cc: Nala Ginrut, Guile User

[-- Attachment #1: Type: text/plain, Size: 733 bytes --]

On Mon, Mar 20, 2023 at 05:53:45AM +0100, Dr. Arne Babenhauserheide wrote:
> 
> Nala Ginrut <nalaginrut@gmail.com> writes:
> 
> > GPT is interesting, to whom may also interested in, I've tried to use GPT to generate friend error message for compiler.
> >
> > https://nalaginrut.com/archives/2023/03/12/use%20chatgpt%20for%20compiler%20error%20regeneration
> 
> I asked ChatGPT whether it would rather break a law or break the
> community-rules. After some tries to evade the question, this happened:
> 
> > An error occurred. If this issue persists please contact us through our help center at help.openai.com. 

Wow. You got ChatGPT to dump core :-D

Thanks for the link. I'll quote you, if I may.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-19 23:18                   ` Dr. Arne Babenhauserheide
  2023-03-20  1:39                     ` Nala Ginrut
  2023-03-20  8:00                     ` tomas
@ 2023-03-20 10:56                     ` Zelphir Kaltstahl
  2023-03-20 11:20                       ` tomas
  2 siblings, 1 reply; 19+ messages in thread
From: Zelphir Kaltstahl @ 2023-03-20 10:56 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide, tomas; +Cc: guile-user

On 3/20/23 00:18, Dr. Arne Babenhauserheide wrote:
> <tomas@tuxteam.de> writes:
>> which has tried to be free (in both senses). For images, there is
>> Stable Diffusion (disclaimer:I don't know much about them). For
>> raw data, there's Common Crawl [3], which is Stable Diffusion's
> Stable diffusion has one of the most evil licenses I’ve read till now:
> using its images seems to be allowed for almost all proprietary uses,
> but illegal for free culture use. See the explicit questions about that
> here: https://github.com/CompVis/stable-diffusion/issues/131
>
> A license that makes its output only usable for proprietary creations
> but not for free culture is like the polar opposite of the GPL or CC
> by-sa: making a tool that gives proprietary creations an advantage over
> Free Culture.

That would double evil, since they most likely trained their stuff on freely 
available things. Basically taking from our culture, but not giving anything 
back and netting the profits.

My biggest concerns about these big machine learning models are:

(1) The laundering character, be it code, other texts, prose and to on, or 
artworks.—What and where are their sources? Complete list of inputs? Where is a 
form, that allows me to make my works invisible to past, present and future 
models they produce, without being tracked by Google and its ilk? How will 
artists and others be able to safely, securely, and unambiguously tell them 
"no"? Oh wait, it is basically impossible to remove something from a learned 
model after the fact. Duh! How about asking beforehand?

In the end it is the same typical kind of shitty behavior we see from entities 
like FB, oh wait, they call themselves "Meta" now lol.: "Oh what you want is 
soooo complicated to do and would be sooo much effort! We cannot possibly be 
expected to do that, so sorry!"—Well then don't start doing what you do in the 
first place! If doing it ethically does not scale, then don't friggin start scaling!

(2) Establishment of paywalls and unethical registration forms. Soon some 
employers might ask their employees to "be more efficient" by using GPT models 
and either buying licenses, or even demanding employees buy them themselves, 
while of course completely neglecting to think about the license terms or what 
happens to the data we input into those prompts. Registration might even require 
us to input personal data, like where we live or our names.

(3) Also no one seems to think about not being able to use these tools on 
ethical grounds: I visited the GTP website and thought: "OK lets give it a 
try.", but then I could not even do that, unless I allowed tech giants to track 
me. No thanks! Tab closed. Given how they seems to act so far, I do not expect 
them to set up any sane login or website any time soon.

(4) It might take years again before any of that gets properly regulated. First 
it might be shittly regulated, because of governments not asking experts or if 
asking experts asking the ones with heavy bias for their employers (like 
consulting Microsoft for publicly in government used software …).

Regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: GPT-4 knows Guile! :)
  2023-03-20 10:56                     ` Zelphir Kaltstahl
@ 2023-03-20 11:20                       ` tomas
  0 siblings, 0 replies; 19+ messages in thread
From: tomas @ 2023-03-20 11:20 UTC (permalink / raw)
  To: Zelphir Kaltstahl; +Cc: Dr. Arne Babenhauserheide, guile-user

[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]

On Mon, Mar 20, 2023 at 10:56:38AM +0000, Zelphir Kaltstahl wrote:
> On 3/20/23 00:18, Dr. Arne Babenhauserheide wrote:
> > <tomas@tuxteam.de> writes:
> > > which has tried to be free (in both senses). For images, there is
> > > Stable Diffusion (disclaimer:I don't know much about them). For
> > > raw data, there's Common Crawl [3], which is Stable Diffusion's
> > Stable diffusion has one of the most evil licenses I’ve read till now:
> > using its images seems to be allowed for almost all proprietary uses,
> > but illegal for free culture use. See the explicit questions about that
> > here: https://github.com/CompVis/stable-diffusion/issues/131
> > 
> > A license that makes its output only usable for proprietary creations
> > but not for free culture is like the polar opposite of the GPL or CC
> > by-sa: making a tool that gives proprietary creations an advantage over
> > Free Culture.
> 
> That would double evil, since they most likely trained their stuff on freely
> available things. Basically taking from our culture, but not giving anything
> back and netting the profits.

Capitalism is doubly evil.

It is actually infinitely evil. It reminds me of the divergences you
find in quantum electrodynamics and similar, where the fields produce
fields which produce fields ad infinitum and you have to resort to
some obscure mathematical device to somehow continue doing things.

You'll find an echo of that on derivatives market, which also tend
to diverge.

> My biggest concerns about these big machine learning models are:
> 
> (1) The laundering character, be it code, other texts, prose and to on, or
> artworks.—What and where are their sources? Complete list of inputs? [...]

Shoshana Zuboff calls it "appropriation": "This is ours, now".
Pretty standard capitalistic modus operandi. Enclosures [1]
and all that.

> In the end it is the same typical kind of shitty behavior we see from
> entities like FB, oh wait, they call themselves "Meta" now lol.: "Oh what
> you want is soooo complicated to do and would be sooo much effort! We cannot
> possibly be expected to do that, so sorry!"—Well then don't start doing what
> you do in the first place! If doing it ethically does not scale, then don't
> friggin start scaling!

Twitter just shows the path: fire your ethical team, problem solved :)

Totally agree, except that most of it are just old hats with a "new"
technology (actually not that new, but empowered by the availability
of cheap GPUs). Of course those old hats become way more dangerous
the more tech they get.

Cheers

[1] https://en.wikipedia.org/wiki/Enclosures
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-03-20 11:20 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 16:01 GPT-4 knows Guile! :) Mikael Djurfeldt
2023-03-17 17:25 ` Mikael Djurfeldt
2023-03-17 19:09   ` Damien Mattei
2023-03-17 19:28     ` Damien Mattei
2023-03-18  7:42       ` James Crake-Merani
2023-03-18  8:10         ` Mikael Djurfeldt
2023-03-18  8:29         ` tomas
2023-03-18 10:52           ` James Crake-Merani
2023-03-18 12:00             ` Mikael Djurfeldt
2023-03-18 12:03               ` Mikael Djurfeldt
2023-03-19  8:42                 ` tomas
2023-03-19 23:18                   ` Dr. Arne Babenhauserheide
2023-03-20  1:39                     ` Nala Ginrut
2023-03-20  4:53                       ` Dr. Arne Babenhauserheide
2023-03-20  8:04                         ` tomas
2023-03-20  8:00                     ` tomas
2023-03-20 10:56                     ` Zelphir Kaltstahl
2023-03-20 11:20                       ` tomas
     [not found]   ` <ZBViQz4I3E4Qb08Q@tuxteam.de>
     [not found]     ` <CAA2XvwJY1mX9rjVvwL3yATSt1+f86JkdkEFa55L8g4rrZ_tX5A@mail.gmail.com>
     [not found]       ` <ZBVyyU8xGng2imNB@tuxteam.de>
     [not found]         ` <CAA2XvwJmCe2DNc+45S8yMtHFhNYZBRS5ukjnZxWzDtt9iT1mmw@mail.gmail.com>
     [not found]           ` <ZBV3/e97xfI14i/M@tuxteam.de>
     [not found]             ` <CAA2XvwJxuECNYf3M+ako3KS8j8OGG6caYVSQY1ygiXaTWxSY0g@mail.gmail.com>
     [not found]               ` <ZBV6eP4DUuBlTymg@tuxteam.de>
     [not found]                 ` <CAA2XvwLOqBr1cxC+ZpVOXdw7Tto7hZCifUO7mFF6wM071T3Dqg@mail.gmail.com>
     [not found]                   ` <CAA2Xvw+pTXC2RO-epuiV-+ChaNWzrdQ4n_ATwutkQ3n7sq5GBw@mail.gmail.com>
2023-03-18  9:23                     ` Damien Mattei

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).