Computer Science Canada need help to simplify |
Author: | person [ Wed Jan 12, 2005 5:33 pm ] |
Post subject: | need help to simplify |
I typed this code for my horse race betting game to determine the winner. This part of the code is supposed to figure out which of the five horses gets first place, second place, third place, fourth... (horse one has the biggest odds of getting first). I made a code to figure it out but it takes Turing a little bit longer than forever to read it. Can u help me simplify it? Thanks var s1, s2, s3, s4, s5, as, bs, cs, ds, es : int as := Rand.Int (1, 100) bs := Rand.Int (1, 100) cs := Rand.Int (1, 100) ds := Rand.Int (1, 100) es := Rand.Int (1, 100) if as >= 1 and as <= 50 then s1 := 10 elsif as >= 51 and as <= 75 then s2 := 10 elsif as >= 76 and as <= 89 then s3 := 10 elsif as >= 90 and as <= 96 then s4 := 10 else s5 := 10 end if loop if bs >= 1 and bs <= 50 and as > 50 then s1 := 20 exit elsif bs >= 51 and bs <= 75 and (as < 51 or as > 75) then s2 := 20 exit elsif bs >= 76 and bs <= 89 and (as < 76 or as > 89) then s3 := 20 exit elsif bs >= 90 and bs <= 96 and (as < 90 or as > 96) then s4 := 20 exit elsif bs >= 97 and bs <= 100 and as < 97 then s5 := 20 exit else bs := Rand.Int (1, 100) end if end loop loop if cs >= 1 and cs <= 50 and as > 50 and bs > 50 then s1 := 30 exit elsif cs >= 51 and cs <= 75 and (as < 51 or as > 75) and (bs < 51 or bs > 75) then s2 := 30 exit elsif cs >= 76 and cs <= 89 and (as < 76 or as > 89) and (bs < 76 or bs > 89) then s3 := 30 exit elsif cs >= 90 and cs <= 96 and (as < 90 or as > 96) and (bs < 90 or bs > 96) then s4 := 30 exit elsif cs >= 97 and cs <= 100 and as < 97 and bs < 97 then s5 := 30 exit else cs := Rand.Int (1, 100) end if end loop loop if ds >= 1 and ds <= 50 and as > 50 and bs > 50 and cs > 50 then s1 := 40 exit elsif ds >= 51 and ds <= 75 and (as < 51 or as > 75) and (bs < 51 or bs > 75) and (cs < 51 or cs > 75) then s2 := 40 exit elsif ds >= 76 and ds <= 89 and (as < 76 or as > 89) and (bs < 76 or bs > 89) and (cs < 76 or cs > 89) then s3 := 40 exit elsif ds >= 90 and ds <= 96 and (as < 90 or as > 96) and (bs < 90 or bs > 96) and (cs < 90 or cs > 96) then s4 := 40 exit elsif ds >= 97 and ds <= 100 and as > 97 and bs > 97 and cs > 97 then s5 := 40 exit else ds := Rand.Int (1, 100) end if end loop loop if es >= 1 and es <= 50 and as > 50 and bs > 50 and cs > 50 and ds > 50 then s1 := 50 exit elsif es >= 51 and es <= 75 and (as < 51 or as > 75) and (bs < 51 or bs > 75) and (cs < 51 or cs > 75) and (ds < 51 or ds > 75) then s2 := 50 exit elsif es >= 76 and es <= 89 and (as < 76 or as > 89) and (bs < 76 or bs > 89) and (cs < 76 or cs > 89) and (ds < 76 or ds > 89) then s3 := 50 exit elsif es >= 90 and es <= 96 and (as < 90 or as > 96) and (bs < 90 or bs > 96) and (cs < 90 or cs > 96) and (ds < 90 or ds > 96) then s4 := 50 exit elsif es >= 97 and es <= 100 and as > 97 and bs > 97 and cs > 97 and ds > 97 then s5 := 50 exit else es := Rand.Int (1, 100) end if end loop |
Author: | Tony [ Wed Jan 12, 2005 7:44 pm ] | ||
Post subject: | |||
I have no idea what you're doing there.. |
Author: | Neo [ Wed Jan 12, 2005 9:40 pm ] |
Post subject: | |
Your code appears to do nothing. ![]() |
Author: | TheXploder [ Wed Jan 12, 2005 9:49 pm ] |
Post subject: | |
I do remember all of Paul's games exactly, he had this thread a while ago I think it'll help. http://www.compsci.ca/v2/viewtopic.php?t=3338&highlight=pauls+horse+betting |
Author: | Paul [ Wed Jan 12, 2005 10:23 pm ] |
Post subject: | |
w00t, that was long ago. Yep, my old messy style. |
Author: | sport [ Wed Jan 12, 2005 11:41 pm ] | ||
Post subject: | |||
if you explain what
are I'll help you |