IA desconectada de Nowak

IA desconectada de Nowak preview image

1 collaborator

Tags

artificial intelligence 

Tagged by Diego Díaz Córdova about 14 hours ago

luis nowak 

Tagged by Diego Díaz Córdova about 14 hours ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 7.0.0 • Viewed 33 times • Downloaded 2 times • Run 0 times
Download the 'IA desconectada de Nowak' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


¿QUE ES ESTO?

La IA desconectada de Nowak es un procedimiento didáctico para comprender como funciona una IA desconectada, es decir que se puede utilizar sin necesidad de cables o procesadores. El juego consiste en 10 cartas y dos jugadores, en los que por turnos dan vuelta en conjuntos de a 1, 2 o 3 cartas, el que da vuelta la última carta pierde. La IA desconectada de Nowak consiste en 9 vasitos, donde en los 8 primeros se colocan 3 papelitos con las inscripciones "1", "2" y "3" y en el último dos papelitos con las inscripciones "1" y "2". El juego se realiza entre un humano y la IA desconectada para poder entrenarla. Cuando le toca el turno a la IA, se saca un papelito al azar del vasito correspondiente. A medida que la IA pierde, entonces se elimina el papelito con el número de cartas a dar vueltas que resultó perdedor. Luego de varias rondas de entrenamiento, la IA desconectada aprende una estrategia mediante la cual ya no vuelve a perder.

COMO FUNCIONA

Esta versión en NetLogo de la IA desconectada de Nowak consta de un tablero en donde están representadas las cartas (en rojo cuando están boca a abajo y en blanco cuando se dan vuelta), los vasitos (pintados de amarillo), los papelitos con las posibilidades (las columnas encima de los vasitos) y una leyenda con el turno (si le toca al humano o a la máquina). El humano tiene 3 posibles cartas para dar vuelta, al igual que la máquina, cuando el turno se termina, se vuelven a poner las cartas de color rojo (boca a abajo).

COMO USAR EL MODELO

El botón de setup configura el tablero con las leyendas correspondientes, las cartas, los vasitos y los papelitos que hay dentro de cada vasito. De acuerdo a lo que se indica en el tablero, comienza el humano o la máquina. Si es el humano, entonces tiene que elegir cuantas cartas va a dar vuelta, si 1, 2 o 3. Si el turno es el de la máquina, entonces hay que hacer click en el botón JuegaIA. Una vez que alguno de los 2 pierde, entonces hay que presionar el botón de resetcard. El botón de entrenaManual se debe dejar presionado, ya que es el que permite ir entrenando a la IA, al hacer click en el vasito con el número elegido, se elimina el papelito (desaparece de la columna de números que se encuentra arriba).

CREDITS AND REFERENCES

Este modelo esta basado en el video del reportaje sobre Inteligencia Artificial al profesor Luis Nowak (https://www.youtube.com/watch?v=0TKrbvQ--dc) investigador del CONICET en el INSTITUTO DE INVESTIGACION EN TECNOLOGIAS Y CIENCIAS DE LA INGENIERIA en Argentina.

Diego Díaz Córdova Cátedra Informática Escuela de Nutrición Universidad de Buenos Aires

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals
[xcarta ;;variable que guarda la carta que toca ser jugada
 cantvas1 ;;cantidad de jugadas de cada vasito (arranca con 3) 
 cantvas2
 cantvas3
 cantvas4
 cantvas5
 cantvas6
 cantvas7
 cantvas8
 cantvas9 ;;el vaso 9 sólo tiene 2 chances
 cuentablancos ;;registra cuantas cartas se dieron vuelta para ver cuando termina el juego 
 guardalabel ;;guarda el valor del último nro sorteado
 guardapxcor ;;guarda las coordenadas del vaso donde salió el último nro sorteado
 guardapycor 
 listv ;;lista temporaria para guardar los papelitos que quedan en los vasitos
 juegahumano ;; flag para ver a quien le toca jugar
 juegamaquina 
]

to setup
  clear-all
  ask patches
  [
   ;;dibujo vasitos 
   if pxcor = -14 and pycor = 1
    [set pcolor yellow]
   if pxcor = -12 and pycor = 1
    [set pcolor yellow]
   if pxcor = -10 and pycor = 1
    [set pcolor yellow]
   if pxcor = -8 and pycor = 1
    [set pcolor yellow]
   if pxcor = -6 and pycor = 1
    [set pcolor yellow] 
   if pxcor = -4 and pycor = 1
    [set pcolor yellow]
   if pxcor = -2 and pycor = 1
    [set pcolor yellow]
   if pxcor = 0 and pycor = 1
    [set pcolor yellow]
   if pxcor = 2 and pycor = 1
    [set pcolor yellow]
   if pxcor = 8 and pycor = 1
    [set plabel "vasitos"] 
   ;; pinto las cartas
   if pxcor = -14 and pycor = -1
    [set pcolor red]
   if pxcor = -12 and pycor = -1
    [set pcolor red]
   if pxcor = -10 and pycor = -1
    [set pcolor red]
   if pxcor = -8 and pycor = -1
    [set pcolor red]
   if pxcor = -6 and pycor = -1
    [set pcolor red] 
   if pxcor = -4 and pycor = -1
    [set pcolor red]
   if pxcor = -2 and pycor = -1
    [set pcolor red]
   if pxcor = 0 and pycor = -1
    [set pcolor red]
   if pxcor = 2 and pycor = -1
    [set pcolor red]
   if pxcor = 4 and pycor = -1
    [set pcolor red]
   if pxcor = 8 and pycor = -1
    [set plabel "cartas"] 
   ;;pongo los papelitos 1
   if pxcor = -14 and pycor = 3
    [set plabel "1"]
   if pxcor = -12 and pycor = 3
    [set plabel "1"]
   if pxcor = -10 and pycor = 3
    [set plabel "1"]
   if pxcor = -8 and pycor = 3
    [set plabel "1"]
   if pxcor = -6 and pycor = 3
    [set plabel "1"] 
   if pxcor = -4 and pycor = 3
    [set plabel "1"]
   if pxcor = -2 and pycor = 3
    [set plabel "1"]
   if pxcor = 0 and pycor = 3
    [set plabel "1"]
   if pxcor = 2 and pycor = 3
    [set plabel "1"]
    ;;pongo los papelitos 2
   if pxcor = -14 and pycor = 5
    [set plabel "2"]
   if pxcor = -12 and pycor = 5
    [set plabel "2"]
   if pxcor = -10 and pycor = 5
    [set plabel "2"]
   if pxcor = -8 and pycor = 5
    [set plabel "2"]
   if pxcor = -6 and pycor = 5
    [set plabel "2"] 
   if pxcor = -4 and pycor = 5
    [set plabel "2"]
   if pxcor = -2 and pycor = 5
    [set plabel "2"]
   if pxcor = 0 and pycor = 5
    [set plabel "2"]
   if pxcor = 2 and pycor = 5
    [set plabel "2"]
   ;;pongo los papelitos 3
   if pxcor = -14 and pycor = 7
    [set plabel "3"]
   if pxcor = -12 and pycor = 7
    [set plabel "3"]
   if pxcor = -10 and pycor = 7
    [set plabel "3"]
   if pxcor = -8 and pycor = 7
    [set plabel "3"]
   if pxcor = -6 and pycor = 7
    [set plabel "3"] 
   if pxcor = -4 and pycor = 7
    [set plabel "3"]
   if pxcor = -2 and pycor = 7
    [set plabel "3"]
   if pxcor = 0 and pycor = 7
    [set plabel "3"]

  ]
  set xcarta -14 
  ;;cantidad inicial de jugadas posibles de cada vasito
  set cantvas1 [1 2 3]
  set cantvas2 [1 2 3]
  set cantvas3 [1 2 3]
  set cantvas4 [1 2 3]
  set cantvas5 [1 2 3]
  set cantvas6 [1 2 3]
  set cantvas7 [1 2 3]
  set cantvas8 [1 2 3]
  set cantvas9 [1 2]
  set cuentablancos 0
  set guardalabel ""
  set guardapxcor 100
  set guardapycor 100
  set listv []
  ifelse random 2 = 1
    [set juegahumano 1
     set juegamaquina 0
     ask patch 6 10
        [set plabel-color blue
         set plabel "juega humano"]
    ]
    [set juegahumano 0
     set juegamaquina 1
     ask patch 6 10
        [set plabel-color green
         set plabel "juega maquina"]
    ]
end 

to uno
  ask patches 
  [
   if pxcor > 4 [stop] 
   if pxcor = xcarta and pycor = -1
    [set pcolor white]
  ]  
  set xcarta xcarta + 2
  set cuentablancos cuentablancos + 1
  set juegamaquina 1
  set juegahumano 0
  ask patch 6 10
     [set plabel-color green
     set plabel "juega maquina"]
end 

to dos
  repeat 2 
  [
   ask patches 
   [
      if pxcor > 4 [stop] 
      if pxcor = xcarta and pycor = -1
        [set pcolor white]  
   ]
   set xcarta xcarta + 2
   set cuentablancos cuentablancos + 1 
  ]
  set juegamaquina 1
  set juegahumano 0
  ask patch 6 10
     [set plabel-color green
     set plabel "juega maquina"]
end 

to tres
   repeat 3 
  [
   ask patches 
   [
      if pxcor > 4 [stop] 
      if pxcor = xcarta and pycor = -1
        [set pcolor white]  
   ]
   set xcarta xcarta + 2
   set cuentablancos cuentablancos + 1 
  ]    
  set juegamaquina 1
  set juegahumano 0
  ask patch 6 10
     [set plabel-color green
     set plabel "juega maquina"]
end 

to juegaIA
  let rnd 0
  ask patches  
   [
     if pxcor = xcarta and pycor = 1
        [
        if xcarta = -14 and pycor = 1
          [set rnd one-of cantvas1
           etiqueta rnd cantvas1
          ]
        if xcarta = -12 and pycor = 1
          [set rnd one-of cantvas2
           etiqueta rnd cantvas2 
          ]
        if xcarta = -10 and pycor = 1
          [set rnd one-of cantvas3
           etiqueta rnd cantvas3 
          ]
        if xcarta = -8 and pycor = 1
          [set rnd one-of cantvas4
           etiqueta rnd cantvas4 
          ]
        if xcarta = -6 and pycor = 1
          [set rnd one-of cantvas5
           etiqueta rnd cantvas5 
          ] 
        if xcarta = -4 and pycor = 1
          [set rnd one-of cantvas6
           etiqueta rnd cantvas6 
          ]
        if xcarta = -2 and pycor = 1
          [set rnd one-of cantvas7
           etiqueta rnd cantvas7 
          ]
        if xcarta = 0 and pycor = 1
          [set rnd one-of cantvas8
           etiqueta rnd cantvas8 
          ]
        if xcarta = 2 and pycor = 1
          [set rnd one-of cantvas9
           etiqueta rnd cantvas9 
          ]  
        ]
  ]     
  if rnd = 1
    [uno]
  if rnd = 2
    [dos]
  if rnd = 3
    [tres]
  set juegamaquina 0
  set juegahumano 1
  ask patch 6 10
     [set plabel-color blue
     set plabel "juega humano"]
end 

to entrenaManual
  if mouse-down? 
  [
    let target patch mouse-xcor mouse-ycor
    if target != nobody 
    [
      ;; elimina el papelito que salió sorteado
      ask target 
      [
        if guardalabel = 1
          [ask patch guardapxcor 3
            [set plabel ""]
          ]
        if guardalabel = 2
          [ask patch guardapxcor 5
            [set plabel ""]
          ]
        if guardalabel = 3
          [ask patch guardapxcor 7
            [set plabel ""]
          ]
         set plabel ""
      ]
      ;; remueve el papelito que salió del vector de papelitos de los vasitos
      if guardapxcor = -14 and guardapycor = 1 and length cantvas1 > 1
        [set listv remove guardalabel cantvas1
         set cantvas1 listv]
      if guardapxcor = -12 and guardapycor = 1 and length cantvas2 > 1
        [set listv remove guardalabel cantvas2
         set cantvas2 listv]
      if guardapxcor = -10 and guardapycor = 1 and length cantvas3 > 1
        [set listv remove guardalabel cantvas3
         set cantvas3 listv]
      if guardapxcor = -8 and guardapycor = 1 and length cantvas4 > 1
        [set listv remove guardalabel cantvas4
         set cantvas4 listv]
      if guardapxcor = -6 and guardapycor = 1 and length cantvas5 > 1
        [set listv remove guardalabel cantvas5
         set cantvas5 listv] 
      if guardapxcor = -4 and guardapycor = 1 and length cantvas6 > 1
        [set listv remove guardalabel cantvas6
         set cantvas6 listv]
      if guardapxcor = -2 and guardapycor = 1 and length cantvas7 > 1
        [set listv remove guardalabel cantvas7
         set cantvas7 listv]
      if guardapxcor = 0 and guardapycor = 1 and length cantvas8 > 1
        [set listv remove guardalabel cantvas8
         set cantvas8 listv]
      if guardapxcor = 2 and guardapycor = 1 and length cantvas9 > 1
        [set listv remove guardalabel cantvas9
         set cantvas9 listv]
    ]
  ]
end 

to etiqueta[p v]
 
if p = 1
  [set plabel-color blue
   set plabel "1"  
  ]
if p = 2
  [set plabel-color blue
   set plabel "2"
  ]
if p = 3
 [set plabel-color blue
  set plabel "3"
 ]
  ;;if xcarta = pxcor and 
  if length v > 1
     [
     set guardalabel read-from-string plabel
     set guardapxcor pxcor
     set guardapycor pycor
     ]   
end 

to resetcard
  ask patches [
    ;; doy vulta todas las cartas
    if pxcor = -14 and pycor = -1
    [set pcolor red]
   if pxcor = -12 and pycor = -1
    [set pcolor red]
   if pxcor = -10 and pycor = -1
    [set pcolor red]
   if pxcor = -8 and pycor = -1
    [set pcolor red]
   if pxcor = -6 and pycor = -1
    [set pcolor red] 
   if pxcor = -4 and pycor = -1
    [set pcolor red]
   if pxcor = -2 and pycor = -1
    [set pcolor red]
   if pxcor = 0 and pycor = -1
    [set pcolor red]
   if pxcor = 2 and pycor = -1
    [set pcolor red]
   if pxcor = 4 and pycor = -1
    [set pcolor red]
   ;;limpio las etiquetas de los vasitos
     if pxcor = -14 and pycor = 1
    [set plabel ""]
   if pxcor = -12 and pycor = 1
    [set plabel ""]
   if pxcor = -10 and pycor = 1
    [set plabel ""]
   if pxcor = -8 and pycor = 1
    [set plabel ""]
   if pxcor = -6 and pycor = 1
    [set plabel ""] 
   if pxcor = -4 and pycor = 1
    [set plabel ""]
   if pxcor = -2 and pycor = 1
    [set plabel ""]
   if pxcor = 0 and pycor = 1
    [set plabel ""]
   if pxcor = 2 and pycor = 1
    [set plabel ""]
   if pxcor = 4 and pycor = 1
    [set plabel ""]
 
  ]
  set xcarta -14
  set cuentablancos 0
  set guardalabel ""
  set guardapxcor 100
  set guardapycor 100
  set listv []
end 

There is only one version of this model, created about 14 hours ago by Diego Díaz Córdova.

Attached files

File Type Description Last updated
IA desconectada de Nowak.png preview Preview for 'IA desconectada de Nowak' about 14 hours ago, by Diego Díaz Córdova Download

This model does not have any ancestors.

This model does not have any descendants.