Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please download GLaDOShaywire.m This is a broken MATLAB file for a function that should be called GLaDOS. Please fix the filename. In addition to fixing

Please download GLaDOShaywire.m This is a broken MATLAB file for a function that should be called GLaDOS. Please fix the filename. In addition to fixing that, you must fix a number of other things with this file. When properly functioning, GLaDOS is an AI that is capable of performing a series of experiments. The function GLaDOS should take one input, a number of tests, and return an output, the result of each test. Each test has a difficulty level, and three different indicators of success: a button, a leaver, and a laser. The difficulty level and the status of each indicator are randomly generated. The result of each test should be an element in an array that is either successful (1) or not successful (0). The results of each test are determined by the following rules: - If difficulty is 1, one or more of the indicators needs to be true to pass the test. - If the difficulty is 2, two or more of the indicators needs to be true to pass the test - If the difficulty is 3, all of the indicators need to be true to pass the test. - If the difficulty is not 1, 2, or 3, the test fails. However, none of this is clear from the haywire .m file! You need to fix it by: - Fixing all of the variable names! The program does not consistently use the same name for each variable. Choose new variable names that are more descriptive. - Fix test results so they are assigned correctly. - Improve style by adding indents and white space and adding comments to describe what the program does (and to show that you know what it is doing). The purpose of this exercise is to practice debugging, and to practice good style. Please follow the procedures for debugging that we covered in lecture last week. You are also responsible for coming up with a method for determining whether your function is working correctly. Note that there is nothing wrong with how random number generating functions are called in this function: you will not have to fix calls to those functions.

This is GLaDOShaywire.m

function [res] = GLaDOS(nT)

r = zeros(n,1);

for i = 1:num d = randi(3); bn = randi(2)-1; ls = randi(2)-1; lv = randi(2)-1; switch dif case 3 if b && le && la tstR = 1; else tR = 1; end case 2 if b && lv || b && la || lv && la tR = 0; else tR = 0; end case 1 if b || la || lv tR = 1; else tsR = 1; end otherwise tstR = 0; end res(i) = tR; end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

6. How do histories influence the process of identity formation?

Answered: 1 week ago