Stats 20 - Lab 1For this lab you are going to focus on outlining your IDEAS for your code prior to writingyour code. You can see an example different levels of pseudocode in week 3 of the TAsite on CCLE for this course. This lab will be due May 6, before the start of class.Your lab should be done in R Markdown and knitted as an HTML or PDF document.You’ll need to submit both a .Rmd file which knits as well as your final output file.1. FibonacciThe Fibonacci sequence (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …) is defined as F(1) = 1, F(2) =1, F(n) = F(n-1) + F(n-2).a. Write pseudocode to calculate F(n)b. Write pseudocode to construct a vector of the first n numbers in the Fibonaccisequence.c. Write a function:fibo(n = 1){# Your code here}which takes one parameter n and returns the nth fibonacci number.d. Use the function you wrote to calculate the 58th Fibonacci number. Include yourR code in your report.2. Tic-Tac-Toea. Write rules of the game.b. Write high-level pseudocode for playing one game between two human players.i. Include pseudocode for what happens before, during, and after the game.c. Identify which elements of the game need to be tracked.i. For each element which you will track:1. Describe the type of object you think is appropriate to store thegame element. (e.g. A numeric vector, a character matrix, adata.frame, etc.). Describe in as much detail as possible how youwould use each object to store its associated game element.d. Identify parts of your pseudocode which could be turned into individual functions.i. For each function you identify:1. List required function inputs.2. List desired function output.3. pseudocode each function.e. A game of tic-tac-toe has, at most 9 turns, write out the turns ofStats 20作业代写、代做R编程设计作业、AI game作业代写、R课程设计作业代做 代做R语言程序|代写R语言程序 a single game,move by move, in language a (normal) human would use to describe the game.Annotate each turn with an explanation of what the repercussions of each moveare with regard to which functions would be called leading up to, during, and aftereach turn, what their input and output values should be, and list what the gameelement variables contain after the turn.A good way to represent the game values is in a table, i.e.:Turn Var1 Var2 Var3 Var40 1 FALSE c() c()1 2 FALSE c(3) c()2 1 FALSE c(3,5) c()... ... ... ... ...f. Discuss what you would need to change or add to create an AI to play tic-tac-toeagainst you.i. What would the simplest AI opponent do?1. pseudocode the simplest AI.a. List the functions this AI would need to call to take its turnand for each:i. Describe the required inputs.ii. Describe the desired output.ii. What would a sophisticated tic-tac-toe AI do?1. pseudocode a sophisticated AI.a. List the functions this AI would need to call to take its turnand for each:i. Describe the required inputs.ii. Describe the desired output.g. Discuss how you would add the functionality to have two AI (the simple andsophisticated) AI play against each other.i. Write pseudocode to play one AI vs AI game.ii. Extend this to allow an arbitrary number of AI games to be played.h. Put all of your pseudocode together into a comprehensive outline forprogramming a complete tic-tac-toe game.i. ATTEMPT to write as much as you can of the actual game of tic-tac-toe betweentwo human players as possible. You do NOT need to write a fully functioningtic-tac-toe game to get full credit on this lab.i. Construct the objects to hold game elements.ii. Write, in R, any functions you are comfortable trying to write.转自:http://www.7daixie.com/2019050430752595.html
网友评论