iansantiago

No preview image

1 collaborator

Default-person ian santiago (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo • Viewed 369 times • Downloaded 42 times • Run 0 times
Download the 'iansantiago' modelDownload this modelEmbed this model

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


default

true

0

Polygon -7500403 true true 150 5 40 250 150 205 260 250

airplane

true

0

Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15

arrow

true

0

Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150

box

false

0

Polygon -7500403 true true 150 285 285 225 285 75 150 135

Polygon -7500403 true true 150 135 15 75 150 15 285 75

Polygon -7500403 true true 15 75 15 225 150 285 150 135

Line -16777216 false 150 285 150 135

Line -16777216 false 150 135 15 75

Line -16777216 false 150 135 285 75

bug

true

0

Circle -7500403 true true 96 182 108

Circle -7500403 true true 110 127 80

Circle -7500403 true true 110 75 80

Line -7500403 true 150 100 80 30

Line -7500403 true 150 100 220 30

butterfly

true

0

Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240

Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240

Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163

Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165

Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225

Circle -16777216 true false 135 90 30

Line -16777216 false 150 105 195 60

Line -16777216 false 150 105 105 60

car

false

0

Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180

Circle -16777216 true false 180 180 90

Circle -16777216 true false 30 180 90

Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89

Circle -7500403 true true 47 195 58

Circle -7500403 true true 195 195 58

circle

false

0

Circle -7500403 true true 0 0 300

circle 2

false

0

Circle -7500403 true true 0 0 300

Circle -16777216 true false 30 30 240

cow

false

0

Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167

Polygon -7500403 true true 73 210 86 251 62 249 48 208

Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123

face happy

false

0

Circle -7500403 true true 8 8 285

Circle -16777216 true false 60 75 60

Circle -16777216 true false 180 75 60

Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240

face neutral

false

0

Circle -7500403 true true 8 7 285

Circle -16777216 true false 60 75 60

Circle -16777216 true false 180 75 60

Rectangle -16777216 true false 60 195 240 225

face sad

false

0

Circle -7500403 true true 8 8 285

Circle -16777216 true false 60 75 60

Circle -16777216 true false 180 75 60

Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183

factory

false

0

Rectangle -7500403 true true 76 194 285 270

Rectangle -7500403 true true 36 95 59 231

Rectangle -16777216 true false 90 210 270 240

Line -7500403 true 90 195 90 255

Line -7500403 true 120 195 120 255

Line -7500403 true 150 195 150 240

Line -7500403 true 180 195 180 255

Line -7500403 true 210 210 210 240

Line -7500403 true 240 210 240 240

Line -7500403 true 90 225 270 225

Circle -1 true false 37 73 32

Circle -1 true false 55 38 54

Circle -1 true false 96 21 42

Circle -1 true false 105 40 32

Circle -1 true false 129 19 42

Rectangle -7500403 true true 14 228 78 270

fish

false

0

Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166

Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165

Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60

Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166

Circle -16777216 true false 215 106 30

flag

false

0

Rectangle -7500403 true true 60 15 75 300

Polygon -7500403 true true 90 150 270 90 90 30

Line -7500403 true 75 135 90 135

Line -7500403 true 75 45 90 45

flower

false

0

Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135

Circle -7500403 true true 85 132 38

Circle -7500403 true true 130 147 38

Circle -7500403 true true 192 85 38

Circle -7500403 true true 85 40 38

Circle -7500403 true true 177 40 38

Circle -7500403 true true 177 132 38

Circle -7500403 true true 70 85 38

Circle -7500403 true true 130 25 38

Circle -7500403 true true 96 51 108

Circle -16777216 true false 113 68 74

Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218

Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240

house

false

0

Rectangle -7500403 true true 45 120 255 285

Rectangle -16777216 true false 120 210 180 285

Polygon -7500403 true true 15 120 150 15 285 120

Line -16777216 false 30 120 270 120

leaf

false

0

Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195

Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195

line

true

0

Line -7500403 true 150 0 150 300

link

true

0

Line -7500403 true 150 0 150 300

link direction

true

0

Line -7500403 true 150 150 30 225

Line -7500403 true 150 150 270 225

pentagon

false

0

Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120

person

false

0

Circle -7500403 true true 110 5 80

Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90

Rectangle -7500403 true true 127 79 172 94

Polygon -7500403 true true 195 90 240 150 225 180 165 105

Polygon -7500403 true true 105 90 60 150 75 180 135 105

plant

false

0

Rectangle -7500403 true true 135 90 165 300

Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285

Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285

Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210

Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135

Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135

Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60

Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90

square

false

0

Rectangle -7500403 true true 30 30 270 270

square 2

false

0

Rectangle -7500403 true true 30 30 270 270

Rectangle -16777216 true false 60 60 240 240

star

false

0

Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108

target

false

0

Circle -7500403 true true 0 0 300

Circle -16777216 true false 30 30 240

Circle -7500403 true true 60 60 180

Circle -16777216 true false 90 90 120

Circle -7500403 true true 120 120 60

tree

false

0

Circle -7500403 true true 118 3 94

Rectangle -6459832 true false 120 195 180 300

Circle -7500403 true true 65 21 108

Circle -7500403 true true 116 41 127

Circle -7500403 true true 45 90 120

Circle -7500403 true true 104 74 152

triangle

false

0

Polygon -7500403 true true 150 30 15 255 285 255

triangle 2

false

0

Polygon -7500403 true true 150 30 15 255 285 255

Polygon -16777216 true false 151 99 225 223 75 224

truck

false

0

Rectangle -7500403 true true 4 45 195 187

Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194

Rectangle -1 true false 195 60 195 105

Polygon -16777216 true false 238 112 252 141 219 141 218 112

Circle -16777216 true false 234 174 42

Rectangle -7500403 true true 181 185 214 194

Circle -16777216 true false 144 174 42

Circle -16777216 true false 24 174 42

Circle -7500403 false true 24 174 42

Circle -7500403 false true 144 174 42

Circle -7500403 false true 234 174 42

turtle

true

0

Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210

Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105

Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105

Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87

Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210

Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99

wheel

false

0

Circle -7500403 true true 3 3 294

Circle -16777216 true false 30 30 240

Line -7500403 true 150 285 150 15

Line -7500403 true 15 150 285 150

Circle -7500403 true true 120 120 60

Line -7500403 true 216 40 79 269

Line -7500403 true 40 84 269 221

Line -7500403 true 40 216 269 79

Line -7500403 true 84 40 221 269

x

false

0

Polygon -7500403 true true 270 75 225 30 30 225 75 270

Polygon -7500403 true true 30 75 75 30 270 225 225 270

Comments and Questions

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

Click to Run Model

;Declaracion de tipos de agentes
breed [ jugadores jugador ]


;Declaracion de variables globales
globals
[
  ;;Datos para funcionamientos de partida
  ronda                ;; numero de ronda de juego
  cuantos-enviaron     ;; numero de jugadores que han realizado su aportacion
  aportacion           ;; suma de las aportaciones de todos los jugadores
  numero-jugadores     ;; numero de participantes en la actividad
  reparto              ;; cantidad de dinero que se reparte a los jugadores
  tiempo               ;; tiempo para el final de ronda
  saldo                ;; dinero asignado a cada jugador
  ultimo-reparto       ;; cantidad de dinero que se repartio a los jugadores la ronda anterior
 
  ;;Variables para seleccion de colores diferentes
  colors                        ;; Colores disponibles
  color-names                   ;; Nombres de los colores
  num-colors                    ;; Numero de colores
  free-colors                   ;; Colores ya utilizados
  
  ;;Datos necesarios para el fincionamiento de 'Quick Start Instructions'
  quick-start                   ;; mensaje a mostrar
  qs-item                       ;; marca el mensaje a mostrar
  qs-items                      ;; lista de mensajes
]


;Declaración de variables propias de cada Jugador
jugadores-own 
[
  id-usuario             ;; identificacion unica, introducida por el usuario cuando entra a la partida
  enviado?               ;; a enviado cantidad?
  ultima-aportacion      ;; aportacion de la ronda anterior
  aportacion-provisional ;; necesaria pra calculos
  disponible             ;; Cantidad de um acumuladas durante el juego
  jugador-color
]


;;;;;;;;;;;;;;;;;;;;;;
;;Funciones de setup;;
;;;;;;;;;;;;;;;;;;;;;;


;; Iniciacion de la aplicación

to startup
  setup
  hubnet-set-client-interface "COMPUTER" []
  hubnet-reset 
end 


;; Configura la partida
;; Inicializa variables de jugadores y globales

to setup
  ca
  clear-all-plots
  set-current-plot "Repartos"
  clear-plot
  setup-globales
  ask jugadores
    [ iniciar-variables-jugadores
      enviar-info-jugadores ]
  setup-quick-start
end 


;; Reinicializa variables de jugadores y globales

to reiniciar
  clear-all-plots
  cp
  setup-globales 
  ask jugadores
    [ reiniciar-variables-jugadores 
      reenviar-info-jugadores
      ]
  setup-quick-start
end 


;; Inicialicion de variables globales 

to setup-globales
  set ronda 1
  set cuantos-enviaron 0
  set aportacion 0
  set numero-jugadores count jugadores
  set reparto 0
  set ultimo-reparto 0
  set tiempo tiempo-jugada + 1
  set colors      [ lime   orange   brown   yellow  turquoise  cyan   sky   blue
                   violet   magenta   pink  red  green  gray  12 62 102 38 ]
  set color-names ["lima" "naranja" "marron" "amarillo" "turquesa" "cyan" "azul cielo" "azul"
                   "violeta" "magenta" "rosa" "rojo" "verde" "gris" "marron" "verde oscuro" "azul marino" "sand"]
  set free-colors colors
  set num-colors length colors
end 


;; Da al usuario cierta informacion sobre lo que realiza el boton 'Setup'

to setup-prompt
  if user-yes-or-no? (word "El botón SETUP sólo debe de ser utilizado cuando se empieza "
               "con otro grupo nuevo (como por ejemplo otra clase) ya que "
               "todos los datos se perderán. Utilice el botón RE-RUN para continuar con "
               "un grupo ya existente."
               "\n\n ¿Quiere realmente perder todos los datos?")
  [
    user-message (word "Antes de cerrar esta pantalla, por favor haga lo siguente:"
                  "\n  -Que todo el mundo que esté conectado se desconecte, y "
                  "si queda alguien expúlselo pulsando 'kick' en la consola de HubNet.")
    setup
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Funciones tiempo ejecucion ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; Función principal
;; Dirige la partida

to go
  listen-to-clients
  set numero-jugadores count turtles
  if numero-jugadores = 0
     [user-message "No hay jugadores"
     stop]
  
  every 0.5[
  if ronda = 1[
     if tiempo = tiempo-jugada[
     colocar-colores]]
  ifelse any? jugadores with [enviado? = false]
     [if tiempo = 0[auto-aportacion]]
     [finalizar-ronda
      ask jugadores[actualizar-jugadores]
      anotar-partida
      ifelse ronda = numero-rondas + 1
         [hubnet-broadcast "Message for you" "FIN DEL JUEGO"
         user-message "FIN DEL JUEGO"
         stop]
         [hubnet-broadcast "Message for you" (word "Ronda " ronda ". Realice aportación y pulse 'Enviar'")
         empezar-ronda
         ]
     ]
  ]
 
  every 1[
     set tiempo tiempo - 1
     hubnet-broadcast "Tiempo restante:" tiempo
   ]
end 
 
 
;; Realiza las acciones propias tras finalizar una ronda

to finalizar-ronda
   set reparto calculo-reparto
   dibujar-graficos
   set ronda ronda + 1
end 
  

;; Inicializa los valores necesarios para iniciar una ronda

to empezar-ronda     
   set reparto 0
   set cuantos-enviaron 0
   set tiempo tiempo-jugada
   set aportacion 0
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Funciones de Calculo  ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; Calcula el saldo máximo

to-report maximo-saldo 
  report max [disponible] of jugadores
end 
  

;; Calcula el saldo mínimo

to-report minimo-saldo 
  report min [disponible] of jugadores
end 
  
  
;; Calcula el saldo medio

to-report media-saldo 
  report median [disponible] of jugadores
end 
  
  
;; Calcula la aportación máxima 

to-report maximo-aportacion 
  report max [ultima-aportacion] of jugadores
end 
  
  
;; Calcula la aportación mínima  

to-report minimo-aportacion 
  report min [ultima-aportacion] of jugadores
end 
  
  
;; Calcula la aportación media  

to-report media-aportacion 
  report median [ultima-aportacion] of jugadores
end 


;; Realiza aportación automática cuando el usuario no haya enviado aportación

to auto-aportacion
       let temp 0
        ask jugadores with [enviado? = false][
           if ultima-aportacion > disponible
              [set ultima-aportacion disponible]
           set temp temp + ultima-aportacion
           set enviado? true
           set cuantos-enviaron cuantos-enviaron + 1
       ]
       set aportacion aportacion + temp  
end 


;; Calcula el reparto a asignar a cada jugador

to-report calculo-reparto
  ifelse aportacion != 0 
     [set ultimo-reparto sum [ (ultima-aportacion  / count jugadores) * multiplicador] of jugadores
     report ultimo-reparto]
     [report 0]
end 


;; Devuelve el nombre del color que entra como argumento

to-report color->string [ color-value ]
  report item (position color-value colors) color-names
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Código para realizar los gráficos ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; Dibuja los grafico con los datos recibidos y calculados

to dibujar-graficos
  set-current-plot "Repartos"
  set-current-plot-pen "Reparto"
  plot reparto 
  set-current-plot "Evolución Aportaciones"
  set-current-plot-pen "max"
  plot maximo-aportacion
  set-current-plot-pen "min"
  plot minimo-aportacion
  set-current-plot-pen "avg"
  plot media-aportacion
  dibujar-saldos
end 
 
 
;; Dibuja el grafico de los saldos de los jugadores 

to dibujar-saldos
      ask jugadores 
      [ set-current-plot "Saldos"
      set-current-plot-pen id-usuario
      plot disponible + reparto
      ]
end 
 
 
;; Permite la inicializacion del world-view
;; Coloca los colores y realiza la tabla de emparejamientos

to colocar-colores
  let lista-temp [self] of turtles
  let color-user red
  let index 0
  let user first lista-temp
  let nombre-user ""
  let x length lista-temp
  let y x
  set x -1 * y + 1
  let x1 x - 1
  let y1 y - 1
  ask patches [
           set pcolor red  ;; todo rojo
           if (pxcor = x1 + 5 and pycor = y1 + 1)
              [set plabel "Disp."]
           if (pxcor = x1 + 9 and pycor = y1 + 1)
              [set plabel "Aport."]]
  while [empty? lista-temp = false]
     [ask first lista-temp [ 
        set color-user color
        set user self
        setxy x1 y1
        set nombre-user id-usuario
        ]
       ; set pxcor x        set pycor y
        ask patches[
         if ( pxcor = x1 - 1 and pycor = y1 )
            [set plabel nombre-user]
        if (pxcor > x1 + 1 and pycor = y1) [set pcolor black]     ;; recuadros sin rival
        if (pxcor > x1 + 9 and pycor = y1) [set pcolor red]     ;; recuadros sin rival
        if (pxcor = x1 + 6 and pycor = y1)[set pcolor white]
        ;if (pycor = y1)            [set pcolor black]  ]  ;; recuadros sin rival
         if ( pxcor = x1 and pycor = y1 )
            [set pcolor color-user]
        ]
        set x x + 2
        set y1 y1 - 2
        set lista-temp butfirst lista-temp
     ]
end 
 

;; Permite anotar los resultados en el world-view tras cada ronda

to anotar-partida
   let lista-temp [self] of turtles  
   let one first lista-temp
   let score 0
   let aport 0
   while [length lista-temp != 0]
        [ask first lista-temp [ 
             set one self
             set score round disponible 
             set aport round ultima-aportacion]
       ask patches[
           if (pxcor = [xcor] of one + 5 and pycor = [ycor] of one)
              [set plabel score]
           if (pxcor = [xcor] of one + 9 and pycor = [ycor] of one)
              [set plabel aport]
           ]
       set lista-temp butfirst lista-temp
          
   ]
end 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Codigo para interactuar con los clientes ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;Determina que cliente envia un comando, y cual es este comando
;;Se reciben por HubNet

to listen-to-clients
  while [ hubnet-message-waiting? ]
  [
    hubnet-fetch-message
    ifelse hubnet-enter-message?
    [
      create-new-jugador hubnet-message-source
      hubnet-send hubnet-message-source "Message for you" "COMIENZA EL JUEGO. Realice aportación y pulse 'Enviar'"
    ]
    [
      ifelse hubnet-exit-message?
        [ remove-jugador hubnet-message-source ]
        [ execute-command hubnet-message-tag ]
    ]
 ]
end 


;; Determina como ejecutar los comando enviados por los jugadores
;; Se reciben por hubnet

to execute-command [command]
  let temp 0 
  if command = "enviar"
   [
    ask jugadores with [id-usuario = hubnet-message-source] ;; cuando se pulsa el boton ENVIAR-CANTIDAD se envia al mercado la cantidad seleccionada en la barra
         [if (enviado? = false)                          ;; Sólo se puede enviar productos al mercado una vez por ronda 
            [ ifelse aportacion-provisional > disponible
               [set ultima-aportacion disponible]
               [set ultima-aportacion aportacion-provisional ]
               set disponible disponible - ultima-aportacion 
               set enviado? true
               set temp ultima-aportacion
               set cuantos-enviaron cuantos-enviaron + 1
             ]
            hubnet-send hubnet-message-source "Message for you" "Aportación realizada. Espere las aportaciones del resto."
           enviar-info-jugadores
           set aportacion aportacion + temp 
          ]   
    ]
    if command = "aportacion"[
       ask jugadores with [id-usuario = hubnet-message-source] ;; cuando se pulsa el boton ENVIAR-CANTIDAD se envia al mercado la cantidad seleccionada en la barra
         [if enviado? = false                          ;; Sólo se puede enviar productos al mercado una vez por ronda 
             [set aportacion-provisional hubnet-message]
         ]
   ]
end 


;; Crear jugador

to create-new-jugador [ id ]
  create-jugadores 1
  [
    iniciar-variables-jugadores
    enviar-info-jugadores
  ]
end 



;; Inicializa las variables de cada Jugador

to iniciar-variables-jugadores  
  set id-usuario hubnet-message-source
  set enviado? false            ;; a enviado cantidad?
  set ultima-aportacion 0   ;; aportacion de la ronda anterior
  set disponible Saldo-inicial
  set aportacion-provisional 1936
  ifelse empty? free-colors
  [set jugador-color one-of colors ]
  [
   set jugador-color one-of free-colors
   set free-colors remove jugador-color free-colors
  ]
  set color jugador-color
  ask jugadores [
    set-current-plot "Saldos"
    create-temporary-plot-pen id-usuario
    set-plot-pen-color jugador-color
  ]
end 


;; Reinicializa las variables de cada Jugador

to reiniciar-variables-jugadores 
  set enviado? false            ;; a enviado cantidad?
  set ultima-aportacion 0   ;; aportacion de la ronda anterior
  set disponible Saldo-inicial
  ask jugadores [
    set-current-plot "Saldos"
    create-temporary-plot-pen id-usuario
    set-plot-pen-color jugador-color
  ]
end 

;; Envia ciertas informaciones a los monitores de los Jugadores

to reenviar-info-jugadores 
  hubnet-send id-usuario "Ultimo reparto" reparto
  hubnet-send id-usuario "Ronda:" ronda
  hubnet-send id-usuario "Tiempo restante:" tiempo-jugada
  hubnet-send id-usuario "Disponible:"  Saldo-inicial
  hubnet-send id-usuario "Ultima aportacion" 0
end 


;; Envia informaciones a todos los monitores de los Jugadores

to enviar-info-jugadores 
  hubnet-send id-usuario "Jugador:" id-usuario
  hubnet-send id-usuario "Ultimo reparto" precision reparto 2
  hubnet-send id-usuario "Ronda:" ronda
  hubnet-send id-usuario "Color" (color->string jugador-color)
  hubnet-send id-usuario "Tiempo restante:" tiempo-jugada
  hubnet-send id-usuario "Disponible:"  precision disponible 2
  hubnet-send id-usuario "Ultima aportacion" precision ultima-aportacion 2
end 


;; Actualiza ciertas variables de Jugador para poder iniciar una nueva ronda

to actualizar-jugadores
  set enviado? false
  set disponible disponible + reparto
  enviar-info-jugadores
end 


;; Elimina el jugador 

to remove-jugador [ id ]
  ask jugadores with [id-usuario = id]
  [die]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; functiones Quick Start ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; Instrucciones para configurar e inicializar rapido la actividad

to setup-quick-start
  set qs-item 0
  set qs-items
  [
      "Profesor: Siga estas instrucciones para ejecutar la actividad de HubNet."
      "Profesor: Abra el centro de control de HubNet( Tools-> Hubnet Control Center)."
      "Ahí verá la dirección IP de este ordenador."
      "Para que los jugadores puedan ver los gráficos, active la opción Mirror plots on clients"
      "Jugadores: Abra el HubNet Client en su ordenador..."
      "Escriba su nombre, seleccione esta actividad y pulse ENTER."
      "Si no apareciese esta actividad, introduzca dirección IP y pulse ENTER."
      "Profesor: Configure la actividad usando los sliders."
      "Elija número de rondas, multiplicador, tiempo por ronda y saldo inicial."
      "Profesor: Pulse 'Activar' para comenzar la actividad."
      "Jugadores: Elija su aportación y pulse 'Enviar'."
      "Cuando todos hayan enviado su aportación, comenzará la siguiente ronda. "
      "Cuando se llegue al numero máximo de rondas, la actividad acabará."
      "Profesor: Para reiniciar la actividad con el mismo grupo pulse 'Reiniciar'."
  ]
  set quick-start (item qs-item qs-items)
end 


;; Ver el siguiente mensaje en el monitor quickstart

to view-next
  set qs-item qs-item + 1
  if qs-item >= length qs-items
  [ set qs-item length qs-items - 1 ]
  set quick-start (item qs-item qs-items)
end 


;; Ver la anterior mensaje en el monitor quickstart

to view-prev
  set qs-item qs-item - 1
  if qs-item < 0
  [ set qs-item 0 ]
  set quick-start (item qs-item qs-items)
end 


;; ************ Javier González Tapia **************
;; ****       "Tragedia de los Comunes" ****

GRAPHICS-WINDOW
592
64
921
414
10
10
15.231
1
12
1
1
1
0
0
0
1
-10
10
-10
10
0
0
1
ticks

CC-WINDOW
5
560
930
655
Command Center
0

BUTTON
129
60
238
101
Activar
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL

SLIDER
145
101
363
134
saldo-inicial
saldo-inicial
10
8000
5000
10
1
u.m
HORIZONTAL

MONITOR
33
10
83
55
Ronda
ronda
0
1
11

BUTTON
31
111
131
159
Reiniciar
reiniciar
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL

MONITOR
29
171
139
216
Aportacion Total
aportacion
2
1
11

PLOT
307
359
591
546
Repartos
Rondas
Reparto
0.0
10.0
0.0
5000.0
true
true
PENS
"Reparto" 1.0 0 -13791810 true

PLOT
306
170
590
357
Evolución Aportaciones
Rondas
Saldo
0.0
10.0
0.0
20000.0
true
true
PENS
"max" 1.0 0 -8630108 true
"avg" 1.0 0 -6459832 true
"min" 1.0 0 -16777216 true

MONITOR
142
171
246
216
Aportacion media
sum [ ultima-aportacion ] of jugadores / count jugadores
3
1
11

MONITOR
142
222
246
267
Reparto
ultimo-reparto
3
1
11

SLIDER
145
135
363
168
numero-rondas
numero-rondas
1
20
2
1
1
NIL
HORIZONTAL

SLIDER
370
135
588
168
multiplicador
multiplicador
1.5
4
1.5
0.5
1
NIL
HORIZONTAL

MONITOR
86
10
158
55
Nº jugadores
count jugadores
3
1
11

BUTTON
33
60
123
101
setup
setup-prompt
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL

SLIDER
369
100
588
133
tiempo-jugada
tiempo-jugada
5
120
20
1
1
segundos
HORIZONTAL

MONITOR
29
222
139
267
NIL
cuantos-enviaron
3
1
11

MONITOR
162
10
592
55
Quick Start Instructions
quick-start
3
1
11

BUTTON
269
61
412
94
Reiniciar instrucciones
setup-quick-start
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL

BUTTON
419
61
498
94
<<< prev
view-prev
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL

BUTTON
503
61
587
94
next>>>
view-next
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL

MONITOR
101
274
182
319
media  saldo
media-saldo
2
1
11

MONITOR
28
274
100
319
saldo  max
maximo-saldo
2
1
11

MONITOR
183
274
265
319
saldo minimo
minimo-saldo
2
1
11

PLOT
28
325
305
545
Saldos
NIL
NIL
0.0
10.0
0.0
5000.0
true
false
PENS
"default" 1.0 0 -16777216 true

TEXTBOX
651
420
908
476
Disp. = Saldo disponible por el jugador\nAport. = Aportación del jugador en la ronda anterior
11
0.0
0

There is only one version of this model, created over 11 years ago by ian santiago.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.