Jogo de Dados
Programinha que simula uma jogada de dados. Precisa melhorar muito a aleatoriedade.
function Point(x,y)
return { x = x, y = math.random(1,y)}
end
x = 1
while x == 1 do
vetor = { }
c = #vetor
print("quantos dados serão usados?")
a = io.read("*n")
print("quantas faces tem o dado?")
b = io.read("*n")
i = 1
while i < (a+1) do
vetor[i] = Point(i,b)
print("dado "..(i).." ----> "..vetor[i].y)
i = i + 1
end
d = 1
soma = 0
while d < (#vetor+1) do
soma = soma + vetor[d].y
d = d + 1
end
print(soma)
print("mais uma jogada? (1)sim, (2)não")
x = io.read("*n")
end