Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc,clearvars
- tortp=1;
- harep=1;
- disp('bang!!!')
- disp('they are off!!!')
- while (tortp<71 && harep<71 )
- rdtort=randi([1,10]);
- rdhare=randi([1,10]);
- if (rdtort>= 1 && rdtort<= 5)
- tortp=tortp+3;
- elseif (rdtort >= 6 && rdtort<= 7)
- tortp=tortp-6;
- elseif (rdtort >= 8 && rdtort<= 10)
- tortp=tortp+1;
- end
- if(tortp<0)
- tortp=1;
- end
- pause(0.03)
- if (tortp> harep)
- disp('T')
- end
- if (rdhare>= 1 && rdhare<= 2)
- harep=harep;
- elseif (rdhare >= 3 && rdhare<= 4)
- harep=harep+9;
- elseif (rdhare >= 5 && rdhare<= 6)
- harep=harep-12;
- elseif (rdhare >= 7 && rdhare<= 9)
- harep=harep+1;
- elseif (rdhare >= 9 && rdhare<= 10)
- harep=harep-2;
- end
- if(harep<0)
- harep=1;
- end
- pause(0.03)
- if (tortp< harep)
- disp('H')
- end
- if (tortp== harep)
- disp('ouch')
- disp('H T "it is a tie"')
- end
- if (harep>= 70)
- disp('hare wins')
- end
- if (tortp>= 70)
- disp('tort wins')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement