CS136 Fall 2012 - Tutorial 1 CS136 Tutors cs136@student.cs.uwaterloo.ca September 14, 2012 CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
RunC Environment We will use gedit under Ubuntu for both C and Racket coding. Use RunC to compile and run your code from within gedit: You can find the link to download our custom RunC at http://www.student.cs.uwaterloo.ca/˜cs136/ software CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Marmoset and Markus We are using both Marmoset and MarkUs for this course. The Marmoset website is: http://marmoset.student.cs.uwaterloo.ca/ The Markus website is: http://markus002.student.cs.uwaterloo.ca/ markus_cs136_f/en/main/ Everyone should now have an account, if you do not have an account see someone or email someone immediately! Marmoset will be used for submissions and release tests. Markus will be used for handmarking and marker comments. CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Piazza - Etiquette Remember, anything you post can be viewed by anyone and everyone! Keep posts relevant to the course. Posts should not be disrespectful in any way: To fellow students, course staff, etc. CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Piazza - Etiquette (Cont.) Try to word questions as clearly as possible. All posts must be in English. NEVER post any code, assignment solutions, partial solutions, etc. This will be dealt with as a cheating case. If you have a question regarding your specific solution, see the instructor, tutor or IA in person, or send a question via email. CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Piazza - Etiquette (Cont.) Avoid useless posts - ”yeah, I have the same problem”. Piazza will be checked/answered during working hours Monday-Friday. Do not expect that it will be checked and answered on weekends or evenings. CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Piazza - Accessing Piazza Instructions: http://www.student.cs.uwaterloo.ca/˜cs136/ piazzahelp.shtml CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
DrRacket We recommend the use of gedit/RunC for the purpose of writing/running Racket programs, but DrRacket is an option if you are more comfortable. Note that your Racket code will be tested on the RunC environment, so it must work with RunC, regardless of how DrRacket works. Make sure that #lang racket is at the very top. Can also use the Dr.Racket GUI - (choose language from source). CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Racket Questions - Set! The set! is a function that allows us to change the value of a variable in a racket module. Eg: > (define a 5) > a ;; Evaluates to 5 5 > (set! a 6) > a ;; Evaluates to 6, since the values of a was 6 > (set! a (+ a 3)) > a ;; Evaluates to 9 9 CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Racket Questions - Practice Problem 1 The average of n numbers is the sum of the n numbers, all divided by n. Write a function, average, that consumes a number, and produces the average of all the numbers consumed so far. CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Racket Questions - Random The random function consumes a positive integer n, and produces a random number in the range of [0, n-1]. CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Racket Questions - Practice Problem 2 Write a function, print-random, that consumes a number and then displays the numbers from 1 to n in a random order. Eg: > (print-random 5) 1 4 3 2 5 > (print-random 5) 5 1 4 2 3 > (print-random 10) 4 10 3 1 2 9 5 6 7 8 CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Racket Questions - Practice Problem 3 Download the rps.rkt module from the tutorials page on the course website Create a new file that ”requires” rps.rkt, and start it running in the interactions window Reading the comments from the rps.rkt file (reading the code is not nessessary), create a Rock, Paper, Scissors match of 100 games between 2 rock-bots Create a new bot (named paper-bot) that will always defeat rock-bot. Try a match of 100 games between paper-bot and rock-bot (Note that any bot needs to take 1 argument, the history of the match, even if it doesn’t ever use it) Play a match of 100 games between your paper-bot, and markov-bot (which is also provided in rps.rkt) CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Racket Questions - Practice Problem 3 (Cont.) markov-bot is clearly capable of figuring out paper-bots strategy. Try creating a new bot named cycle-bot that cycles through rock, paper, scissors with each call. Try playing 100 games between markov-bot and cycle-bot markov-bot uses markov chaining to deduce your next move based on your previous move. If a bot follows a simple pattern, markov bot should always be able to defeat it. With that in mind, create a bot that follows no pattern . You should be able to get a 33% win rate against markov-bot with it. CS136 Tutorscs136@student.cs.uwaterloo.ca CS136 Fall 2012 - Tutorial 1
Recommend
More recommend