Poker02.kt 17.1 KB
Newer Older
Jllamas02 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
package Poker02
object paloss {
    val palos = arrayOf(
        'S','D','H','C'
    )
}


data class mazojugado(val valor: Char, val palo: Char)

fun mejormazo(jugada1 : List<mazojugado>, jugada2 : List<mazojugado>, tipo1 :String, tipo2 : String) : String{
    var ganador : String = ""
    var palosusados = arrayOf(0,0,0,0)
    var valordelmazovv1 = arrayOf(0,0,0,0,0,0,0,0,0,0,0,0,0)
    for (palos in jugada1){
        when(palos.palo){
            'S' -> palosusados[0]++  'C' -> palosusados[1]++  'D' -> palosusados[2]++  'H' -> palosusados[3]++ }
    }
    for (valores in jugada1){
        when(valores.valor){
            'A' -> valordelmazovv1[0]++ '2' -> valordelmazovv1[1]++ '3' -> valordelmazovv1[2]++ '4' -> valordelmazovv1[3]++ '5' -> valordelmazovv1[4]++ '6' -> valordelmazovv1[5]++ '7' -> valordelmazovv1[6]++ '8' -> valordelmazovv1[7]++ '9' -> valordelmazovv1[8]++ 'T' -> valordelmazovv1[9]++ 'J' -> valordelmazovv1[10]++ 'Q' -> valordelmazovv1[11]++ 'K' -> valordelmazovv1[12]++  }
    }
    var palosusados2 = arrayOf(0,0,0,0)
    var valordelmazo = arrayOf(0,0,0,0,0,0,0,0,0,0,0,0,0)
    for (palos in jugada2){
        when(palos.palo){
            'S' -> palosusados2[0]++ 'C' -> palosusados2[1]++ 'D' -> palosusados2[2]++ 'H' -> palosusados2[3]++
        }
    }
    for (valores in jugada2){
        when(valores.valor){
            'A' -> valordelmazo[0]++ '2' -> valordelmazo[1]++ '3' -> valordelmazo[2]++ '4' -> valordelmazo[3]++ '5' -> valordelmazo[4]++ '6' -> valordelmazo[5]++ '7' -> valordelmazo[6]++ '8' -> valordelmazo[7]++ '9' -> valordelmazo[8]++ 'T' -> valordelmazo[9]++ 'J' -> valordelmazo[10]++ 'Q' -> valordelmazo[11]++ 'K' -> valordelmazo[12]++
        }
    }
    val jugadas: ArrayList<Int> = arrayListOf(0,0,0,0,0,0,0,0,0,0)
    when(tipo1){
        "ESCALERA REAL" -> jugadas[0]++ "ESCALERA COLOR" -> jugadas[1]++ "POKER" -> jugadas[2]++ "FULL HOUSE" -> jugadas[3]++ "COLOR" -> jugadas[4]++ "ESCALERA" -> jugadas[5]++ "TRIO" -> jugadas[6]++ "DOBLE PAREJA" -> jugadas[7]++ "PAREJA" -> jugadas[8]++ "CARTA ALTA" -> jugadas[9]++
Jllamas02 committed
38
        }
Jllamas02 committed
39 40
    when(tipo2){
        "ESCALERA REAL" -> jugadas[0]++ "ESCALERA COLOR" -> jugadas[1]++ "POKER" -> jugadas[2]++ "FULL HOUSE" -> jugadas[3]++ "COLOR" -> jugadas[4]++ "ESCALERA" -> jugadas[5]++ "TRIO" -> jugadas[6]++ "DOBLE PAREJA" -> jugadas[7]++ "PAREJA" -> jugadas[8]++ "CARTA ALTA" -> jugadas[9]++
Jllamas02 committed
41
        }
Jllamas02 committed
42 43 44
    var quiengano = -1
    var segundo = 0
    loop@ for(casos in jugadas.indices){
Jllamas02 committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
    when(jugadas[casos]) {
    1->{
    quiengano = casos
    ganador = when(quiengano){
    0 -> "ESCALERA REAL" 1 -> "ESCALERA COLOR" 2 -> "POKER" 3 -> "FULL HOUSE" 4 -> "COLOR" 5 -> "ESCALERA" 6 -> "TRIO" 7 -> "DOBLE PAREJA" 8 -> "PAREJA" 9 -> "CARTA ALTA"
    else -> "NADA"
        }
    break@loop
        }
    2->{
    when(casos){
    0 -> {
    ganador = "Mazos iguales"
        }
    1 ->{
    var ultimo = 1
    var mazo1 = 0
    var mazo2 = 0
    loopjugado1@ for (indice in valordelmazovv1.indices) {
    if (valordelmazovv1[indice] == 1) {
    if (ultimo == 5) {
    mazo1 = indice
    break@loopjugado1
        }
    ultimo++
Jllamas02 committed
70
            }
Jllamas02 committed
71 72 73 74 75 76 77 78 79 80 81 82
        }
    ultimo = 1
    println()
    loopjugado2@ for (indice in valordelmazo.indices){
    if (valordelmazo[indice] == 1) {
    if (ultimo == 5){
    mazo2 = indice
    break@loopjugado2
            }
    ultimo++
            }
        }
Jllamas02 committed
83

Jllamas02 committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
    ganador = if (mazo1 == 0 && mazo2 != 0){
    "Mazo 1"
    }else if (mazo2 == 0 && mazo1 != 0) {
    "Mazo 2"
    }else if (mazo1 == mazo2){
    "Mazos iguales"
    }else if (mazo1 > mazo2) {
    "Mazo 1"
    } else "Mazo 2"
        }
    2 ->{
    var ultimo = 0
    var mazo1 = 0
    var mazo2 = 0
    for (indice in valordelmazovv1.indices) {
    if (valordelmazovv1[indice] == 1) {
    if (ultimo == 5) {
    mazo1 = indice
    }
    ultimo++
    }
    }
Jllamas02 committed
106

Jllamas02 committed
107
    ultimo = 0
Jllamas02 committed
108

Jllamas02 committed
109 110 111 112
    for (indice in valordelmazo.indices){
    if (valordelmazo[indice] == 1) {
    if (ultimo == 5){
    mazo2 = indice
Jllamas02 committed
113
                                }
Jllamas02 committed
114
    ultimo++
Jllamas02 committed
115 116
                            }
                        }
Jllamas02 committed
117 118 119 120 121 122 123 124 125
    ganador = if (mazo1 == 0 && mazo2 != 0){
    "Mazo 1"
    }else if (mazo2 == 0 && mazo1 != 0) {
    "Mazo 2"
    }else if (mazo1 == mazo2){
    "Mazos iguales"
    }else if (mazo1 > mazo2) {
    "Mazo 1"
    } else "Mazo 2"
Jllamas02 committed
126
                    }
Jllamas02 committed
127 128
    3 -> {
    var trio1 = -1
Jllamas02 committed
129

Jllamas02 committed
130 131 132
    for (indice in valordelmazovv1.indices) {
    if (valordelmazovv1[indice] == 3) {
    trio1 = indice
Jllamas02 committed
133 134
                            }
                        }
Jllamas02 committed
135
    var trio2 = -1
Jllamas02 committed
136

Jllamas02 committed
137 138 139
    for (indice in valordelmazo.indices) {
    if (valordelmazo[indice] == 3) {
    trio2 = indice
Jllamas02 committed
140 141
                            }
                        }
Jllamas02 committed
142 143 144 145 146 147 148 149 150
    ganador = if (trio1 == 0 && trio2 != 0) {
    "Mazo 1"
    } else if (trio2 == 0 && trio1 != 0) {
    "Mazo 2"
    } else if (trio1 == trio2) {
    "Mazos iguales"
    } else if (trio1 > trio2) {
    "Mazo 1"
    } else "Mazo 2"
Jllamas02 committed
151
                    }
Jllamas02 committed
152 153 154 155 156 157 158 159 160
    4 ->{
    var ultimo = 1
    var mazo1 = 0
    var mazo2 = 0
   loopjugado1@ for (indice in valordelmazovv1.indices) {
    if (valordelmazovv1[indice] == 1) {
    if (ultimo == 5 || indice == 0) {
    mazo1 = indice
    break@loopjugado1
Jllamas02 committed
161
                                }
Jllamas02 committed
162
    ultimo++
Jllamas02 committed
163 164
                            }
                        }
Jllamas02 committed
165 166 167 168 169 170 171
    ultimo = 1
    println()
    loopjugado2@ for (indice in valordelmazo.indices){
    if (valordelmazo[indice] == 1) {
    if (ultimo == 5 || indice == 0){
    mazo2 = indice
    break@loopjugado2
Jllamas02 committed
172
                                }
Jllamas02 committed
173
    ultimo++
Jllamas02 committed
174 175
                            }
                        }
Jllamas02 committed
176 177 178 179 180 181 182 183 184 185
    println("mazo1 = $mazo1 mazo2 = $mazo2")
    ganador = if (mazo1 == 0 && mazo2 != 0){
    "Mazo 1"
    }else if (mazo2 == 0 && mazo1 != 0) {
    "Mazo 2"
    }else if (mazo1 == mazo2){
    "Mazos iguales"
    }else if (mazo1 > mazo2) {
    "Mazo 1"
    } else "Mazo 2"
Jllamas02 committed
186
                    }
Jllamas02 committed
187 188 189 190 191 192 193 194 195
    5   ->{
    var ultimo = 1
    var mazo1 = 0
     var mazo2 = 0
    loopjugado1@ for (indice in valordelmazovv1.indices) {
    if (valordelmazovv1[indice] == 1) {
    if (ultimo == 5 || (indice == 0 && valordelmazovv1[9] == 1 && valordelmazovv1[10] == 1 && valordelmazovv1[11] == 1 && valordelmazovv1[12] == 1)){
    mazo1 = indice
    break@loopjugado1
Jllamas02 committed
196
                                }
Jllamas02 committed
197
    ultimo++
Jllamas02 committed
198 199
                            }
                        }
Jllamas02 committed
200 201 202 203 204 205 206
    ultimo = 1
    println()
    loopjugado2@ for (indice in valordelmazo.indices){
    if (valordelmazo[indice] == 1) {
    if (ultimo == 5 || (indice == 0 && valordelmazovv1[9] == 1 && valordelmazovv1[10] == 1 && valordelmazovv1[11] == 1 && valordelmazovv1[12] == 1)){
    mazo2 = indice
    break@loopjugado2
Jllamas02 committed
207
                                }
Jllamas02 committed
208
    ultimo++
Jllamas02 committed
209 210
                            }
                        }
Jllamas02 committed
211 212 213 214 215 216 217 218 219 220
    println("mazo1 = $mazo1 mazo2 = $mazo2")
    ganador = if (mazo1 == 0 && mazo2 != 0){
    "Mazo 1"
    }else if (mazo2 == 0 && mazo1 != 0) {
    "Mazo 2"
    }else if (mazo1 == mazo2){
    "Mazos iguales"
    }else if (mazo1 > mazo2) {
    "Mazo 1"
    } else "Mazo 2"
Jllamas02 committed
221
                    }
Jllamas02 committed
222 223 224 225 226
    6 ->{
    var trio1 = -1
    for (indice in valordelmazovv1.indices) {
    if (valordelmazovv1[indice] == 3) {
    trio1 = indice
Jllamas02 committed
227 228
                            }
                        }
Jllamas02 committed
229 230 231 232
    var trio2 = -1
    for (indice in valordelmazo.indices) {
    if (valordelmazo[indice] == 3) {
     trio2 = indice
Jllamas02 committed
233 234
                            }
                        }
Jllamas02 committed
235 236 237 238 239 240 241 242 243
    ganador = if (trio1 == 0 && trio2 != 0) {
    "Mazo 1"
    } else if (trio2 == 0 && trio1 != 0) {
    "Mazo 2"
    } else if (trio1 == trio2) {
    "Mazos iguales"
    } else if (trio1 > trio2) {
    "Mazo 1"
    } else "Mazo 2"
Jllamas02 committed
244
                    }
Jllamas02 committed
245 246 247 248 249 250 251 252 253
    7 ->{
    var duoone = -1
    var duotwo = -1
    loopintern@for (indice in valordelmazovv1.indices){
    if (segundo == 1){
    if (valordelmazovv1[indice] == 2){
    duotwo = indice
    segundo = 0
    break@loopintern
Jllamas02 committed
254 255
                                }
                            }
Jllamas02 committed
256 257 258
    if (valordelmazovv1[indice] == 2 && segundo == 0){
    duoone = indice
    segundo = 1
Jllamas02 committed
259 260
                            }
                        }
Jllamas02 committed
261 262 263 264 265 266 267 268 269
    var duoone2 = -1
    var duotwo2 = -1
    segundo = 0
    loopintern@for (indice in valordelmazo.indices){
    if (segundo == 1){
    if (valordelmazo[indice] == 2){
    duotwo2 = indice
    segundo = 0
    break@loopintern
Jllamas02 committed
270 271
                                }
                            }
Jllamas02 committed
272 273 274
    if (valordelmazo[indice] == 2 && segundo == 0){
    duoone2 = indice
    segundo = 1
Jllamas02 committed
275 276
                            }
                        }
Jllamas02 committed
277 278 279 280 281 282 283 284
    ganador = if (duoone == 0 && duoone2 != 0) {
    "Mazo 1"
    } else if (duoone2 == 0 && duoone != 0) {
    "Mazo 2"
    } else if (duoone == duoone2) {
    when {
    duotwo == duotwo2 -> {
    "Mazos iguales"
Jllamas02 committed
285
                                }
Jllamas02 committed
286 287
    duotwo > duotwo2 -> {
    "Mazo 1"
Jllamas02 committed
288
                                }
Jllamas02 committed
289 290
    else -> {
    "Mazo 2"
Jllamas02 committed
291 292
                                }
                            }
Jllamas02 committed
293 294 295
    } else if (duoone > duoone2) {
    "Mazo 1"
    } else "Mazo 2"
Jllamas02 committed
296
                    }
Jllamas02 committed
297 298 299 300 301
    8 ->{
    var ultimo = 1
    var mazo1 = 0
    var mazo2 = 0
    var duoone = -1
Jllamas02 committed
302

Jllamas02 committed
303 304 305 306 307
    var segundo = false
    for (indice in valordelmazovv1.indices){
    if (valordelmazovv1[indice] == 2){
    duoone = indice
    ultimo = 2
Jllamas02 committed
308 309
                            }
                        }
Jllamas02 committed
310 311 312 313 314
    loopjugado1@ for (indice in valordelmazovv1.indices) {
    if (valordelmazovv1[indice] == 1) {
    if (ultimo == 4 || (indice == 0)){
    mazo1 = if (indice == 0) 14 else indice
    break@loopjugado1
Jllamas02 committed
315
                                }
Jllamas02 committed
316
    ultimo++
Jllamas02 committed
317 318
                            }
                        }
Jllamas02 committed
319
    ultimo = 1
Jllamas02 committed
320

Jllamas02 committed
321 322 323 324 325
    var duoone2 = -1
    for (indice in valordelmazo.indices){
    if (valordelmazo[indice] == 2){
    duoone2 = indice
    ultimo = 2
Jllamas02 committed
326 327
                            }
                        }
Jllamas02 committed
328 329 330 331 332
    loopjugado2@ for (indice in valordelmazo.indices){
    if (valordelmazo[indice] == 1) {
    if (ultimo == 4 || (indice == 0)){
    mazo2 = if (indice == 0) 14 else indice
    break@loopjugado2
Jllamas02 committed
333
                                }
Jllamas02 committed
334
    ultimo++
Jllamas02 committed
335 336 337
                            }
                        }

Jllamas02 committed
338 339 340 341 342 343 344 345 346 347 348 349 350
    ganador = if (duoone == 0 && duoone2 != 0) {
    "Mazo 1"
    } else if (duoone2 == 0 && duoone != 0) {
    "Mazo 2"
    } else if (duoone == duoone2) {
    when {
    mazo1 > mazo2 -> "Mazo 1 "
    mazo1 < mazo2 -> "Mazo 2 "
    else -> "Mazos iguales"
    }
    } else if (duoone > duoone2) {
    "Mazo 1"
    } else "Mazo 2"
Jllamas02 committed
351
                    }
Jllamas02 committed
352 353 354 355 356 357 358 359
    9 ->{
    var ultimo = 1
    var mazo1 = 0
    var mazo2 = 0
    loopjugado1@ for (indice in valordelmazovv1.indices) {
    if (valordelmazovv1[indice] == 1) {
    if (ultimo == 5 || (indice == 0)){ mazo1 = indice
    break@loopjugado1
Jllamas02 committed
360
                                }
Jllamas02 committed
361
    ultimo++
Jllamas02 committed
362 363
                            }
                        }
Jllamas02 committed
364 365 366 367 368 369 370
    ultimo = 1
    println()
    loopjugado2@ for (indice in valordelmazo.indices){
    if (valordelmazo[indice] == 1) {
    if (ultimo == 5 || (indice == 0)){
    mazo2 = indice
    break@loopjugado2
Jllamas02 committed
371
                                }
Jllamas02 committed
372
    ultimo++
Jllamas02 committed
373 374
                            }
                        }
Jllamas02 committed
375 376 377 378 379 380 381 382 383 384
    println("mazo1 = $mazo1 mazo2 = $mazo2")
    ganador = if (mazo1 == 0 && mazo2 != 0){
     "Mazo 1"
    }else if (mazo2 == 0 && mazo1 != 0) {
    "Mazo 2"
    }else if (mazo1 == mazo2){
     "Mazos iguales"
    }else if (mazo1 > mazo2) {
     "Mazo 1"
    } else "Mazo 2"
Jllamas02 committed
385 386
                    }

Jllamas02 committed
387 388
     else ->{
     "ERROR 5: JUGADA NO ENCONTRADA"
Jllamas02 committed
389 390 391 392 393 394 395
                    }
                }
            }
        }
    }
    return ganador
}
Jllamas02 committed
396
    fun reconocerjugada(jugadapa : List<mazojugado>): String{
Jllamas02 committed
397 398 399 400 401

    var palosutilizados = arrayOf(0,0,0,0)
    var mazosutilizados = arrayOf(0,0,0,0,0,0,0,0,0,0,0,0,0)
    var result = "NADA"
    for (palos in jugadapa){
Jllamas02 committed
402 403
    when(palos.palo){
    'S' -> palosutilizados[0]++ 'C' -> palosutilizados[1]++ 'D' -> palosutilizados[2]++ 'H' -> palosutilizados[3]++
Jllamas02 committed
404 405 406
        }
    }
    for (valores in jugadapa){
Jllamas02 committed
407 408
    when(valores.valor){
    'A' -> mazosutilizados[0]++ '2' -> mazosutilizados[1]++ '3' -> mazosutilizados[2]++ '4' -> mazosutilizados[3]++ '5' -> mazosutilizados[4]++ '6' -> mazosutilizados[5]++ '7' -> mazosutilizados[6]++ '8' -> mazosutilizados[7]++ '9' -> mazosutilizados[8]++ 'T' -> mazosutilizados[9]++ 'J' -> mazosutilizados[10]++ 'Q' -> mazosutilizados[11]++ 'K' -> mazosutilizados[12]++
Jllamas02 committed
409 410 411 412 413 414 415 416
        }
    }
    var colornm =true
    for (palo in palosutilizados){
        if (palo == 5){
            result = "COLOR"
            colornm = false
            for (position in mazosutilizados.indices){
Jllamas02 committed
417 418
            result = if (position < 9){
            if (1 == mazosutilizados[position] && 1 == mazosutilizados[position+1] && 1 == mazosutilizados[position+2] && 1 == mazosutilizados[position+3] && 1 == mazosutilizados[position+4]) "ESCALERA COLOR" else continue
Jllamas02 committed
419
                }else if (position == 9){
Jllamas02 committed
420
            if (1 == mazosutilizados[position] && 1 == mazosutilizados[position+1] && 1 == mazosutilizados[position+2] && 1 == mazosutilizados[position+3] && 1 == mazosutilizados[0]) "ESCALERA REAL" else break
Jllamas02 committed
421 422 423 424 425 426 427 428 429 430 431 432 433 434
                }else break
            }
        }
    }
    if (colornm) {
        var trio = false
        var doblenms = 0
        for (position in mazosutilizados.indices) {
            if (mazosutilizados[position] == 4) {
                result = "POKER"
                break
            } else if (mazosutilizados[position] == 1 && position <= 9) {
                if (position < 9) {
                    if (1 == mazosutilizados[position] && 1 == mazosutilizados[position + 1] && 1 == mazosutilizados[position + 2] && 1 == mazosutilizados[position + 3] && 1 == mazosutilizados[position + 4]) {
Jllamas02 committed
435 436
                    result = "ESCALERA"
                    break
Jllamas02 committed
437
                    } else {
Jllamas02 committed
438
                    continue
Jllamas02 committed
439 440
                    }
                } else if (position == 9) {
Jllamas02 committed
441 442 443
                  if (1 == mazosutilizados[position] && 1 == mazosutilizados[position + 1] && 1 == mazosutilizados[position + 2] && 1 == mazosutilizados[position + 3] && 1 == mazosutilizados[0]) {
                  result = "ESCALERA  FIGURAS"
                  break
Jllamas02 committed
444 445 446 447
                    } else continue
                } else continue
            }
            else {
Jllamas02 committed
448 449 450 451 452 453 454
            if (mazosutilizados[position] == 3) trio = true
            if (mazosutilizados[position] == 2) doblenms++
            result = if ((doblenms == 1) && trio) "FULL HOUSE"
            else if ((doblenms == 0) && trio) "TRIO"
            else if (doblenms == 1) "PAREJA"
            else if (doblenms == 2) "DOBLE PAREJA"
            else "CARTA ALTA"
Jllamas02 committed
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
            }
        }
    }
    return result
}
fun escalerinha(mazoenmesanm: String) : Boolean{
    var escorrecto = false
    for (caracteres in 0..4 step 2){
        for (caracteresRepite in caracteres+2..8 step 2){
            if ((mazoenmesanm[caracteres] == mazoenmesanm[caracteresRepite]) && (mazoenmesanm[caracteres+1] == mazoenmesanm[caracteresRepite+1])){
                escorrecto = true
            }
        }
    }
    return escorrecto
}
fun valido(cartasenlamesa : String) : Boolean{
    var result  = true
    if (cartasenlamesa.length == 10 && !escalerinha(cartasenlamesa)) {
Jllamas02 committed
474 475
    for (indice in 1..9 step 2) {
    result = !( cartasenlamesa[indice] == paloss.palos[0] || cartasenlamesa[indice] == paloss.palos[1] || cartasenlamesa[indice] == paloss.palos[2] || cartasenlamesa[indice] == paloss.palos[3]) }
Jllamas02 committed
476
    }else {
Jllamas02 committed
477
    println("No forma ningun mazo, por favor, ingrese de nuevo: ")
Jllamas02 committed
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
    }
    return result
}
fun main() {
    var cartasenlamesa : String
    var leermesa : String
    val jugada = arrayListOf<mazojugado>()
    val jugada2 = arrayListOf<mazojugado>()

    println("Mazo del primer jugador:")
    do {
        cartasenlamesa = readLine()!!.toString().toUpperCase()
    }while (valido(cartasenlamesa))
    println("Mazo del segundo jugador:")
    do {
        leermesa = readLine()!!.toString().toUpperCase()
    }while (valido(leermesa))
    jugada.add(mazojugado(valor = cartasenlamesa[0], palo = cartasenlamesa[1])) || jugada.add(mazojugado(valor = cartasenlamesa[2], palo = cartasenlamesa[3])) || jugada.add(mazojugado(valor = cartasenlamesa[4], palo = cartasenlamesa[5])) || jugada.add(mazojugado(valor = cartasenlamesa[6], palo = cartasenlamesa[7])) || jugada.add(mazojugado(valor = cartasenlamesa[8], palo = cartasenlamesa[9]))
    jugada2.add(mazojugado(valor = leermesa[0], palo = leermesa[1])) || jugada2.add(mazojugado(valor = leermesa[2], palo = leermesa[3])) || jugada2.add(mazojugado(valor = leermesa[4], palo = leermesa[5])) || jugada2.add(mazojugado(valor = leermesa[6], palo = leermesa[7])) || jugada2.add(mazojugado(valor = leermesa[8], palo = leermesa[9]))
    val jugadapa = jugada.sortedWith(compareBy {it.valor})
    val segundaplay = jugada2.sortedWith(compareBy {it.valor})
    println("Judada 1")
    for (indice in jugadapa.indices)
    {
        print("${jugadapa[indice].valor}${jugadapa[indice].palo} ")
    }
    println("\nJudada 2")
    for (indice in segundaplay.indices)
    {
        print("${segundaplay[indice].valor}${segundaplay[indice].palo} ")
    }

    val resultado1 = reconocerjugada(jugadapa)
    val resultado2 = reconocerjugada(segundaplay)
    println("\nMazo1 $cartasenlamesa es: $resultado1")
    println("Mazo 2 $leermesa es: $resultado2")
    println("El mejor mazo es: "+mejormazo(jugadapa, segundaplay, resultado1, resultado2))
}