Topic: "Turing" (page 1 of 2)

1 2 >
Author Post
midnightfae
[none yet]
Does anyone here know how to use turing? Our computer teacher's saying that we have to know it to know the basics, i personally find it boring as hell because i'm the furthest in my class, but a question about it: how do you use counters to know how many times a random integer is displayed?
private message EMail Website
unknown user
ask something what you are thinking about....
EMail
midnightfae
[none yet]
huh?
private message EMail Website
togi
groupmastergroupmastergroupmastergroupmastergroupmaster
eh... display random number, increase counter?
private message
midnightfae
[none yet]
ok... im now very lost about what both of you have said.
the assignment are as follows: (i have finished 15)\
Exercise 15:

Create a program that simulates the rolling of a die. First the program rolls the die once (sets a random number) to establish the player’s point. This is the number that player will try to match in as few rolls as possible. Then the program continues rolling the die until the point is matched. There should be a one second delay between each roll. Show your teacher when you are done and make sure to save the program in your Turing directory.

Exercise 16:

Modify your die game that you created for the above so that there can between 2 and 4 players. The program should prompt for how many players there are and should declare which player is the winner. Show your teacher when you are done and make sure to save the program in your Turing directory.

ok. i have all my stuff from 15, and then i added 3 more players. BUT i can't figure out what commands to use to calculate who is the winner after the die is rolled. Does anyone know what commands to type in to make it work? my teacher said it was something to do with counter or something... but sure, help is always welcome on this.

private message EMail Website
DigitalAcid
groupmastergroupmastergroupmaster
Already tried to store the values into an array ? :)
The amount of arrays will be the same as the amount of players of course ;).
private message EMail
midnightfae
[none yet]
no actually i didnt... how pre tell to i do that? right now, it is as follows:


var players : int
put "How many players?" ..
get players
put
"The number shown is your number. Keep rolling to match it."
var n, a, b, c, d : int

n := Rand.Int (1, 6)
put n
var me : string (1)
getch (me)
if players = 1 then
put "Player 1"
loop
randint (a, 1, 6)
delay (20)
put a
exit when a = n
end loop
put "You Won!!!"
put ""
else
end if
if players = 2 then
put "Player 1"
loop
randint (a, 1, 6)
delay (20)
put a
exit when a = n
end loop
put ""
put "Player 2"
loop
randint (b, 1, 6)
delay (20)
put b
exit when b = n
end loop
put ""
else
end if
if players = 3 then
put "Player 1"
loop
randint (a, 1, 6)
delay (20)
put a
exit when a = n
end loop
put ""
put "Player 2"
loop
randint (b, 1, 6)
delay (20)
put b
exit when b = n
end loop
put ""
put "Player 3"
loop
randint (c, 1, 6)
delay (20)
put c
exit when c = n
end loop
put ""
else
end if
if players = 4 then
put "Player 1"
loop
randint (a, 1, 6)
delay (20)
put a
exit when a = n
end loop
put ""
put "Player 2"
loop
randint (b, 1, 6)
delay (20)
put b
exit when b = n
end loop
put ""
put "Player 3"
loop
randint (c, 1, 6)
delay (20)
put c
exit when c = n
end loop
put ""
put "Player 4"
loop
randint (d, 1, 6)
delay (20)
put d
exit when d = n
end loop
end if

what do i add and where do i add it?
---------------------------------------------------
the most confusing thing is humanity
---------------------------------------------------
private message EMail Website
unknown user
does that prog even work...i dunno why but it looks kinda goofy to me...but i cant place it
EMail
togi
groupmastergroupmastergroupmastergroupmastergroupmaster
i'm quite sure there's a better way to solve that
private message
unknown user
holy JEAZUS now thats a needlessly long proggy...

cant you just set the dice variable to start and then have a single loop to test/verify each user input as he inputs? The break from the loop when a correct answer is recieved?

e.g.

algotrythm()
print "how many players";
input int NumOfPlayers;
int CurrentPlayer = 0;

int diceRoll = randomly rolled dice;
boolean isTrue = false;

while (!isTrue)
{
print "player "+ CurrentPlayer+1 + " Take your go!";
input int guess;

if ( guess == diceRoll )
isTrue = True;
else
{
if (CurrentPlayer == NumOfPlayers-1)
CurrentPlayer=0;
else
CurrentPlayer++;
}

}

print "Player "+ currentPlayer+1 +" is Correct!";
end

Emmm.... i think this would work... i didnt really think about it that much, so there are prob lots of better implementations. This should also work for any number of players. /me shurgs, this just a wee taster anywho.
EMail

Topic: "Turing" (page 1 of 2)

1 2 >