[ prog / sol / mona ]

prog


GPT3 code

1 2022-12-07 02:17

GPT3 will just write code from prompts.
Here's a scheme raytracer it wrote. I doubt it works but I don't have scheme installed here:
;; Define a structure to represent a 3D point
(define-struct point (x y z))

;; Define a structure to represent a 3D vector
(define-struct vector (x y z))

;; Define a structure to represent a ray
(define-struct ray (origin direction))

;; Define a structure to represent a sphere
(define-struct sphere (center radius))

;; Function to add two vectors
(define (vector-add v1 v2)
(make-vector (+ (vector-x v1) (vector-x v2))
(+ (vector-y v1) (vector-y v2))
(+ (vector-z v1) (vector-z v2))))

;; Function to subtract two vectors
(define (vector-sub v1 v2)
(make-vector (- (vector-x v1) (vector-x v2))
(- (vector-y v1) (vector-y v2))
(- (vector-z v1) (vector-z v2))))

;; Function to multiply a vector by a scalar
(define (vector-mul v c)
(make-vector (* (vector-x v) c)
(* (vector-y v) c)
(* (vector-z v) c)))

;; Function to dot product of two vectors
(define (dot v1 v2)
(+ (* (vector-x v1) (vector-x v2))
(* (vector-y v1) (vector-y v2))
(* (vector-z v1) (vector-z v2))))

;; Function to cross product of two vectors
(define (cross v1 v2)
(make-vector (- (* (vector-y v1) (vector-z v2)) (* (vector-z v1) (vector-y v2)))
(- (* (vector-z v1) (vector-x v2)) (* (vector-x v1) (vector-z v2)))
(- (* (vector-x v1) (vector-y v2)) (* (vector-y v1) (vector-x v2)))))

;; Function to compute the normal vector of a sphere
(define (sphere-normal sphere point)
(vector-normalize (vector-sub point (sphere-center sphere))))

;; Function to compute the intersection of a ray and a sphere
(define (intersect-sphere ray sphere)
(let* ((origin (ray-origin ray))
(direction (ray-direction ray))
(center (sphere-center sphere))
(radius (sphere-radius sphere))
(oc (vector-sub origin center))
(a (dot direction direction))
(b (dot oc direction))
(c (dot oc oc) - (* radius radius)))
(let ((discriminant (sqrt (- (* b b) (* a c)))))
(if (< discriminant 0)
#f
(let ((t1 (/ (- b) a))
(t2 (/ (+ b) a)))
(let ((t (if (< t1 0) t2 t1)))
(if (< t 0)
#f
(vector-add origin (vector-mul direction t)))))))))
vector-mul direction t)))))))))

;; Function to compute the color of a sphere
(define (sphere-color sphere point)
(let ((normal (sphere-normal sphere point)))
(let ((r (abs (vector-x normal)))
(g (abs (vector-y normal)))
(b (abs (vector-z normal))))
(list r g b))))

;; Function to render an image
(define (render width height spheres)
(let ((image (make-vector width height)))
(let loop ((y 0) (x 0))
(if (< y height)
(if (< x width)
(let* ((origin (make-point 0 0 0))
(direction (make-vector x y 1))
(ray (make-ray origin direction))
(color (let loop ((spheres spheres))
(if (null? spheres)
(list 0 0 0)
(let ((intersection (intersect-sphere ray (car spheres))))
(if intersection
(sphere-color (car spheres) intersection)
(loop (cdr spheres)))))))
(r (floor (* (car color) 255)))
(g (floor (* (cadr color) 255)))
(b (floor (* (caddr color) 255))))
(vector-set! image y (vector-set! (vector-ref image y) x (list r g b)))
(loop y (+ x 1)))
(loop (+ y 1) 0)))
image))))

;; Example usage
(let ((spheres (list (make-sphere (make-point 0 0 10) 1)
(make-sphere (make-point 0 0 20) 1))))
(let ((image (render 800 600 spheres)))
(for-each (lambda (row)
(for-each (lambda (pixel)
(display (car pixel))
(display (cadr pixel))
(display (caddr pixel)))
row)
(newline))
image)))

2 2022-12-07 07:58 *

Is this proprietary software?

3 2022-12-07 11:56

You're free to use it except for commercial stuff I think

4 2022-12-07 12:17

>>2
It's too big to run locally and they don't want to just give it away for "moral reasons" or whatever. The tools to regenerate it are open source but you'll need a massive amount of computing power to train it.

5 2022-12-07 12:19 *

(c (dot oc oc) - (* radius radius)))
infix -

6 2022-12-07 18:06

And now it's dead.

7 2022-12-11 10:41

What is this GPT3 good for, other than generating blogspam? It seems completely unreliable for anything else, I've seen pictures of it confidently claiming that subtraction is commutative, starfish are mammals and the double of 1000 is 1000. This seems entirely useless if there's no guarantee that it won't just make up dumb shit as an answer.

8 2022-12-11 19:15

It's way better than google/stack overflow for getting quick snippets of code for libraries or asking questions.

9 2022-12-11 20:17

>>7
It is the temporary issue. The next major update will have multimodal processing and will choose results by their similarity.

>>8
Not just quick snippets: https://github.com/vrescobar/chatGPT-python-elm

10 2022-12-12 19:57

Yeah it will make up programming languages and write compilers for them. I even had it write a graphical xmpp client.

11 2022-12-12 20:10

>>9
We should fear this coming world where you'll be able to meme results into reality and nobody will be the wiser.
Reason was supposed to be an escape from that.

12 2022-12-12 20:20

People were freaking out about Github's copilot circumventing copyleft but apparently this is okay because it is not Microsoft?

13 2022-12-12 22:04

If this becomes popular copyright becomes irrelevant.

14 2022-12-12 22:05

>>11
Reason is still an escape from that, now you no longer can pretend computers and reason are connected so closely.

15 2022-12-12 22:26

>>13
If it becomes popular it will flood the internet with an unending stream of garbage. We will be forced to use snail mail again if we want to talk with another sentient being.

16 2022-12-13 01:23

Gpt3 definitely has a recognizable style so you're safe from that for now.

17 2022-12-13 05:36

>>16
How long is that 'now'

18 2022-12-13 06:16

Until someone adds "following Google style guides" to the prompt.

19 2022-12-13 06:29

They want to become a new world government by censoring its output and restricting access to it by that random number assigned by ISP to their client.

20 2022-12-21 09:22

Corporations would rather feed their NIH syndrome with shitty AI generated code than use Free Software.

21 2022-12-26 06:16

I asked out a Corporation the other day and they rejected me...
How do I recover?

22 2022-12-26 14:45

>>21
Corpos usually have no standards so you can take it as a compliment

23


VIP:

do not edit these