#lang racket/gui

(require "Matrices.rkt")
(require "Reglas-vecindad.rkt")
(require "Hormiga.rkt")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define elemento%
  (class color%
    (init-field
     (estado 0)
     (dureza 0)
     (olor 'objeto_tipo_olor)
     )
    (define/public set-olor
      (lambda (obj)
        (set! olor obj)
        ))
    (define/public get-olor
      (lambda ()
        olor
        ))
    (define/public get-rgb
      (lambda ()
        (let ((r (send this red))
              (g (send this green))
              (b (send this blue))
              (o (send this alpha))
              )
          (list r g b o)
          )
        ))
    (define/public get-color
      (lambda ()
        this ))
    (define/public get-estado
      (lambda ()
        estado ))
    (define/public get-dureza
      (lambda ()
        dureza ))
    (super-new)
    ))
;;Objetos del tipo OLOR
(define olor%
  (class object%
    (init-field
     (tipo 0)
     (intensidad 0)
     )
    (define/public get-tipo
      (lambda ()
        tipo ))
    (define/public get-intensidad
      (lambda ()
        intensidad ))
    (define/public update-intensidad
      (lambda (valor)
        (set! intensidad
              (+ intensidad valor))
        ))
    (super-new)
    ))
;;;;;;;;;;;;
(define olor0;inodora
  (make-object olor% 0 0))
(define olor1;feromonas
  (make-object olor% 1 30))
(define olor2;comida verde
  (make-object olor% 2 10))
(define olor3;comida amarillo
  (make-object olor% 3 10))
(define olor4;el olor de una hormiga
  (make-object olor% 4 1))
(define olor5;el olor de otro autómata
  (make-object olor% 5 1))
(define olor6;el olor de azul y marrón
  (make-object olor% 6 1))
;;Estado dureza olor R   G   B   O
(define blanco
  (make-object elemento% 0 0 olor0 255 255 255 1.0))


(define rojo
  (make-object elemento% 1 5 olor5 255 0 0 1.0))
(define verde
  (make-object elemento% 2 2 olor2 0 255 0 1.0))

(define negro
  (make-object elemento% 3 6 olor4 0 0 0 1.0))
(define amarillo
  (make-object elemento% 4 3 olor3 255 215 0 1.0))

(define azul
  (make-object elemento% 5 7 olor6 0 0 255 1.0))
(define marron
  (make-object elemento% 6 8 olor6 132 60 36 1.0))


;;;;;;;;;;;;;;
(define entorno%
  (class object%
    (init-field
     (ff 0)
     (cc 0)
     (lista-hormigas '())
     )
    (define set-matriz
      (lambda (matriz obj)
        (let rows ((i 0)
                   (j ff))
          (if (= i j)
              matriz
              (let columnas ((m 0)
                             (n cc))
                (if (= m n)
                    (rows (add1 i) j)
                    (begin
                      (matriz-set! matriz i m obj)
                      (columnas (add1 m) n))
                    )
                )
              )
          )
        ))
    (define/public set-configuracion
      (lambda ()
        (set! configuracion (es-configuracion))
        ))
    (define es-configuracion
      (lambda ()
        (map
         (lambda (fila-obj fila-olor)
           (map
            (lambda (obj olor)
              (cons obj olor)
              )
            (vector->list fila-obj)
            (vector->list fila-olor))
           )
         (vector->list matriz-objetos)
         (vector->list tabla-olores)
         )
        ))
    (define/public set-locus!
      (lambda (f c obj)
        (let* ((olor_obj (send obj get-olor))
               (tipo_olor (send olor_obj get-tipo))
               )
          (matriz-set! matriz-objetos f c obj)
          (when (= tipo_olor 1)
            (matriz-set! tabla-olores f c olor_obj)
            )
          #t
          )
        ))
    (define/public get-locus;;;??
      (lambda (x y)
        (values
         (matriz-ref matriz-objetos x y vector-ref)
         (matriz-ref tabla-olores x y vector-ref)
         )
        ))
    (field
     (iteracion 0)
     (Lista-Hormigas lista-hormigas)
     (tabla-olores
      (set-matriz
       (make-matriz ff cc) (make-object olor% 0 0)))
     (matriz-objetos
      (set-matriz
       (make-matriz ff cc)
       (make-object elemento% 0 0 (make-object olor% 0 0) 255 255 255 1.0)))
     (configuracion (es-configuracion))
     )
    (define/public get-Lista-Hormigas;;;;;;;;;;;;;;;;;;;;;;
      (lambda ()
        Lista-Hormigas))
    (define/public get-matriz
      (lambda ()
         matriz-objetos ))
    (define/public get-dimensiones
      (lambda ()
        (cons ff cc) ))
    (define/public get-obj
      (lambda (x y)
        (matriz-ref matriz-objetos x y vector-ref)
        ))
    (define/public get-configuracion
      (lambda ()
        (es-configuracion) ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    
    (define ley-basica
      (lambda (vec anim clave)
        (let* ((vec_obj (matriz-ref matriz-objetos (car vec) (cdr vec) vector-ref))
               (rgb_vec (send vec_obj get-rgb))
               )
          (cond
            ((eq? clave 'avanzar+feromona) (equal? rgb_vec (send blanco get-rgb)))
            ((eq? clave 'avanzar) (equal? rgb_vec (send blanco get-rgb)))
            ((eq? clave 'recoger-comida) (equal? rgb_vec (send amarillo get-rgb)))
            (else #f)
            )
          )
        ))
    (define multiplo-de
      (lambda (m n)
        (if (= (remainder m n) 0)
            #t
            #f)
        ))
    (define deposita-comida
      (lambda (f c1 c2);46 28 39 / 47 28 39
        (if (> c1 c2)
            #f
            (let* ((obj (matriz-ref matriz-objetos f c1 vector-ref))
                   (tipo_obj (send obj get-rgb))
                   )
              (if (equal? tipo_obj (list 255 255 255 1.0))
                  (matriz-set! matriz-objetos f c1 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
                  (deposita-comida f (add1 c1) c2)
                  )
              )
            )
        )
      )
    (define vecinos->objetos
      (lambda (vecinos data proc)
        (if (null? vecinos)
            '()
            (cons
             (matriz-ref data (car (first vecinos)) (cdr (first vecinos)) proc)
             (vecinos->objetos (rest vecinos) data proc)
             )
            )
        ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (define set-comida!
      (lambda (lugares)
        (for-each
         (lambda (lugar)
           (let ((objeto (matriz-ref matriz-objetos (first lugar) (second lugar) vector-ref)))
             (when (is-a? objeto elemento%)
               (matriz-set! matriz-objetos (first lugar) (second lugar) (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
               (matriz-set! tabla-olores (first lugar) (second lugar) (make-object olor% 3 10))
               )
             )
           )
         lugares)
        ))
    (define abre-ramal!
      (lambda (lugares)
        (for-each
         (lambda (lugar)
           (let ((objeto (matriz-ref matriz-objetos (first lugar) (second lugar) vector-ref)))
             (when (is-a? objeto elemento%)
               (matriz-set! matriz-objetos (first lugar) (second lugar) (make-object elemento% 0 0 (make-object olor% 0 0) 255 255 255 1.0))
               (matriz-set! tabla-olores (first lugar) (second lugar) (make-object olor% 0 0))
               )
             )
           )
         lugares)
        ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (define/public procesar!
      (lambda (iter)
        (when (and (multiplo-de iter 8) (not (null? lista-hormigas)))
          (send (car lista-hormigas) set-home (list (cons 44 23) (cons 44 24) (cons 44 25) (cons 44 26)))
          (send M set-locus! 45 24 (car lista-hormigas))
          (set! lista-hormigas (cdr lista-hormigas))
          )
        (when (equal? (send (get-obj 45 24) get-rgb) (send blanco get-rgb))
          (set-locus! 45 24 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
          )
        (when (and (null? Lista-Hormigas) (odd? iter) (not (null? Hormigas)))
          (let-values ([(bloque1 bloque2) (split-at Hormigas 5)])
            (set! lista-hormigas bloque1)
            (set! Hormigas bloque2)
            (set! Lista-Hormigas lista-hormigas)
            (set-comida! lugares-comida)
            )
          )
        (set! configuracion (es-configuracion))
        (let rows
          ((i 0)
           (j ff)
           )
          (if (= i j)
              (begin
                (when (< (length Hormigas) 20);12
                  (abre-ramal! ramal-derecho-lugares)
                  )
                (set! configuracion (es-configuracion))
                )
              (let columns
                ((m 0)
                 (n cc)
                 )
                (if (= m n)
                    (rows (add1 i) j)
                    (let* ((Obj (car (matriz-ref configuracion i m list-ref)))
                           )
                      (cond
                        ((is-a? Obj hormiga%)
                         (printf "~a:: ~n" (send Obj get-id))
                         (let*-values
                             ([(v1 v2 v3 v4 v5 v6 v7 v8) (Moore i m (sub1 ff) (sub1 cc))]
                              [(vecinos-obj) 
                               (vecinos->objetos (list v1 v2 v3 v4 v5 v6 v7 v8) matriz-objetos vector-ref)]
                              [(vecinos-olores)
                               (vecinos->objetos (list v1 v2 v3 v4 v5 v6 v7 v8) tabla-olores vector-ref)]
                              [(vecinos-coord) (list v1 v2 v3 v4 v5 v6 v7 v8)]
                              [(accion vecino automata)
                               (send Obj procesar! i m vecinos-coord vecinos-obj vecinos-olores)]
                              )
                           (cond
                             ((eq? accion 'stop)
                              (let*
                                    ((olor (matriz-ref tabla-olores (car automata) (cdr automata) vector-ref))
                                     (tipo_olor (send olor get-tipo))
                                     )
                                (cond
                                  ((= tipo_olor 1)
                                   (send olor update-intensidad 30)
                                   (matriz-set! tabla-olores (car automata) (cdr automata) olor)
                                   (matriz-set! matriz-objetos (car automata) (cdr automata) (make-object elemento% 0 0 olor 255 255 255 1.0))
                                   )
                                  (else
                                   (matriz-set! tabla-olores (car automata) (cdr automata) (make-object olor% 1 30))
                                   (matriz-set! matriz-objetos (car automata) (cdr automata) (make-object elemento% 0 0 (make-object olor% 1 30) 255 255 255 1.0))
                                   )
                                  )
                                (deposita-comida 47 19 30)
                                (set! Lista-Hormigas (remove Obj Lista-Hormigas))
                                (printf "Hormiga entra en hormiguero y deposita comida~n")
                                )
                              )
                             ((eq? accion 'avanzar+feromona)
                              (when (ley-basica vecino automata accion)
                                (let*
                                    ((olor_vec (matriz-ref tabla-olores (car vecino) (cdr vecino) vector-ref))
                                     (tipo_olor (send olor_vec get-tipo))
                                     (obj_vec (matriz-ref matriz-objetos (car vecino) (cdr vecino) vector-ref))
                                     )
                                  ;;se ubican el autómata y el vecino:
                                  (matriz-set! matriz-objetos (car vecino) (cdr vecino) Obj)
                                  (matriz-set! matriz-objetos i m obj_vec)
                                  ;;se comprueba si vecino huele a feromona
                                  (cond
                                    ((= tipo_olor 1)
                                     (send olor_vec update-intensidad 30)
                                     (matriz-set! tabla-olores (car vecino) (cdr vecino) olor_vec)
                                     )
                                    (else (matriz-set! tabla-olores (car vecino) (cdr vecino) (make-object olor% 1 30)))
                                    )
                                  (printf "Deja feromona en ~a. Rastro con intensidad: ~a~n" (cons i m) (exact->inexact(send (matriz-ref tabla-olores i m vector-ref) get-intensidad)))
                                  )
                                )
                              )
                             ((eq? accion 'avanzar)
                              (when (ley-basica vecino automata accion);;;;;;
                                (let*
                                    ((obj_vec (matriz-ref matriz-objetos (car vecino) (cdr vecino) vector-ref))
                                     (tipo_olor (send (matriz-ref tabla-olores i m vector-ref) get-tipo))
                                     (intensidad_olor (exact->inexact (send (matriz-ref tabla-olores i m vector-ref) get-intensidad)))
                                     )
                                  ;;se ubican el autómata y el vecino:
                                  (matriz-set! matriz-objetos (car vecino) (cdr vecino) Obj)
                                  (matriz-set! matriz-objetos i m obj_vec)
                                  (printf "Entorno: Ubicados autómata en ~a y objeto en ~a Feromona: ~a~n" vecino (cons i m)  (if (= tipo_olor 1) intensidad_olor "no hay")) 
                                  )
                                )
                              )
                             ((eq? accion 'girar) )
                             ((eq? accion 'parar) )
                             ((eq? accion 'recoger-comida);;;;;
                              (when (ley-basica vecino automata accion)
                                (matriz-set! matriz-objetos (car vecino) (cdr vecino) (make-object elemento% 0 0 (make-object olor% 0 0) 255 255 255 1.0))
                                (matriz-set! tabla-olores i m (make-object olor% 1 30))
                                (send Obj set-comida (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
                                ) 
                              )
                             )
                           ) 
                         );;fin primera clausula
                        (else
                         (let* ((olor (matriz-ref tabla-olores i m vector-ref))
                                (tipo_olor (send olor get-tipo))
                                )
                           (when (= tipo_olor 1)
                             (send olor update-intensidad -1/8)
                             ;controlar la disminución de feromona
                             (if (< (send olor get-intensidad) 0)
                                 (matriz-set! tabla-olores i m (make-object olor% 0 0))
                                 #t)
                             )
                           )
                         )
                        );;fin cond
                      (columns (add1 m) n)
                      )
                    )
                )
              )
          )
        ))
    (super-new)
    ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define Hormigas (list H7 H8 H9 H10 H11 H2 H3 H4 H5 H6 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21 H22 H23 H24 H25 H26))
(define M (make-object entorno% 50 50 (list H1)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CIERRE DE LA COMIDA
(send M set-locus! 0 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 23 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 24 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 25 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 26 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 0 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 1 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 2 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 3 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 4 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 5 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 1 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 2 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 3 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 4 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 5 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 5 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 5 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 5 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
;(send M set-locus! 5 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 5 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 5 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 5 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 5 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;COMIDA
(send M set-locus! 1 19 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 20 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 21 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 22 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 23 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 24 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 25 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 26 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 27 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 28 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 29 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 1 30 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))

(send M set-locus! 2 19 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 20 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 21 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 22 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 23 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 24 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 25 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 26 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 27 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 28 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 29 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 2 30 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))

(send M set-locus! 3 19 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 20 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 21 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 22 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 23 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 24 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 25 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 26 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 27 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 28 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 29 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 3 30 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))

(send M set-locus! 4 19 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 20 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 21 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 22 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 23 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 24 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 25 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 26 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 27 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 28 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 29 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
(send M set-locus! 4 30 (make-object elemento% 4 3 (make-object olor% 3 10) 255 215 0 1.0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HORMIGUERO;;salida: 45, 32
(send M set-locus! 48 18 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 19 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 20 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 21 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 22 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 23 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 24 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 25 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 26 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 27 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 28 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 29 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 30 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 48 31 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))

(send M set-locus! 45 18 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 19 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 20 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 21 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 22 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 23 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
;(send M set-locus! 45 24 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 25 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 26 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 27 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 28 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 29 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 30 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 45 31 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))

(send M set-locus! 46 18 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 47 18 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))

(send M set-locus! 46 31 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
(send M set-locus! 47 31 (make-object elemento% 6 8 (make-object olor% 6 1) 132 60 36 1.0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RAMAL IZQUIERDO
(send M set-locus! 6 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 7 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 8 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 9 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 6 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 7 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 8 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 9 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 10 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 32 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 11 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0));;;;;;;;;;;;;;;;;;;;;;;;
(send M set-locus! 12 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 14 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 15 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 16 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 17 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 18 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 20 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 21 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0));;;;;;;;;;;;;;;;;;;;;;;;

(send M set-locus! 22 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 32 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 13 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 17 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 23 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 24 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 25 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 26 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 14 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 15 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 16 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 17 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 18 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 14 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 15 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 16 12 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 16 13 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 16 14 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 16 15 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 16 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 17 12 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 18 12 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 19 12 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 13 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 14 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 15 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 17 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 23 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 24 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 25 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 26 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 13 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 10 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 11 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 12 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 13 13 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 12 13 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 11 13 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 10 13 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 14 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 15 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 17 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 10 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
;(send M set-locus! 10 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 14 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 15 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 16 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 17 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 18 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 19 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 20 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 21 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 22 9 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 10 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 11 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 12 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 13 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 14 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 15 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 17 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 22 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 23 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 24 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 25 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 26 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 27 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 23 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 24 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 25 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 26 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 27 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 28 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 17 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 29 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 30 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 32 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 33 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 34 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 35 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 36 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 38 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 39 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 40 16 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 17 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 18 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 41 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 42 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 43 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 44 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 41 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 42 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 43 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 44 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 40 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 32 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 34 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 35 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 40 36 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 39 36 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 38 36 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 37 36 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 37 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 38 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 39 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 36 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 35 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 34 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 33 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 32 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 30 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 29 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 40 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(send M set-locus! 28 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 32 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 34 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 35 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 36 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 37 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 38 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 28 39 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 37 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 23 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 24 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 25 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 26 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 32 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 37 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 36 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 35 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 34 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 33 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 32 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 31 19 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 20 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 21 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 23 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 24 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 25 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 26 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 36 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 35 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 34 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 34 34 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 34 35 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 34 36 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 34 37 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 33 37 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 32 37 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 31 37 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 36 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 35 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 34 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 33 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 32 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 31 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 30 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 29 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 28 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 31 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CIERRE RAMAL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(send M set-locus! 11 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 12 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 12 26 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 12 25 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 20 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 21 27 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))

(send M set-locus! 29 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 30 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 30 23 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 30 24 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 38 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
(send M set-locus! 39 22 (make-object elemento% 5 7 (make-object olor% 6 1) 0 0 255 1.0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define ramal-derecho-lugares
  '((11 27)
    (12 27)
    (12 26)
    (12 25)
    (20 27)
    (21 27)
    (29 22)
    (30 22)
    (30 23)
    (30 24)
    (38 22)
    (39 22)
    ))
(define lugares-comida
  '(
    (1 19)
    (1 20)
    (1 21)
    (1 22)
    (1 23)
    (1 24)
    (1 25)
    (1 26)
    (1 27)
    (1 28)
    (1 29)
    (1 30)
    (2 19)
    (2 20)
    (2 21)
    (2 22)
    (2 23)
    (2 24)
    (2 25)
    (2 26)
    (2 27)
    (2 28)
    (2 29)
    (2 30)
    (3 19)
    (3 20)
    (3 21)
    (3 22)
    (3 23)
    (3 24)
    (3 25)
    (3 26)
    (3 27)
    (3 28)
    (3 29)
    (3 30)
    (4 19)
    (4 20)
    (4 21)
    (4 22)
    (4 23)
    (4 24)
    (4 25)
    (4 26)
    (4 27)
    (4 28)
    (4 29)
    (4 30)
    )
  )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define blancos-en
  (lambda (matriz dimensiones)
    (let rows
      ((i 0)
       (j (car dimensiones))
       (salida '())
       )
      (if (= i j)
          salida
          (let columns
            ((m 0)
             (n (cdr dimensiones))
             )
            (if (= m n)
                (rows (add1 i) j salida)
                (if (equal? (list 255 255 255 1.0)
                            (send
                             (send M get-obj i m)
                             get-rgb))
                    (begin
                      (set! salida (cons (cons i m) salida))
                      (columns (add1 m) n)
                      )
                    (columns (add1 m) n))
                )
            )
          )
      )
    ))
(define ubica-animat
  (lambda (animat)
    (let* 
        ((hay-blancos
          (blancos-en (send M get-matriz) (send M get-dimensiones)))
         (azar (random (length hay-blancos)))
         (locus (list-ref hay-blancos azar))
         )
      (send M set-locus! (car locus) (cdr locus) animat)
      locus
      )
    ))
;(ubica-animat H1)
;(ubica-animat A2)
                
(provide M hormiga%)
