1) A system uses statistical time division multiplexing, there are 56 channels (56 different signals) being combined into one multiplexed signal. Each channel carries frames with a total length of 1200 bytes. Each frame has a header of 60 bytes. Each channel supports a maximum bit rate of 9.6Mb per second (1KB = 1000 bytes, 1MB = 1000 KB, 1GB = 1000 MB, 1Kb = 1000 bits, 1Mb = 1000 Kb, 1Gb = 1000 Mb). Assume that the average frame rate passing through each channel is 555 frames/s. Assume that the line carrying the multiplexed signals can carry signals at a maximum bit rate of 550 Mb/s.a) [3 points] What is the maximum number of frames per second supported by each channel? b) [3 points] What the average percentage of the time each channel is used? c) [3 points] What fraction of the information being sent is overhead? d) [3 points] What are the average bit rate and the average frame rate summed over all signals?e) [4 points] What is the average data rate summed over all signals? (data only) f) [3 points] What percentage of the line’s capacity will be utilized?2) Consider a transmission line with a transmission rate of 360 Mibps (1Mibps = 220 bits per second). a) [4 points] How many users would the line support? Make the following assumptions: i. Each user has a 15 Mibps connection ii. The line is shared using synchronous TDM iii. Assume that 85% of the capacity of the line may be used for user connections.b) [4 points] How many users can the line support? Why? Make the following assumptions i. Each user has a 15 Mibps connection ii. Each user’s connection is used an average of 34% of the time iii. The line is shared using synchronous TDM iv. Assume that 85% of the capacity of the line may be used for user connections.c) [4 points] How many users can the line support? Make the following assumptions i. Each user has a 15 Mibps connection ii. Each user’s connection is used an average of 34% of the time iii. The line is shared using statistical TDM iv. Assume that 85% of the capacity of the line may be used for user connections.d) [8 points] Suppose there are 66 users, using 10 Mibps connections at the same time. Each user uses their connection 38% of the time. Find the probability that at any given time, exactly 22 users are transmitting simultaneously. Derive an equation then calculate the requested value (Hint: use the binomial distribution).3) [20 points] Consider a local network with one router, that router is connected to the internet through its first network card (interface). The router is connected to the local network through a second interface. All hosts on the local network including the router are on the same physical network segment. A proposal has been made to add a HTTP proxy server to a host in the local network.All HTTP traffic will be processed by the proxy server before being sent onto the Internet. HTTP queries would be sent to the internet only if they could not be satisfied from the HTTP cache. The purpose of adding the proxy server is to reduce traffic on the Internet connection. The local network supports a bit rate of 900 Mbs. The internet connection supports a bit rate of 250 Mbs The average traffic on the local network, excluding HTTP traffic, is 320 Mbs. The average traffic on the Internet connection, excluding HTTP traffic, is 85 Mbs. The average number of internet queries from the network is 135 queries per second Each query has an average size of 1.18 Mb. If a HTTP proxy server is added the number of queries satisfied by the cache will be 62%Determine each of the following: a) HTTP traffic intensity for the local network b) HTTP traffic intensity for the internet without the proxy server. c) The total traffic intensity for the local network without the proxy server.d) The total traffic intensity for the internet connection without the proxy server e) The total traffic intensity for the internet connection with the proxy server Is a proxy server needed?Why? Will the addition of the proxy server solve any problems with traffic intensity your identified? Why? HINT: traffic intensity = traffic(Mbs/sec)/data rate(Mbs)4) Suppose two hosts A and B. Both hosts are part of a packet switched network. A user has a 3 Gb (3*230 bits) file to transfer across the connection. Assume that each link in the packet switched network has a capacity of 900MBps, the propagation delay on each link is 0.0001s, the processing delay at each host is 0.003s, there are no queuing delays, and the packet is transmitted by A and by 9 additional hosts as it travels through the packet switched network to B.a) [5 points] Consider sending the file through the packet switched network as a single packet. Assume that each of the intermediate hosts are store and forward nodes. How long does it take to send the file from A to B?b) [6 points] Assume that the file is segmented into packets containing 12000 bits each. Each packet has a header of 200 bits. If a packet is partially full of data the remainder of the data field is filled with zeros before the resulting full size packet is transmitted. How long does it take for the file to be transmitted through the network (assume no queuing delays).c) [10 points] What is the optimal packet size to transmit this file through this network? To find the optimum express the equation as a function of the amount of data in each packet, Ipacket. Then take a derivative with respect to Ipacket to get the general expression. Finally evaluate the expression to find the optimal packet size for the5) Consider the HTTP protocol. HTTP is the protocol the protocol used for sending the contents of web pages between hosts, from a web server to an agent (client like Firefox or explorer). HTTP is also used by agents to make requests to web servers for particular web pages. HTTP communications, both requests and replies travel through TCP connections. The packets sent back and forth between an agent requesting web pages and the web server sending the web page were captured using the packet sniffer Wireshark. All the provided files provide a list of packets that were transmitted when web pages were requested using the chrome browser on a windows 10 machine.You can download Wireshark and open the pcapng data files supplied with this problem. These files contain a great deal of information about each packet. I will discuss some of the things you can do with Wireshark in the video that will be supplied soon after this assignment is posted. If you try capturing your own packets, please be aware that many license agreements specify you will not capture packets from the application, and using Wireshark may flag you to network admins of the networks you work on as a potential hacker. You do not need to capture any packets to complete this problem. Please use the supplied Wireshark files.Summary data was captured and is provided for you in the files HTTP2020summary.pcapng and HTTP2020conversation.pcapng. Consider only the HTTP packets in the summary file (ignore the packets labeled TCP). The conversation file contains both the HTTP packets and the TCP packets used to transmit the data sent by the server in response the HTTP requests. Both files include both the initial request for one or more web pages and the responses to those requests.Based on the information in these files answer each of the following questions. In each case explain how the contents of the files supports the answer you have given. For parts a), c} support for your answer should include reference to a particular frame or group of frames in the file HTTP2020summary.pcapng, pointing out the useful evidence within the packet or packets.For parts d), e} support for your answer should include reference to a particular frame or group of frames in the file HTTP2020conversation.pcapng, pointing out the useful evidence within the packet or packets.a. [6 points] What is the difference between a basic HTTP GET request and a conditional HTTP get request? After answering this question provide the following information to illustrate your answer: i. Identify by frame number an example packet from the file HTTP2020summary.pcapng for a conditional Get request. Show the line in the file you have selected in your solution. (The line from the list of Wireshark packets)ii. Identify by frame number an example packet from the file HTTP2020summary.pcapng for a Get request that is not conditional. Show the line from the file you have selected in your solution and if possible one for a Get that is not conditional.iii. Explain briefly how you found the packets and the evidence within the packets tell you if the packet is executing a GET or a conditional GET? Show the evidence you site in your answerb. [4 points] What is different about the responses to a basic HTTP GET command and to a conditional HTTP GET request? What information does each type of response return? Would you expect a different response to the conditional get if the web page had been modified between the two requests? No evidence from packets is required for thisc. [4 points] What was the IP address of the computer running the browser (the agent)? What was the IP address of the web server it queried? Explain why the evidence you used from the file HTTP2020summary.pcapng file to demonstrate the addresses you chose were the addresses of the agent and the server?d. [2 points] For one of the HTTP GET responses shown in file HTTP20202conversation.pcapng how many packets were used to carry the HTTP GET response from the server to the client? How did you determine your answer?e. [4 points] Were persistent or non-persistent connections used to download the webpage information from the server? Explain why you think so? Were persistent or nonpersistent connections used to download the webpage information from the server?
Create a program that reads an uncompressed TIFF image file and compress/decompress it. Your program should first show an open file dialog box for the user to select the TIFF file, which follows the same format specification/constraints as in Project 1. Your program should compress the image with your own (1) lossless compression and (2) lossy compression, and then decompress and output the results as follows: 1. Displays the original image (right side) together with the decompressed image from lossless compression (left side) ( – yes, these two should look exactly the same, but if you use some conversions or transforms, e.g., RGB to YUV, then there would be small round off errors; it’s good if you provide discussions on their impact) ; also display the compression ratio at the bottom; 2. Refreshes by the original image (right side) together with the decompressed image from lossly compression (right) of a compression ratio around 10; also display the exact compression ratio at the bottom; 3. Refreshes by the original image (right side) together with the decompressed image from lossly compression (right) of a compression ratio around 20; also display the exact compression ratio at the bottom. We can accept a range of [8,12] for compression ratio 10 and [16,24] for compression ratio 20. You should submit the source code together with its executable version. You should also submit a short report (2-3 pages) describing the following issues: 1. The key techniques used in your solution and their respective impacts to the image quality. You may want to draw a simple diagram for the processing flow (like that for JPEG in the slides); 2. The percentage of the computation times of the different modules (try to figure out a way to measure them); 3. Image quality comparison with other commercial tools (e.g., Photoshop); 4. Any other problem/interesting issues you have encountered. Grading scheme: 2 of 2 1. File input (2 marks) 2. Lossless compression implementation (4 marks) 3. Lossy compression implementation (8 marks) 4. Discussion in report (6 mark)
Create a program that reads an uncompressed TIFF image file and display it on the screen. A brief introduction and historical review of TIFF can be found at https://en.wikipedia.org/wiki/TIFF Details about the TIFF 6.0 format can be found in TIFF6.pdf as well as many other places online. Only the 24-bit RGB full color uncompressed mode in TIFF will be considered (see Section 6: RGB Full Color Images in TIFF6.pdf). You can assume that the image is no bigger than the 4*CIF size (i.e., 704*576). You can ignore header tags that are not used in this project. Your program should first show an open file dialog box for the user to select the TIFF file. It should then work as follows: 1. Displays the original colored image; 2. Refreshes by the corresponding grayscale image of the original image; 3. Refreshes by applying ordered dithering on the grayscale image; 4. Refreshes by making the brighter part of the image darker and the darker part brighter, which is known as “adjusting the dynamic range” in photo editing. To move to the next step, your can either place a “next” button on screen, or pause until any key is pressed. Go back to step 1 after step 4. There should also be a “quit” button. We will not specify any dither matrix. You can experiment different ones and choose a good one. You need to discuss your choice of the dither matrix in the report. For adjustment of dynamic range, you should experiment different ways/thresholds and discuss the effects, too. Grading scheme 1. File input (2 marks) 2. Display the color and grayscale images (4 marks each) 3. Display the dithered image and discuss about the dither matrix (5 marks) 4. Dynamic range adjustment and discuss about your solutions/experiments (4 marks) 2 of 2 Rationale of doing this project: 1. Learn a media file format and how is it specified. You will find that there are so many fine details. There are so many different formats in industry (see for example Murray, James D.; vanRyper, William (April 1996). “Encyclopedia of Graphics File Formats” (Second ed.). O’Reilly. ISBN 1-56592-161-5. ) Yet as long as you have experience with one format, you’ll find that you can easily hack most others. In fact, TIFF is known as the “base” or “origin” of many other formats. 2. Have some inside knowledge about some Photoshop operations, e.g., remove color, adjust dynamic range. We will see more in next project. You will then find that you know Photoshop (or other similar tools) much better, and you can indeed write your own. 3. Have some taste about research. Say for the choice of dither matrix and dynamic range adjustment, we expect that you find a good one (or the best trade-off) through your own design/experiments, while not simply and passively look for an answer from textbook. The discussion part will be the highlight of your report, which will showcase your own hard works and distinguish yourself from others. (same for Programming assignment)
Q. 1. (LZW coding) Read a sequence that consists of letters A, B, and C only and assume that the initial dictionary is 0 A 1 B 2 C (1) Print out the output sequence for the input sequence using the LZW coding algorithm. (2) Print out the dictionary in the end of the LZW coding. The length of the input sequence is no more than 64 letters. Q.2. 2D (Discrete Cosine Transform) Read N (an integer between 2 and 10) and then an input matrix of size NxN, print out the 2D DCT transform result (rounding to integers). See Slide 41 in Lossy compression for an example. Note that you can’t call any lib to do this; you have to write your own code to implement the matrix operation.
Q. 1. Given input Y U V = 156, 28, 37, print out the corresponding Y Co Cg and the average running time of your code. (A trick here is to use a loop to automatically run your program many times, say, 1 million times, and then take the average). Discuss the complexity of your program and make it as fast as possible (and discuss your optimization). Your marks will depend on the correctness, the speed, and more importantly the insight presented in your discussion.Q. 2. Given an NxN picture (N in [4..16], and each pixel has a grey level in [0..255]), and an MxM dither matrix, where N is always an integer multiple of M. Print out resultant pictures with halftone printing and with ordered dithering, representatively. You may use “1” to represent “on”, and “0” otherwise.
Texbook 3 rd Edition (Please see Canvas/Files or Dropbox for the 3 rd Edition chapters) P. 297 Q4, 5(a) P. 336 Q4 P. 364 Q8 (a)(b) P. 530 Q9 EX.1. Give the ZigZag scanned runlength coding output (0,45), (3, 28), (7,12), (0, 11), (12,7), (0,0) for a 8×8 block, what’s the input? If we simply use the regular left-to-right, top-to-bottom scan instead of the ZigZag scan, then what is the corresponding output of the runlength coding? EX. 3. Which is the most time-consuming part in video compression? Explain your answer.
Texbook 3 rd Edition (Please see Canvas/Files or Dropbox for the 3 rd Edition chapters) 7.8 Q1, 3, 13 EX1. Give sequence 01101100110011100011011101100111 (1) What is the second-order entropy of this sequence ? (2) What is the average codeword length (per symbol) if we use 2-symbol extended Huffman coding ?EX2. Given input sequence acbbaca and assume that the initial dictionary is 0 a 1 b 2 c (1) What is the output sequence for the input sequence using the LZW coding algorithm ? (2) What is the dictionary in the end of the LZW coding ? EX3. Give sequence aabbba What are the lower and higher bounds of the final interval in arithmetic coding?
Texbook 3 rd Edition (Please see Canvas/Files or Dropbox for the 3 rd Edition chapters) 1.5 Q5 6.4 Q1, 2, 4, 8, 12, 4.4 Q 8, 9 EX1: Assume that a PC has a working noise of 50 dB. What will be the working noise of 5 such PCs ? What about 10 such PCs? EX2: Assume that a camera’s CCD sensor has some error in capturing colors. Basically, its R becomes (real) R/2+G. Design a matrix that correctly converts its captured R, G, B to the real Y, U, V. EX3: List three multimedia applications that were launched in recent five years. For example, TikTok, social media sharing platform for short videos, 2017
Question 1 (4 marks) The table on the right contains (fictitious) examples of holiday trips. Relevant attributes are the destination country of the trip, the season during which the trip took place, the type of trip, and its length in weeks. The target attribute is how much fun the trip was. attributes goal example country season type weeks fun 1 Italy summer repose 2 much 2 Italy winter sports 1 much 3 Austria winter culture 1 little 4 Austria winter repose 3 little 5 Austria winter sports 1 much 6 Spain summer repose 3 much 7 Spain summer sports 2 much 8 Spain winter repose 2 little (You may assume that all possible values of the attributes are already mentioned in the examples.)(a) Generate a decision tree from these examples using the Decision-Tree-Learning algorithm in order to predict the expected fun for arbitrary holiday trips. Determine the best attribute for each test by means of computing information gains. Please show and explain all steps.(b) From the examples, find two decision lists (DL) predicting the expected fun. The first list should comply with (i), the second with (ii). (i) The tests of the DL contain as few literals as possible (e.g. only one, if possible). (ii) The DL consists of as few tests as possible (e.g. only one, if possible).Question 2 (3 marks) The table on the right contains (again fictitious) examples of observations about movies. Attributes represent the genre of the movie, the number of celebrity main actors, the amount of marketing that was done, the production costs, and whether the movie was well received by critics or not. attributes goal example genre actors marketing cost reception 1 SciFi 2 much high good 2 Comedy 3 little low bad 3 Comedy 1 little medium bad 4 Drama 2 much low good 5 Drama 1 little high good 6 SciFi 3 much low good 7 Comedy 1 little high good 8 SciFi 2 little low badIn this question, a perceptron shall be trained using the examples in the table. To this end, in part (a), the attributes have to be transformed into numeric inputs first. Then, in part (b), Neural-Network-Learning can be applied.(a) For encoding the examples use the eight inputs ID, IC, IS, I#, IM, Ih, Im, Il , where the attributes “genre”, “marketing”, “cost” are encoded by the following schemes: genre ID IC IS Drama 1 0 0 Comedy 0 1 0 SciFi 0 0 1 marketing IM much 1 little 0 cost Ih Im Il high 1 0 0 medium 0 1 0 low 0 0 1The values of the attribute “actors” can directly serve as input I# since they are numeric. For the goal attribute “reception”, 1 represents “good” and 0 represents “bad”. Set up the following table of transformed examples where T denotes the correct output. example ID IC IS I# IM Ih Im Il T 1 0 0 1 2 1 1 0 0 1 2 . . . 8For which of the attributes “genre”, “actors”, “marketing”, “cost”, and “reception” did we use local encoding, and for which ones or distributed encoding? 2 (b) Use the transformed examples of part (a) to train a perceptron that has eight inputs, namely ID, IC, IS, I#, IM, Ih, Im, Il with corresponding weights WD, WC, WS, W#, WM, Wh, Wm, Wl . Let the activation function be step0 , the learning rate be 2, and the weights initialized by +1. (For the given examples, these settings yield a fast convergence.)As a trace of the Neural-Network-Learning algorithm applied to the examples of part (a), set up the following table where O denotes the perceptron output and E = T − O is the error. You must include the output and the error for every example but you may omit weights whose values are not changed. In the table below, the first half of epoch 1 is already entered. example O E WD WC WS W# WM Wh Wm Wl initial. +1 +1 +1 +1 +1 +1 +1 +1 epoch 1 1 1 0 2 1 −1 −1 −5 −1 3 0 0 4 0 +1 +3 −1 +3 +1 5 6 7 8 epoch 2 1 . . . 8 epoch 3 . . . [Hint: If you did not make a mistake — neither here nor in part (a) — it should turn out that all examples are correctly predicted in epoch 3. Thus use this hint to verify your solution (as a necessary (but not sufficient) condition).]You are invited to solve this question by implementing the perceptron learning algorithm and applying the program to the given examples. Of course, you can solve it “by hand”, too.Question 3 (3 marks) (a) Construct a feed-forward neural network that has at most one hidden layer (i. e., it is a perceptron or a feed-forward 2-layer network) and represents the 3-ary Boolean function f1(x1, x2, x3) = (x1 ≡ (x2 ∧ x3)) using only step functions as activation functions.1(b) Can the following Boolean function be represented by a perceptron, using only step functions? If yes, present one, if no, explain why this is the case. f2(x1, x2, x3) = (x1 ∧ x2 ∧ x3) ∨ (¬x1 ∧ ¬x2 ∧ ¬x3)) 1 stept (x) = 0 , if x < t; stept (x) = 1 , if x ≥ t.
Question 1 (3 marks) Alice, Bob, and Christine belong to the Alpine Club. Every member of the Alpine Club who is not a skier is a mountain climber. Mountain climbers do not like rain, and anyone who does not like snow is not a skier. Bob dislikes whatever Alice likes, and likes whatever Alice dislikes. Alice likes rain and snow.(a) Prove that the given sentences logically imply (entail) that there is a member of the Alpine Club who is a mountain climber but not a skier. For this purpose, express the statements as a set of FOL formulas KB, formulate an appropriate query α, and then apply the Resolution method. Use answer extraction to find out who that individual is.In your formulation, use the following vocabulary: • C (x): Predicate. Person x is a member of the Alpine Club. • S(x): Predicate. Person x is a skier. • M (x): Predicate. Person x is a mountain climber. • L(x, y): Predicate. Person x likes y.• a, b, c: Constants denoting the three persons. • r , s: Constants denoting rain and snow, respectively.(b) Suppose we had been told that Bob likes whatever Alice dislikes, but we had not been told that Bob dislikes whatever Alice likes. Prove that the resulting set of sentences KB0 no longer logically implies that there is a member of the Alpine Club who is a mountain climber but not a skier. For this purpose, present a logical interpretation I that is a counterexample, i.e. where I |= KB0 , but I 6|= α. 1For the purpose of this assignment, we assume that “x dislikes y” means ¬L(x, y).Question 2 (3 marks) Consider the following simplified variant of the wellknown Blocks World. There are three blocks A, B, and C, each of which is initially located on the table T. The goal is to have A on B and B ontop of C. The robot can perform the following two actions:• Move(x, y, z): move block x from y onto block z. This requires that x is on y and both x and z are clear. • MoveToTable(x, y): move block x from y onto the table. This requires that x is on y and x is clear. A C A B B C T T(a) Present Strips operators for the two actions together with the initial state (Start) and the goal (Finish). Use the predicates On(x, y) to denote that block x is on (block or table) y and Clear(x) to say that there is no block on top of block x.(b) Draw the partial plan that results from first introducing Move(B, y1, C) and then Move(A, y2, B), each satisfying one precondition of Finish. Satisfy the remaining open preconditions by means of Start using appropriate variable assignments where necessary. Use solid lines for causal links and dashed lines for ordering constraints. Since a causal link always implies an ordering, you do not have to draw both arrows in these cases but only the one for the causal link.(c) Indicate where the plan contains a conflict by circling the precondition/effect pair that causes this threat. Resolve the conflict by either promotion or demotion and draw the resulting plan. Is the plan now consistent? Is it complete?Question 3 (2 marks) In an exam a professor asks a student three questions. If the student is well-prepared she can give the right answer to any of these questions with a probability of 95 %. Otherwise she will have a 30 % chance to answer the first question correctly, a 50 % chance to answer the second question correctly, and only a 10 % chance to answer the third question correctly. If the student is (or is not) well-prepared, answering some questions correctly or not neither increases nor decreases the chance for answering another question correctly. Normally, 4 out of 5 students are well-prepared. Let Qi stand for answering question i correctly, and W for being well-prepared.(a) Which (unconditional or conditional) probabilities are directly given in the above text with what values? [Hint: There are exactly seven.] (b) Compute: P(W | Q1), P(Q1, Q2 | ¬W), P(Q3 | Q1, Q2, W). (c) If the student answers the first and second question correctly but gives a wrong answer to the third question: How probable is it that the student is well-prepared? In other words: Compute P(W | Q1, Q2, ¬Q3).(d) Compute P(W | Q1, ¬Q2, ¬Q3).2 (e) Why is it important that correct or incorrect answers to some questions do not influence the chance for answering another question correctly? 2Are you surprised by this value compared to part (c)) because of the 50 % chance of the second question? If you like you can compute P(W |(¬)Q1,(¬)Q2,(¬)Q3) for all the other combinations of the Qi and ¬Qi .Question 4 (2 marks) In the belief network on the right the random variables S, R, L, W stand for “season”, “raining”, “lawn sprinkler on”, “sidewalk wet”, respectively. The CPTs (Conditional Probability Tables) for R, L, W are given by the following tables: S P(R | . . .) spring 0.45 summer 0.15 autumn 0.35 winter 0.20 S P(L | . . .) spring 0.15 summer 0.30 autumn 0.05 winter 0.00 R L P(W | . . .) T T 0.95 T F 0.95 F T 0.90 F F 0.05 S R L WThe prior probability for each of the four seasons (spring, summer , autumn, winter ) is 0.25. The accuracy of your answers (to all parts of this exercise) should be at least three decimal places. (a) Compute P(W ∧ ¬L ∧ R ∧ S=spring).(b) If it is not raining and the lawn sprinkler is off: how likely is winter? (i. e.: Compute P(S=winter | ¬R ∧ ¬L).) (c) What is the probability for rain in the summer when the sidewalk is wet? 3 (i. e.: What is P(R | W ∧ S=summer )?) 3Before computing it, try a rough guess. (Guess at least whether it is greater or less than 0.5?)
Question 1 (2 marks) For each of the following assertions, say whether it is true or false and give a brief justification (i.e., no more than 1–3 sentences) to support your answer. (a) An agent that senses only partial information about the state cannot be perfectly rational. (b) There exist task environments in which no pure reflex agent can behave rationally.(c) There exists a task environment in which every agent is rational. (d) Every agent function is implementable by some program/machine combination. (e) Suppose an agent selects its action uniformly at random from the set of possible actions. There exists a deterministic task environment in which this agent is rational.(f) It is possible for a given agent to be perfectly rational in two distinct task environments. (g) Every agent is rational in an unobservable environment. (h) A perfectly rational poker-playing agent never loses.Question 2 (3 marks) Consider the MAX-MIN game tree shown below where the numbers underneath the leaves of the tree are utility values from the first player’s point of view (MAX). A B D E I J K C F G L N O M H 9 17 11 15 7 6 13 8 1 max min max min(a) Draw a copy of the tree on paper and perform the minimax algorithm on it by hand. Write the resulting minimax values next to every node. (b) Do the same, but with left-to-right alpha-beta pruning. Write the final values for α and β next to every node, and indicate which nodes are not examined due to pruning.(c) Do the same, but with right-to-left alpha-beta pruning. Again, show the final values for α and β, and indicate which nodes are not examined.Question 3 (3 marks) Consider the following two-player game (players A and B): The starting position of the simple game is shown on the right: A B 1 2 3 4 Player A moves first. The two players take turns moving, and each player must move his token to an open adjacent space in either direction. If the opponent occupies an adjacent space, then a player may jump over the opponent to the next open space if any. (For example, if A is on 3 and B is on 2, then A may move back to 1 or forward to 4.) The game ends when one player reaches the opposite end of the board. If player A reaches space 4 first, then the value of the game to A is +1; if player B reaches space 1 first, then the value of the game to A is −1.(a) Draw the complete game tree using the following conventions: • Annotate each terminal state with its game value in a circle. • Treat loop states as terminal states. Since it is not clear how to assign values to loop states, annotate each with a question mark in a circle. Loop states are states that already appear on their path to the root at a level in which it is the same player’s turn to move.(b) Now mark each node with its backed-up minimax value (also in a circle). Explain how you handled the question mark values and why. (c) Explain why the standard minimax algorithm would fail on this game tree and briefly sketch how you might fix it, drawing on your answer to part (b). Does your modified algorithm give optimal decisions for all games with loops?(d) Which player has a winning strategy, and what does it look like? And what can be said about the general case, when instead of a 4-square game, we consider an n-square game for n > 2?Question 4 (2 marks) Consider a vocabulary with the following symbols: • Occupation(x, y): Predicate. Person x has occupation y. • Customer (x, y): Predicate. Person x is a customer of person y. • Boss(x, y): Predicate. Person x is a boss of person y. • doctor , surgeon, lawyer , actor : Constants denoting occupations. • emily, joe: Constants denoting people.Use these symbols to write the following assertions in first-order logic: (a) Emily is a surgeon or a lawyer. (b) Joe is an actor, but he also holds another job. (c) All surgeons are doctors. (d) Joe does not have a lawyer (i.e., is not a customer of any lawyer). (e) Emily has a boss who is a lawyer. (f) There exists a lawyer all of whose customers are doctors. (g) Every surgeon has a lawyer.
In this assignment you get a chance to experiment with some (informed) search algorithms. In the aima-python repository, take a look at the class called EightPuzzle. Take some time to read and understand it, including the Problem class that it inherits from.Put the coding part of your answers to the following questions in a Python 3 file named a1.py that starts like this: # a1.py from search import * # … Do not use any modules or code except from the standard Python 3 library, or from the textbook code from Github. 1https://www.python.org/ 2https://github.com/aimacode/aima-pythonWrite a function called make rand 8puzzle() that returns a new instance of an EightPuzzle problem with a random initial state that is solvable. Note that EightPuzzle has a method called check solvability that you should use to help ensure your initial state is solvable. Write a function called display(state) that takes an 8-puzzle state (i.e. a tuple that is a permutation of (0, 1, 2, …, 8)) as input and prints a neat and readable representation of it. 0 is the blank, and should be printed as a * character.For example, if state is (0, 3, 2, 1, 8, 7, 4, 6, 5), then display(state) should print: * 3 2 1 8 7 4 6 5By default, the A∗ implementation in aima-python uses the misplaced-tiles heuristic. In your program, include top-level code such that when the program is executed, it creates a random 8-puzzle problem instance (using your code above), prints the instance, and solves it by means of A∗. Afterwards, it should report: • the total running time for the search algorithm in seconds; • the length (i.e. number of tiles moved) of the solution; • the total number of nodes that were expanded during search.You will probably need to make some modifications to the A∗ code to get all this data. Also, be aware that the time it takes to solve random 8-puzzle instances can vary from less than a second to hundreds of seconds (see hints below)! Modify your program such that the user can optionally provide the initial state for a problem instance on the command line. For example, to solve (0, 3, 2, 1, 8, 7, 4, 6, 5), the program should be called using $ python3 ai.py 0 3 2 1 8 7 4 6 5 If no instance is given, the program instead creates the random instance as described above.Write a function manhattan(n) that implements the Manhattan distance heuristic, taking a Node n as its argument. Extend your top-level code such that it additionally runs A∗ using this heuristic function. Be careful: there is an incorrect Manhattan distance function in tests/test search.py. Don’t use that, but implement your own (correctly working!) version.One relaxation of the 8-puzzle is the assumption that a tile can move from one square to the blank position directly, even if it is not a neighbouring square. The exact solution of this problem defines Gaschnig’s heuristic. Implement it in a function called gaschnig(n), and again extend your top-level code such that it additionally runs A∗ with this heuristic.Create 10 (more would be better!) random 8-puzzle instances (using your code from above), and solve each of them using the 3 different heuristics for the A∗ algorithm. Each version should be run on the exact same set of problems to make the comparison fair.Write a PDF document in which you discuss your results. It should at least contain a (single) table that summarizes your data. Be sure to include helpful descriptive statistics like the min, max, average, and median values. You are also encouraged to include helpful or informative graphs of your data.Furthermore, in your PDF, answer the following questions: • Based on your data, can you give a recommendation for what you think is the best algorithm? Explain how you came to your conclusion.• Is it possible to rule out one of the heuristic functions without looking at experimental data, but purely based on theoretical consideration? Hint: We say that an admissible heuristic h1 is at least as accurate as another admissible heuristic h2 iff for every n, h1(n) ≥ h2(n). • Can you suggest a heuristic that is always at least as accurate as all 3 heuristic functions discussed here?What to Submit Please put all your code into a single Python 3 file named a1.py, all your data, tables, charts, discussion, etc. in a PDF file named a1.pdf, and submit them on Canvas before the due date listed there.If you want to make changes to code in search.py, or in files other than a1.py, please copy the code you want to change into a1.py, and change it there. Don’t make any changes to other files in the textbook code.Hints • When you are testing your code, you might want to use a few hard-coded problems that don’t take too long to solve. Otherwise, you may spend a lot of time waiting for tests to finish!• One easy way to time code is to use Python’s standard time.time() function, e.g.: import time def f(): start_time = time.time() # … do something … elapsed_time = time.time() – start_time print(f’elapsed time (in seconds): {elapsed_time}s’) Python has other ways to do timing, e.g. check out the timeit module.• To process command line arguments, use the sys module: import sys print(’Number of arguments: ’, len(sys.argv)) print(’Argument List: ’, sys.argv) Running the above as file test.py using $ python test.py arg1 arg2 arg3 yields Number of arguments: 4 Argument List: [’test.py’, ’arg1’, ’arg2’, ’arg3’] Note that the filename of the program is considered the first argument.• If you download the textbook code as a Git repository, then you can create a branch called a1 for this assignment, e.g. something like: $ git branch a1 git checkout a1 This way you can make any changes you like while maintaining a copy of the original code. You are not required to use Git, but since the code is stored as a Git repository, it’s probably the best way to get it.
When adding real numbers expressed in scientific notation (base 10), we must first transform them such that they have the same exponent. For example, 3.1416 + 1.0 x 103 must be transformed to 3.1416 + 1000.0. Once the numbers are expressed with the same exponent, we need to align their decimal point, then we can add them (1003.1416 = 1.0031416 x 103).The same is true when adding IEEE floating point numbers, except that the base we are working with is 2.Perform the following IEEE floating point number additions following the algorithm described above, i.e., first, transform the IEEE floating point numbers (expressed as hexadecimal numbers) such that they have the same exponents, align their binary points and add them. Express their sum as an IEEE floating point number, then express this IEEE floating point number as a hexadecimal number. Show your work and clearly show the result of rounding, if rounding occurs.where 0.16666667 approximates 0x3E2AAAAB and 0.83333333 approximates 0x3F555555Assume the following values are stored at the indicated memory addresses and registers:Imagine that the operands in the table below are the Src (source) operands for some unspecified assembly instructions, fill in the following table with the appropriate answers.Note: We do not need to know what these assembly instructions are in order to fill the table. Still using the first table listed above displaying the values stored at various memory addresses and registers, fill in the following table with three different Src (source) operands for some unspecified assembly instructions. For each row, this operand must result in the operand Value listed and must satisfy the Operand Form listed.Requirement 1:We would like to write assembly code (instruction(s)) that multiplies the value stored in the register %esi by c, where c is a positive integer constant (fits in 32 bits), and stored their product in the register %eax, i.e., %eax arith.objdumpWe display the partial content of arith.objdump below. The file arith.objdump is the disassembled version of the executable file ar.Your task is to fill in its missing parts, which have been underlined:0000000000400527 : 400527: 48 8d 04 37 lea (%rdi,%rsi,1),%rax ___40052b___: 48 01 d0 add %rdx,%rax 40052e: 48 8d 0c 76 lea (%rsi,%rsi,2),%rcx 400532: 48 c1 e1 _4_ shl $0x4,%rcx 400536: 48 8d 54 0f 04 lea 0x4(%rdi,%rcx,1),%rdx 40053b: 48 0f af c2 imul %rdx,%rax _40053f_____: c3 retq Do the Homework Problem 3.58 at the end of Chapter 3 and include your program called decode2.c below. Make sure you satisfy the following requirements:Once you have created you program decode2.c, generate its assembly code version using the optimization level “g” (–Og) and call it decode2.s. Include it below as well without making any modifications to it.You do not have to electronically submit your program on CourSys. However, your program must be functionally correct (i.e., it must compile, execute properly and solve this problem).
For each of the above rounded binary numbers, indicate what type of rounding you performed and compute the value that is either added to or subtracted from the original number (listed above) as a result of the rounding process. In other words, compute the error introduced by the rounding process.Below is a table listing several real numbers represented as 6-bit floating-point numbers (w = 6). The format of these 6-bit floating-point numbers is as follows: 1 bit is used to express for the sign, 3 bits are used to express “exp” (k = 3) and 2 bits are used to represent “frac” (n = 2), in the following order: sign exp frac.Complete the table (the same way as in Figure 2.35 in our textbook) then answer the questions below the table.Tip: Have a look at Figure 2.35 in our textbook, which illustrates a similar table for a hypothetical 8-bit floating-point format. This will give you an idea of how to complete the table. Also, Figure 2.34 displays the complete range of these 6-bit floating point numbers as well as their values between -1.0 and 1.0. This diagram may be helpful when you are checking your work. Expressed these differences (“delta”) as decimal numbers.
a. Convert each of the unsigned decimal values below into its corresponding binary value (w = 8), then convert the binary value into its corresponding hexadecimal value. I. 15710 II. 24810b. Convert each of the signed decimal values below into its corresponding two’s complement binary value (w = 8), then convert the binary value into its corresponding hexadecimal value. I. 12310 III. -7410c. Interpret each of the binary values below first as an unsigned decimal value, then as a signed decimal value (using the two’s complement encoding scheme). I. 111010012 II. 100101102d. Convert 24710 into a signed value directly, without converting it first to its corresponding binary value (w = 8). e. Convert -15210 into a unsigned value directly, without converting it first to a binary number (w = 8).2. [6 marks] Unsigned and signed arithmetic operations and overflow For a. below, convert each of the operands (unsigned decimal values) into its corresponding binary value (w = 8). For b. below, convert each of the operands (signed decimal values) into its corresponding two’s complement binary value (w = 8).For a. and b. below, perform both the decimal addition and the binary addition and indicate the true sum and the actual sum and whether they are the same or different. For the binary addition, clearly label all carry in bits (by using the label “carry in”) and the carry out bit (by using the label “carry out”).Finally, indicate whether or not an overflow occurred (for signed values, specify whether the overflow is positive or negative). If an overflow occurred, explain how addition overflow can be detected … 1. at the bit level, and 2. using the decimal operands. a. Unsigned addition: I. 7410 + 6310 II. 12310 + 15710 b. Signed (two’s complement) addition: I. 2810 + -7410 II. -11710+ 12610 III. 7410 + 6310 IV. -11910 + -105103. [8 marks] C Code, endian and bit-level manipulation Download and extract Assn1-files and open Assn1_Q3.c, Assn1_main.c and makefile in a text editor. Read and understand their content. Using the makefile, compile and execute the program.Requirements: While answering this question, you must not change the prototype of the functions given. The reason is that these functions will be tested using a test driver built based on these function prototypes.a. Modify the printf statement of the show_bytes(…) function such that it first prints the memory address of each byte then the content of the byte itself. Here is an example: 0x7ffe5fb887cc 0x80 where 0x7ffe5fb887cc is the memory address of a byte which contains the value 0x80. Compile and test your program.b. Looking at the output of this program, would you say that the CSIL computer you are using is a little endian or a big endian computer? Justify your answer by including some of the output of your program in your answer.c. Modify the loop of the show_bytes(…) function such that, instead of using array notation to access each element of the array start, it uses pointer notation to access each of these elements. The output of your program should remain the same as in a. above.d. Write a function called show_bits( … ). This function must have the following prototype: void show_bits(int); This function must print the bit pattern of the parameter of type int. Compile and test your program. Here are two test cases (data and expected results) to illustrate the behaviour of this function: Test Case 1: If the parameter (int) is 12345, then show_bits( … ) prints: 00000000000000000011000000111001 Test Case 2: If the parameter (int) is -12345, then show_bits( … ) prints: 11111111111111111100111111000111 Add this function to Assn1_Q3.c.e. Write a function called mask_LSbits( … ). This function must have the following prototype: int mask_LSbits( int n );This function creates (returns) a mask with the n least significand bits set to 1. For example, if n is 2, the function returns 3 (i.e., 0x00000003) and if n is 15, the function returns 32767 (i.e., 0x00007fff). What happens when n >= w or when n = w, your function must return a mask of all 1’s. When n
Overview In this assignment, you are to create a Tokimon finder game. You are a Tokimon trainer who is trying to collect all Tokimons within a 10 cell by 10 cell game grid. You have no knowledge of what is in each unvisited cell and at each turn you will make a move to explore a new location on the grid. The grid can be occupied by (i) a Tokimon, (ii) a Fokimon or (iii) nothing. Fokimons are evil bird-like creatures who purpose is to harm Tokimon trainers. If you end up on a cell occupied by a Fokimon, you lose the game!• Your game should start by accepting anywhere from 0 to 3 arguments to main(). The arguments to the program will provide options for gameplay, the options are: –numToki=X (where X is a positive integer >= 5): this determines the number of Tokimons in the 10×10 grid–numFoki=X (where X is a positive integer >= 5): this determines the number of Fokimons in the 10×10 grid –cheat puts program into cheat mode. See below. o If the number of Tokimons is not specified, use a default value of 10. If the number of Fokimons is not specified, use a default of 5. For example, assuming the main() method is located in TokimonFinder (see Technical requirements):> java TokimonFinder –numToki=20 –numFoki=6 will specify 20 Tokimons and 6 Fokimons on the game grid. You should provide some basic error checking for the options. • The program will then randomly choose positions on the grid to put the Tokimons and Fokimons.• The game grid has the columns numbered 1, 2, … and has the rows lettered A, B, … • The program will begin by asking user for an initial position: o For example, B5, and then enter.• The player will also begin with 3 spells. Using a spell can either: 1. Jump the player to another grid location 2. Randomly reveal the location of one of the Tokimons or 3. Randomly kill off one of the Fokimons It is up to you how you would like to do this.• At each turn, the player is prompted for the next move, the player can choose to 1. Move up, down, left, or right from their current position (key W, A, S, or D) or 2. Use a spell Choosing option 2 will result in further prompting as described in the previous point. • If a move results in the player landing on a cell occupied by a Fokimon, the game will be over, and the player loses.• If a move results in the player landing on a cell occupied by a Tokimon, the player should be notified and congratulated. • After each turn, the player is shown the number of Tokimons they have collected, the number of Tokimons remaining, and the number of spells remaining.• At each turn, the player is shown a map of what is known about the game-grid so far: o ~ indicates unknown (unvisited) o $ indicates a found Tokimon o ‘ ’ (space) indicates a visited but empty location. o @ player’s current position• A player wins when all Tokimons on the board have been collected. • When the game ends, the player is shown the complete board including X’s to indicate the positions of the Fokimons.• CHEAT MODE: if the option –cheat was included in the main() call, the program should show the user the full board (including the positions of all Tokimons and Fokimons) before starting the game. Technical Requirements: • Main class should be in a file called TokimonFinder.java• Must exhibit good OOD principles: o You must have two packages: One package for the UI related class(es); another package for the model related classes (actual game logic). Imagine that you wanted to have not only a text game, but also a web version. You should be able to reuse the entire model (game logic) in a completely different UI.o Each class is responsible for one thing. o Reasonably detailed break-out of classes to handle responsibilities. o Each class demonstrates correct encapsulation. o Consider use of immutable classes where applicable. o Respect the command/query separation guideline when appropriate. • The game is to use a text interface for display, and the keyboard for input. • Implementation must follow the online style guide. Specifically, important are: o Good class, method, field, and variable names. o Correct use of named constants. o JavaDoc – Good class-level comments (comment on the purpose of each class). o Clear logic.• OOD Hint: o When you have some complex state, it is often best to encapsulate it into an object. Consider having an object for storing the state of each cell of your gamegrid. Store a group of these to makeup the game grid.Design: Complete the following steps to create an object-oriented design for this application. 1. Use case • Create a use case for the game. Hint: it will be titled “Play game”. • Provide a reasonable list of steps for playing the game from the user’s perspective. For example, how to recover from incorrect user input without crashing (use a Use Case variation). • This must be typed on a computer and submitted as a text or PDF file named USECASE.TXT (or .PDF). Place this file in the docs/ folder of your project (you will need to create this folder).2. CRC Cards • Create CRC cards to come up with an initial object-oriented design. • Do not submit the actual cards, but once you have settled on a design, you must type up the information stored on the CRC cards, or take a picture of the cards. • Each card must show the class name, responsibilities, and collaborators. Submit this as a .txt, .pdf, or .jpg/.png file named CRC.TXT (or .PDF,…) in the docs/ folder. If you take a picture, ensure that the text is clear, and that the image is less than one MB.3. UML Class Diagram • Create an electronic UML class diagram for your OO design. • The diagram should not be a complete specification of the system, but rather contain enough information to express the important details of your design. • Your diagram must include the major classes, all class relationships, and some key methods or fields that explain how the classes will support their responsibilities. • You must use a computer tool to create the diagram. We will discuss some free software for doing this . You may not generate the diagram directly from your Java code.• Submit your UML diagram as a PDF or image file named CLASSDIAGRAM.PDF (or .PNG, or .JPG, …) in the docs/ folder. Implementation: • Implement the game in Java. • You must implement according to your OOD from the Design Phase. • Source Control: Although not a requirement, you may find it helpful (especially if you’d like to use this for your portfolio). o If you’d like to develop using GIT, you can use SFU’s GitLab: https://csil-git1.cs.surrey.sfu.ca/ o (Do not use GitHub unless you keep your projects closed source; do not share your code publicly during the course, otherwise it counts as academic dishonesty).Marking Scheme: Phase 1: Design – Total [15] Marks – [3] Use case – Reasonable description of the steps for playing the game from the user’s point of view. – [3] CRC – Reasonable break-out of classes and high-lever responsibilities. List major class collaborators. – [9] UML Class Diagram – Clear OOD, Correct and meaningful class relationships. Some methods and/or fields listedPhase 2: Implementation – Total [35] Marks – [4] Correctly handle command line arguments – [3] Game-grid display – [3] User interaction handles errors – [15] Correct game-play handling player moves – [5] Correct handling of the remaining workflow & win/loss. – [3] Game polish: Clear messages, nice layout. – [2] CreativityCorrectly follow coding style guide. – Total [0] Marks – [-8] Up to 8 point max deductionsSubmission Submit a zip file of your project (according to the directions outlined in the assignments link of the course website) to the coursys server. https://courses.cs.sfu.ca/. Your project must generate a JAR file as part of the build process. Please note: all submissions are automatically checked for similarities of all other submissions on the server. In addition, you must submit your files from the design phase: 1. USECASE.TXT (or .PDF) 2. CRC.TXT (or .PDF, or JPG) 3. CLASSDIAGRAM.PDF (or PNG, or .JPG)Sample game grids: These are just samples, you do not have to follow this convention. In fact, please try to come up with more interesting UI. 1. During gameplay, when a Tokimon is discovered, after a few cells have been visited. Game Grid: 1 2 3 4 5 6 7 8 9 10 A ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ B ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ C ~ ~ ~ ~ ~ ~ ~ ~ ~ D ~ @$ ~ ~ ~ ~ ~ ~ ~ E ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ F ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ G ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ H ~ ~ ~ ~ ~ ~ ~ I ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ J ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 2. When you lose: Game Grid: 1 2 3 4 5 6 7 8 9 10 A B $ C $ X X D E $ @X $ F G $ $ X H $ $ $ $ I X J X $ 3. When you win: Game Grid: 1 2 3 4 5 6 7 8 9 10 A B $ X C $ D E X @$ F X G $ $ X H $ $ $ I $ J $ X $
Overview A Tokimon handler is a person who trains and cares for Tokimons. Their job is to coordinate a team of Tokimons and gather their strengths. Each team’s members and their relative compatibility is kept in a JSON file much like the one that is given as part of this assignment.Each JSON file corresponds to one Tokimon in the database and gives information about their compatibility to the team as well as to each member of their team. Note that compatibility scores are not symmetric. For example, Toki1’s compatibility score towards Toki2 may not necessarily be the same as Toki2’s compatibility score to Toki1.Your task in this assignment is to create a program which finds all JSON files in a folder and processes them to create the teams. It then generates a .CSV file which a handler can look at and evaluate each team’s strengths and weaknesses.• You must create an object-oriented system of your own design. You must have at least 3 non-trivial classes by the time you are done. Each class should demonstrate strong cohesion: the class has one guiding purpose, and all methods and fields of the class fit well in the class.• Put all your classes in the package ca.cmpt213.as2 (this helps with marking). • Your code must conform to the programming style guide (available in the resources section of the course website). All classes must have class-level JavaDoc comments describing the purpose of the class.Collecting Inputs: • Your main class (the class that contains your main() function) must be called TokimonProcessor. • The main class accepts two arguments: 1. Path to the directory containing the input .JSON files. 2. Path to the output directory where the generated .csv will be placed. If an invalid number of command line arguments is supplied (too many or too few), then print out what arguments are expected and exit the program. If the input folder (for .JSON files) or the output folder (for the generated .csv file) do not exist, then print an error message and exit. You may assume that each argument contains no spaces.• Search the input folder (recursively) for any JSON files and read them into your program. You must use a FileFilter object for filtering the files found by File.listFiles(). You may use any approach you like for reading JSON files. I recommend using the GSON library. JSON files end in the .json extension, case insensitive. Other files must be ignored. You may assume that JSON input files have the same format as the ones supplied with this assignment. Spacing in a JSON file is arbitrary but it must conform to some basic rules: https://www.w3schools.com/js/js_json_syntax.asp.• The first Tokimon mentioned in the JSON file refers to the Tokimon that this file is about. The rest of the Tokimons (if any), are its teammates.• Generate an error if any of the following errors occur: 1. Incorrect number of arguments provided to program. 2. Input folder does not exist. 3. No JSON files are found. Bad JSON file format or missing required fields. It is OK to not check if file has extra fields. 4. Any score is less than 0.• If there are any errors with the input data then: Display a message stating the error, Display the filename and path of the problematic JSON file (if applicable), and Exit the program with exit code -1, without creating any output files. It is OK to display multiple errors before exiting (if multiple problems with input data detected).Organizing the data: • Analyze the data from each Tokimon’s JSON file to recreate the teams (i.e., infer who is teamed up with whom based on who is in their JSON file). Note that each Tokimon’s JSON input file has an entry for not only themselves, but also each other teammate. • Teaming algorithm: Tokimon S belongs to team T if team T already contains another Tokimon R such that R has an association to S. If a Tokimon S belongs to no existing teams, place that Tokimon in a new team.• Errors: • It is an error if Tokimon S is mentioned by Tokimons who are in two different teams. (i.e., S can only be a member of one team). • It is an error if any Tokimon who is mentioned in the JSON file of another Tokimon in the team fails to submit a JSON file. • It is an error if any Tokimon in a team does not mention all other Tokimons in that team.• If Tokimon S is already in a team, it is an error if S’s property does not match its existing recorded properties. For example, if S was defined to have name “Toki1”, it cannot later have name “Toki2” in another JSON file; this is an error. • In the event of an error: Display a message stating the error, Display the filename and path of the problematic JSON file (when possible), and Exit the program with exit code -1, without creating any output files. It is OK to display multiple errors before exiting if multiple problems are found.• Note: Two Tokimons are the same if they have the same id field. Ignore spaces at the start of end of an id (hint String’s trim() function) Comparison is case insensitive (hint String’s equalsIgnoreCase() function).Outputting the data: Generate a comma separated value file (.csv) which contains the following columns. • For each team, generate a one row header that just says “Team 1” or “Team 2” (indexed accordingly).• For each Tokimon S in the team: • Generate one row for each other Tokimon R in the team. This row should list the id of S, the id of R, the compatibility score from S to R, and any comment from S to R. Generate one row showing the compatibility score S to the team, the comment from S to the team, and showing S’s extra comments.• Output Format Constraints • Use the following for the column headings in your CSV file: Team#, From Toki, To Toki, Score, Comment, , Extra • Sorting: Inside the teams, output Tokimons in alphabetical order (sorted by lower-case id). • 0Column description: • Team Number – This column only has data for the “header” row for each team. • From Toki – the id of Tokimon S. The source Tokimon. • To Toki – the id of “other” Tokimon R. For the rows that display S’s own compatibility score, display “-”.• Score – Compatibility Score to the from Tokimon S to Tokimon R. Display as a floatingpoint number with 1 digit after the decimal point. • Comment – Display the comment associated with this row (from Tokimon S to Tokimon R). • Extra – The extra comment property of each Tokimon.Sample Run: • A sample run of your program may look something like: > java TokimonProcessor “./InputTestDataSets/1-OneTeamOneToki” “./AnalysisResults_v2/1-OneTeamOneToki” This would generate the team_info.csv file located in the 1-OneTeamOneToki folder. Please note that the path may also be an absolute path.Marking Scheme: [5 marks] Single Group – generates correct and well-formatted .CSV file. [10] Multiple Groups – correct number of Tokimons per team, correlating Tokimons to teams, generate correct and well-formatted .CSV file. [6] Error Handling – print reasonable error message in each case. [3] Object Oriented DesignSubmission Submit a zip file of your project (according to the directions outlined in the assignments link of the course website) to the coursys server. https://courses.cs.sfu.ca/.Your project must: • Import external dependencies (such as GSON) via Maven, or else included them in your project. • Generate a JAR file as part of the build process. Please note: all submissions are automatically checked for similarities of all other submissions on the server. THE END
A Tokimon is a rare creature found in the remote areas of Korea. For the most part, they resemble rabbits and the only form of communication they have with us is the ability to say their own name. Tokimons come in all shapes and sizes, have special abilities, and tend to fight with each other on occasion. Each Tokimon has a type which gives them the ability to fly, throw fire, spray water, electrify, and freeze (other Tokimons); each Tokimon has a strength measured by an integer between 0 and 100. Because they are such primitive creatures but have such extraordinary abilities, they must be tracked. We would like to write an application to track the characteristics of the less than 300 Tokimons in existence today.Text Interface: your app should have the following general options to choose from: 1. List all Tokimons including the name, type, height, weight, and abilities 2. Add a new Tokimon. Prompt the user for a name, type, height, weight, and abilities. 3. Delete a Tokimon. First list all current Tokimons, allow the user to choose the Tokimon to delete (or 0 to cancel). Entering an invalid number should be handled by the program, but invalid datatypes such as ‘A’ need not be handled.4. Augment ability. First list all current Tokimons, allow the user to choose the Tokimon to increase the ability, the type of ability, then prompt for the amount. Once again, you do not need to handle invalid datatypes. 5. Display the toString() on each Tokimon in the system.6. Exit the program. Technical requirements: – Write a function called displayMainMenu() – Write a function called displayAllTokis() – Write a function called addNewToki() – Write a function called deleteToki() – Write a function called alterToki()This may give some intuition to a good design for this assignment. Here is some sample output, you do not have to match the exact layout (it’s just a suggestion): ******************************************** * Tokimon Tracker by Bobby Chan sn 5555555 * ******************************************** ************* * Main Menu * ************* 1. List Tokimons 2. Add a new Tokimon 3. Remove a Tokimon 4. Change Tokimon strength 5. DEBUG: Dump objects (toString) 6. Exit > 2 Enter Tokimon’s name: Toki chu Enter Tokimon’s type: Fire Enter Tokimon’s size: .5 ************* * Main Menu * ************* 1. List Tokimons 2. Add a new Tokimon 3. Remove a Tokimon 4. Change Tokimon strength 5. DEBUG: Dump objects (toString) 6. Exit > 1 ********************* * List of Tokimons: * ********************* 1. Toki chu, 0.5m, Fire ability, 0 strength ************* * Main Menu * ************* 1. List Tokimons 2. Add a new Tokimon 3. Remove a Tokimon 4. Change Tokimon strength 5. DEBUG: Dump objects (toString) 6. Exit > 2 Enter Tokimon’s name: Squir To Enter Tokimon’s type: Water Enter Tokimon’s size: 3.1 ************* * Main Menu * ************* 1. List Tokimons 2. Add a new Tokimon 3. Remove a Tokimon 4. Change Tokimon strength 5. DEBUG: Dump objects (toString) 6. Exit > 1 ********************* * List of Tokimons: * ********************* 1. Toki chu, 0.5m, Fire ability, 0 strength 2. Squir To, 3.1m, Water abiity, 0 strength ************* * Main Menu * ************* 1. List Tokimons 2. Add a new Tokimon 3. Remove a Tokimon 4. Change Tokimon strength 5. DEBUG: Dump objects (toString) 6. Exit > 5 All Tokimon objects: 1. ca.sfu.cmpt213.as1.Tokimon[Name:Toki chu, Strength:0, Height:0.5, Ability:Fire] 2. ca.sfu.cmpt213.as1.Tokimon[Name:Squir To, Strength:0, Height:3.1, Ability:Water] ************* * Main Menu * ************* 1. List Tokimons 2. Add a new Tokimon 3. Remove a Tokimon 4. Change Tokimon strength 5. DEBUG: Dump objects (toString) 6. Exit > 4 ********************* * List of Tokimons: * ********************* 1. Toki chu, 0.5m, Fire ability, 0 strength 2. Squir To, 3.1m, Water abiity, 0 strength (Enter 0 to cancel) > 1 By how much?: 3 Toki chu now has strength 3! ************* * Main Menu * ************* 1. List Tokimons 2. Add a new Tokimon 3. Remove a Tokimon 4. Change Tokimon strength 5. DEBUG: Dump objects (toString) 6. Exit > 4 ********************* * List of Tokimons: * ********************* 1. Toki chu, 0.5m, Fire ability, 0 strength 2. Squir To, 3.1m, Water abiity, 0 strength (Enter 0 to cancel) > 0 ************* * Main Menu * ************* 1. List Tokimons 2. Add a new Tokimon 3. Remove a Tokimon 4. Change Tokimon strength 5. DEBUG: Dump objects (toString) 6. Exit > 6 BYE! You may assume any requirements that are not explicitly stated in this description (within reason). If you’re not sure of a requirement, please see the TAs or myself.Marking Scheme: [20] Basic Functionality [5] Robust keyboard input: when given a number out of range it asks for retry. (Not testing typing text, like “A”, instead of a number). [5] Able to add and remove Tokimons. [5] Able to augment strengths correctly. [5] Good listing of Tokimons, and debug listing (using toString). [8] Code Quality and Style Guide * Reasonable object oriented structure (one class likely is not enough) * JavaDoc comment on each class (not needed on methods/fields) * Correct indentation, brackets, spacing (use IDE’s reformat if needed). * Good intention revealing class, method, and variable names.Submission Submit a zip file of your project (according to the directions outlined in the assignments link of the course website) to the coursys server. https://courses.cs.sfu.ca/ Please note: all submissions are automatically checked for similarities of all other submissions on the server. THE END