;;;NETTOOL3 CREATED


(de nettool-net ()
  (let ((input
          (new c-layer '("input" (16 16) t () () () () () t) 60 110 112 112) )
        (hidden-1
          (new c-layer '("hidden-1" (8 8) () () t () () () t) 250 20 64 64) )
        (hidden-2
          (new c-layer '("hidden-2" (8 8) () () t () () () t) 250 110 64 64) )
        (hidden-3
          (new c-layer '("hidden-3" (8 8) () () t () () () t) 250 200 64 64) )
        (hidden-4
          (new c-layer '("hidden-4" (8 8) () () t () () () t) 250 290 64 64) )
        (internal
          (new c-layer '("internal" (4 10) () t () () () () t) 430 90 76 190) )
        (output
          (new c-layer '("output" (1 10) () t () () () t ()) 600 90 19 190) ) )
    (new c-connection input hidden-1
      (list ct-mask-toric-connect '(3 3) '(2 2)) )
    (new c-connection input hidden-2
      (list ct-mask-toric-connect '(3 3) '(2 2)) )
    (new c-connection input hidden-3
      (list ct-mask-toric-connect '(3 3) '(2 2)) )
    (new c-connection input hidden-4
      (list ct-mask-toric-connect '(3 3) '(2 2)) )
    (new c-connection hidden-1 internal
      (list ct-connect '(1 1) '(1 1)) )
    (new c-connection hidden-2 internal
      (list ct-connect '(1 1) '(1 1)) )
    (new c-connection hidden-3 internal
      (list ct-connect '(1 1) '(1 1)) )
    (new c-connection hidden-4 internal
      (list ct-connect '(1 1) '(1 1)) )
    (new c-connection internal output
      (list ct-connect '(1 1) '(1 1)) ) ) )


(de create-net ()
  (alloc_net (+ 573 0) (+ 13250 0) (+ 10730 0))
  (build-net-nobias
    '((input 256) (hidden-1 64) (hidden-2 64) (hidden-3 64) (hidden-4 64)
      (internal 40) (output 10) )
    () )
  ()
  (shared-bias-connect hidden-1)
  (shared-bias-connect hidden-2)
  (shared-bias-connect hidden-3)
  (shared-bias-connect hidden-4)
  (bias-connect internal)
  (bias-connect output)
  (mask-toric-connect input 16 16 hidden-1 8 8 2 2 3 3)
  (mask-toric-connect input 16 16 hidden-2 8 8 2 2 3 3)
  (mask-toric-connect input 16 16 hidden-3 8 8 2 2 3 3)
  (mask-toric-connect input 16 16 hidden-4 8 8 2 2 3 3)
  (connect hidden-1 internal)
  (connect hidden-2 internal)
  (connect hidden-3 internal)
  (connect hidden-4 internal)
  (connect internal output) )


(de draw-net (&optional l num)
  (when (null draw-net-windowobject)
    (setq :draw-net-windowobject
      (new net-display 0 0 641 386 "Network Window"
        (lambda ()
          (graphics_batch
            (cls)
            (gprintf 60 106 "Input")
            (gray_draw_list 60 110 (neurval input) 16 1.2 -1.2 7)
            (gprintf 250 16 "Hidden-1")
            (gray_draw_list 250 20 (neurval hidden-1) 8 1.2 -1.2 8)
            (gprintf 250 106 "Hidden-2")
            (gray_draw_list 250 110 (neurval hidden-2) 8 1.2 -1.2 8)
            (gprintf 250 196 "Hidden-3")
            (gray_draw_list 250 200 (neurval hidden-3) 8 1.2 -1.2 8)
            (gprintf 250 286 "Hidden-4")
            (gray_draw_list 250 290 (neurval hidden-4) 8 1.2 -1.2 8)
            (gprintf 430 86 "Internal")
            (gray_draw_list 430 90 (neurval internal) 4 1.2 -1.2 19)
            (gprintf 600 86 "Output")
            (draw_list 600 90 (neurval output) 1 1.2 19 17) ) )
        (lambda (xc yc)
          (cond
            ((point_in_rect xc yc '(60 110 112 112))
              (nth (+ (div (- xc 60) 7) (* 16 (div (- yc 110) 7))) input) )
            ((point_in_rect xc yc '(250 20 64 64))
              (nth (+ (div (- xc 250) 8) (* 8 (div (- yc 20) 8))) hidden-1) )
            ((point_in_rect xc yc '(250 110 64 64))
              (nth (+ (div (- xc 250) 8) (* 8 (div (- yc 110) 8))) hidden-2) )
            ((point_in_rect xc yc '(250 200 64 64))
              (nth (+ (div (- xc 250) 8) (* 8 (div (- yc 200) 8))) hidden-3) )
            ((point_in_rect xc yc '(250 290 64 64))
              (nth (+ (div (- xc 250) 8) (* 8 (div (- yc 290) 8))) hidden-4) )
            ((point_in_rect xc yc '(430 90 76 190))
              (nth (+ (div (- xc 430) 19) (* 4 (div (- yc 90) 19))) internal) )
            ((point_in_rect xc yc '(600 90 19 190))
              (nth (+ (div (- xc 600) 19) (* 1 (div (- yc 90) 19))) output) )) ) ))
    (setq :draw-net-window :draw-net-windowobject:window) )
  (==> draw-net-windowobject expose)
  (==> draw-net-windowobject repair-damaged) )
