Question: ANSWER WITH MATLAB CODE You are asked to write a program for a game using a Brain-Computer-Interface where the user gives left/right/up/down commands to move

ANSWER WITH MATLAB CODE

You are asked to write a program for a game using a Brain-Computer-Interface where the user gives left/right/up/down commands to move on a board and collect points. Write a function bciboardgame2(m,x,y,moves) that takes a matrix m representing the board and x,y coordinates representing the row and column indices of the user's current location. The moves is a cell array of strings containing the sequence of user commands, as a vector of integers between 1 and 4 (1: left, 2:right, 3:up, 4:down). Your program should start at x,y coordinates, and move around the board according to user's commands and return the total number of points the user collects, including the points on the starting position. If the user makes an illegal move that would take the user off the board, do not move the user and collect the points in the current location.

THE CORRECT ANSWER WILL GIVE THE FOLLOWING EXAMPLE OUTPUTS, EXACTLY:

>> disp(bciboardgame2([10 20 30; 40 50 60], 1, 3, { })) 30 >> disp(bciboardgame2([10 20 30; 40 50 60], 1, 3, { 'up' })) 60 >> disp(bciboardgame2([10 20 30; 40 50 60], 1, 3, { 'up' 'up'})) 90 >> disp(bciboardgame2([10 20 30; 40 50 60], 1, 3, {'left'})) 50 >> disp(bciboardgame2([10 20; 30 40], 1, 1, {'left' 'down' 'up'})) 60 >> disp(bciboardgame2([10 20; 30 40], 1, 1, {'right' 'down' 'up'})) 90 >> disp(bciboardgame2([10 20; 30 40], 1, 1, {'right' 'down' 'left' 'up'})) 110 >> disp(bciboardgame2([10 20; 30 40], 1, 1, {'right' 'down' 'left' 'up' 'right' 'down' 'left' 'up'})) 210 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!