to caos repeat 100 [ run pick [ mov_a_hor mov_a_antihor mov_b_hor mov_b_antihor mov_c_hor mov_c_antihor mov_d_hor mov_d_antihor ] ] end to centerlabel :t (local "p "dim) make "p pendownp label [] ; parece que hay un bug en labelsize, hay que llamar antes a label make "dim labelsize :t pu bk (first :dim)/2 lt 90 fd (last :dim)/2 rt 90 label :t lt 90 bk (last :dim)/2 rt 90 fd (first :dim)/2 if :p [pd] end to dentro_caja :centro :lado ; Devuelve true si el puntero del ratón está dentro del rectángulo centrado ; en :centro y de lados :lado x :lado/2 output and (abs (first mousepos) - first :centro) < :lado (abs (last mousepos) - last :centro) < :lado/2 end to gira :quenumeros :quesentido foreach :quenumeros [setitem item ? :numeros :orientaciones modulo (item item ? :numeros :orientaciones) + :quesentido 4] end to haz_mov :letra :mov repeat (count :listamovs) - :puntero [make "listamovs bl :listamovs] make "listamovs lput :letra :listamovs make "puntero :puntero + 1 mostrar :l "borrar run :mov mostrar :l "normal end to jugar ; Principal; empezar por aquí make "caseignoredp "false cs gifload "parrilla1.gif pu ht setxy -500 500-513 bitcut 514 514 setxy -514/2 -514/2 bitpaste make "numeros [1 2 3 4 5 6 7 8 9 10 11 12] make "orientaciones {0 0 0 0 0 0 0 0 0 0 0 0} make "orient_centros {0 0 0 0} make "listamovs [] make "puntero 0 mostrar :l "normal setfocus [MSWLogo Screen] keyboardon [mira_teclado] mouseon [mira_raton] [] [] [] [] end to mira_raton if dentro_caja [-108 132] 40 [haz_mov "a "mov_a_hor] if dentro_caja [-108 76] 40 [haz_mov "A "mov_a_antihor] if dentro_caja [ 108 132] 40 [haz_mov "b "mov_b_hor] if dentro_caja [ 108 76] 40 [haz_mov "B "mov_b_antihor] if dentro_caja [-108 -76] 40 [haz_mov "c "mov_c_hor] if dentro_caja [-108 -132] 40 [haz_mov "C "mov_c_antihor] if dentro_caja [ 108 -76] 40 [haz_mov "d "mov_d_hor] if dentro_caja [ 108 -132] 40 [haz_mov "D "mov_d_antihor] end to mira_teclado (local "t "m) make "t keyboardvalue ;print :t if memberp (char :t) [a A b B c C d D] [haz_mov (char :t) first bf member (char :t) :clave_movs] if :t = 8 [ ; Backspace = Deshacer if :puntero = 0 [stop] mostrar :l "borrar if (item :puntero :listamovs) = "a [mov_a_antihor] if (item :puntero :listamovs) = "A [mov_a_hor] if (item :puntero :listamovs) = "b [mov_b_antihor] if (item :puntero :listamovs) = "B [mov_b_hor] if (item :puntero :listamovs) = "c [mov_c_antihor] if (item :puntero :listamovs) = "C [mov_c_hor] if (item :puntero :listamovs) = "d [mov_d_antihor] if (item :puntero :listamovs) = "D [mov_d_hor] mostrar :l "normal make "puntero :puntero - 1 ] if :t = 13 [ ; Intro = Rehacer if :puntero = (count :listamovs) [stop] make "puntero :puntero + 1 mostrar :l "borrar if (item :puntero :listamovs) = "a [mov_a_hor] if (item :puntero :listamovs) = "A [mov_a_antihor] if (item :puntero :listamovs) = "b [mov_b_hor] if (item :puntero :listamovs) = "B [mov_b_antihor] if (item :puntero :listamovs) = "c [mov_c_hor] if (item :puntero :listamovs) = "C [mov_c_antihor] if (item :puntero :listamovs) = "d [mov_d_hor] if (item :puntero :listamovs) = "D [mov_d_antihor] mostrar :l "normal ] if (char :t) = "e [ ; Posición inicial mostrar :l "borrar make "numeros [1 2 3 4 5 6 7 8 9 10 11 12] make "puntero 0 make "orientaciones {0 0 0 0 0 0 0 0 0 0 0 0} make "orient_centros {0 0 0 0} mostrar :l "normal ] if :t = 3 [ ; ^C = Desordenar mostrar :l "borrar caos make "listamovs [] make "puntero 0 mostrar :l "normal ] end to mostrar :l :borrar ; Muestra o borra los números home fd :l lt 90 fd :l/2 rt 180 muestranum 1 :borrar fd :l muestranum 2 :borrar bk :l lt 90 bk :l rt 90 muestranum 6 :borrar fd :l muestranum 7 :borrar bk :l lt 90 bk :l rt 90 muestranum 11 :borrar fd :l muestranum 12 :borrar bk :l lt 90 bk :l rt 90 home fd :l/2 rt 90 bk :l muestranum 3 :borrar fd :l muestranum 4 :borrar fd :l muestranum 5 :borrar bk 2*:l lt 90 bk :l rt 90 muestranum 8 :borrar fd :l muestranum 9 :borrar fd :l muestranum 10 :borrar if :orient [muestra_centros :borrar] end to mov_a_antihor ; Movimiento antihorario de la primera rueda. Permutación (1 3 6 4) pon_asi_numeros [4 2 1 6 5 3 7 8 9 10 11 12] gira [1 3 6 4] -1 setitem 1 :orient_centros modulo difference item 1 :orient_centros 1 4 end to mov_a_hor ; Movimiento antihorario de la primera rueda. Permutación (1 4 6 3) pon_asi_numeros [3 2 6 1 5 4 7 8 9 10 11 12] gira [1 3 6 4] 1 setitem 1 :orient_centros modulo sum item 1 :orient_centros 1 4 end to mov_b_antihor ; Movimiento antihorario de la segunda rueda. Permutación (2 4 7 5) pon_asi_numeros [1 5 3 2 7 6 4 8 9 10 11 12] gira [2 4 7 5] -1 setitem 2 :orient_centros modulo difference item 2 :orient_centros 1 4 end to mov_b_hor ; Movimiento horario de la segunda rueda. Permutación (2 5 7 4) pon_asi_numeros [1 4 3 7 2 6 5 8 9 10 11 12] gira [2 4 7 5] 1 setitem 2 :orient_centros modulo sum item 2 :orient_centros 1 4 end to mov_c_antihor ; Movimiento antihorario de la tercera rueda. Permutación (6 8 11 9) pon_asi_numeros [1 2 3 4 5 9 7 6 11 10 8 12] gira [6 8 11 9] -1 setitem 3 :orient_centros modulo difference item 3 :orient_centros 1 4 end to mov_c_hor ; Movimiento horario de la tercera rueda. Permutación (6 9 11 8) pon_asi_numeros [1 2 3 4 5 8 7 11 6 10 9 12] gira [6 8 11 9] 1 setitem 3 :orient_centros modulo sum item 3 :orient_centros 1 4 end to mov_d_antihor ; Movimiento antihorario de la cuarta rueda. Permutación (7 9 12 10) pon_asi_numeros [1 2 3 4 5 6 10 8 7 12 11 9] gira [7 9 12 10] -1 setitem 4 :orient_centros modulo difference item 4 :orient_centros 1 4 end to mov_d_hor ; Movimiento horario de la cuarta rueda. Permutación (7 10 12 9) pon_asi_numeros [1 2 3 4 5 6 9 8 12 7 11 10] gira [7 9 12 10] 1 setitem 4 :orient_centros modulo sum item 4 :orient_centros 1 4 end to muestra_centros :borrar local "flechas make "flechas (list char 24 char 26 char 22 char 27) ifelse :borrar = "borrar [setpc [255 255 255]] [setpc [0 0 0]] setxy -:l/2-2 :l/2 centerlabel item sum 1 item 1 :orient_centros :flechas setxy :l/2+2 :l/2-2 centerlabel item sum 1 item 2 :orient_centros :flechas setxy -:l/2-3 -:l/2-3 centerlabel item sum 1 item 3 :orient_centros :flechas setxy :l/2+4 -:l/2-5 centerlabel item sum 1 item 4 :orient_centros :flechas end to muestranum :n :borrar (local "num "flechas) make "flechas (list char 24 char 26 char 22 char 27) make "num item :n :numeros ifelse :borrar = "borrar [setpc [255 255 255]] [ ifelse :num=:n [setpc [0 0 0]] [setpc [255 0 0]] ] ifelse :orient [centerlabel (word :num "- item 1 + item :num :orientaciones :flechas)] [centerlabel :num] end to pon_asi_numeros :lista ; lista de 12 números make "numeros (list item (item 1 :lista) :numeros item (item 2 :lista) :numeros item (item 3 :lista) :numeros item (item 4 :lista) :numeros item (item 5 :lista) :numeros item (item 6 :lista) :numeros item (item 7 :lista) :numeros item (item 8 :lista) :numeros item (item 9 :lista) :numeros item (item 10 :lista) :numeros item (item 11 :lista) :numeros item (item 12 :lista) :numeros ) end Make "ciclo_huesos [i D I d I D i d I D i i d I] Make "ciclo_piedras [I I I I d i i D i d I D I d i D i d I D I d i i D i d I D i d I D i d I I D i d I D i d I D i d I I I D i i i i] Make "clave_movs [a mov_a_hor A mov_a_antihor b mov_b_hor B mov_b_antihor c mov_c_hor C mov_c_antihor d mov_d_hor D mov_d_antihor] Make "l 210 Make "listamovs [] Make "numeros [1 2 3 4 5 6 7 8 9 10 11 12] Make "orient "false Make "orient_centros {0 0 0 0} Make "orientaciones {0 0 0 0 0 0 0 0 0 0 0 0} Make "puntero 0