Exámenes - Juego de dados

En este ejercicio se debe crear un programa que simule una partida de un juego de dados de dos jugadores. En este juego un jugador juega con un dado de seis caras numeradas del 1 al 6 y el otro con un dado de cuatro caras numeradas del 1 al 4. Primero se decide cuántas veces se van a tirar los dados (de 1 a 5 veces, al azar) y a continuación se tiran los dados. Gana el primer jugador si no salen números iguales consecutivos. Gana el segundo si salen.

Juego de dados - Comentarios

Juego de dados - Ejemplos de código HTML


  <h2>2 dados</h2>

  <p>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <rect x="10" y="10" width="80" height="80" fill="lightblue" stroke="blue" stroke-width="3"/> <text x="50" y="75" text-anchor="middle" font-size="75">6</text> </svg>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <polygon points="50,10 90,90 10,90" fill="pink" stroke="red" stroke-width="3"/> <text x="50" y="80" text-anchor="middle" font-size="60">4</text> </svg>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <rect x="10" y="10" width="80" height="80" fill="lightblue" stroke="blue" stroke-width="3"/> <text x="50" y="75" text-anchor="middle" font-size="75">2</text> </svg>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <polygon points="50,10 90,90 10,90" fill="pink" stroke="red" stroke-width="3"/> <text x="50" y="80" text-anchor="middle" font-size="60">4</text> </svg>
</p> <p>Ha ganado el primer jugador porque no hay valores consecutivos repetidos.</p>