BEST代写-最专业、靠谱的代写

Best代写-最专业、靠谱的代写IT&CS | 留学生作业 |编程代写 | Java | Python | C/C++ | PHP | Matlab | Assignment Project Homework代写

Matlab 代写 | CSCE 155N Maze Game

Matlab 代写 | CSCE 155N Maze Game

这是Matlab游戏设计作业,涉及循环、数组、文件读取等基础知识,难度中等。
Objectives
The objectives of this homework assignment:
1. Master the use of selection statements in Matlab.
2. Master the use of loops in Matlab.
3. Familiarize with the use of functions in Matlab.
4. Familiarize with the use of cell arrays in Matlab.
5. Familiarize with use of File I/O in Matlab.
6. Familiarize with the built-in functions that can be applied to strings in Matlab.
7. Familiarize with the use of matrices in Matlab.
8. Familiarize with the concept of control statements (selection and loop) in solution design.
9. Be exposed to the concept of problem decomposition and the design-implementation test
cycle.
Problem Description
This project involves implementing a single player game. The game can be tested using the
GameTest.m file. The programmer needs to modify the function call to either include a file name
or not. The programmer needs to create a function playGame in a separate file (the programmer
is encouraged to develop sub-functions if necessary) and include their code/logic in it. The
required files for this project can be downloaded here.
The player (P) always starts the game at the lower left corner and the player’s task is to reach the
position which is marked as Final Goal (G) in the minimum number of moves. The player can
view the entire maze at the start of the game. The player’s choices (moves) must be entered in
advance into a file, with that file included as input to your playGame function. The playGame
function also takes as input a file which contains the top 10 players’ scores. So, the input
arguments to your playGame function should be
1. Filename (string) of the file which stores the player’s planned
moves.
2. Filename (string) of the file which stores the scores of the top 10
players.
3. Maze (square matrix of numbers) representation as a matrix.
4. Players’ name (string).
Note: Make sure that you include all the required and created files in the same folder, in order to
avoid having to specify paths and annoying the graders.
A maze will be provided at random by the webgrader to your functions. You can design your
own maze by modifying the variable maze in the GameTest.m file. A general description of a
maze is described below:
 The Player is represented using a 2 in the matrix maze.
 The walls are represented using 1’s in the matrix maze.
 The final target is represented using 3 in the matrix maze.
 The empty spaces where the player is free to move are represented using 0’s in the matrix
maze.
Some rules that should be followed while playing the game:
 The internal walls cannot be destroyed.
 There are no external boundaries. But, a player should not be allowed to move outside the
maze.
 The player can choose to either move a single step (option ‘s’) in some direction or move
along a direction until there is a wall or edge of the maze (option ‘a’). {‘s’ for single step
and ‘a’ for all steps}
 If a player reaches the position which is marked as the Final Goal (G), then no further
steps are allowed and the game ends.
 If a player reaches the position which is marked as the Final Goal (G), then the player’s
name should be inserted into the top-10 players file along with his/her score (the number
of moves – not necessarily steps – taken by the player to reach the goal), assuming he/she
makes into the top-10 list. The player’s details must be inserted in to the top-10 list at the
appropriate position based on his/her number of moves and the players must be ranked
according to the number of moves.
 Eg:
o If a player ‘x’ reached the goal in 5 steps and the top-10 players file has just 5
players in it, then ‘x’ should be inserted into the top-10 players file at an
appropriate position based on his/her number of moves.
o If a player ‘x’ reached the goal in 5 steps and the top-10 players file has 10
players in it and player ‘x’ has fewer moves than some other players, then player
‘x’ should be inserted into the top-10 players file and the lowest player in the file
should be dropped. Increasing numerical order should be maintained.
 ‘x’ reached the goal in 5 steps and there are some other players ‘y’ (at line
7) and ‘z’ (at line 6) with 5 steps in the top-10 players file, then the player
‘x’ must be inserted after line 7 and the last player (at line 10) should be
removed from the file.
 The players must be ranked according to the number of moves (The player
at line ‘l’ should have less or equal number of moves compared to any
other player after line ‘l’ in the file)
o If a player ‘x’ reached the goal in 7 steps and the top-10 players file has 10
players in it and all of them have better (lower) scores, then player ‘x’ details
shouldn’t be inserted in the top-10 players file.
 The format of the top-10 players file should be playerName, number of moves – separated
by commas. All the players must be arranged by increasing numerical order of the
number of moves.
o Eg: patrick, 4
Riedesel, 5
chuck, 10
 The format of the player’s moves should be the player’s choice of move (‘a’ or ‘s’),
direction (‘n’, ‘e’, ‘w’, ‘s’) – separated by commas.
o Eg: a, n
s, e
a, w
An example of the maze and the input files are presented here:
maze:
0 1 0 0 0 0
0 0 3 1 1 0
0 1 0 0 0 1
0 0 0 1 0 1
2 0 0 0 0 0
Player name: ‘Charles’
Moves.txt:
a , n
s , s
a , e
s, n
top10players.txt:
patrick, 4
Riedesel, 5
chuck, 10
Now your code should read the files and execute those moves from the moves.txt file.
Moving all possible steps ‘a’ in north direction ‘n’
0 1 0 0 0 0 2 1 0 0 0 0
0 0 3 1 1 0 0 0 3 1 1 0
0 1 0 0 0 1 Move ‘a’ 0 1 0 0 0 1
0 0 0 1 0 1 0 0 0 1 0 1
2 0 0 0 0 0 0 0 0 0 0 0
Before After
Moving a single step ‘s’ in south direction ‘s’
2 1 0 0 0 0 0 1 0 0 0 0
0 0 3 1 1 0 2 0 3 1 1 0
0 1 0 0 0 1 Move ‘s’ 0 1 0 0 0 1
0 0 0 1 0 1 0 0 0 1 0 1
0 0 0 0 0 0 0 0 0 0 0 0
Before After
Moving all possible steps ‘a’ in east direction ‘e’
0 1 0 0 0 0 0 1 0 0 0 0
2 0 3 1 1 0 0 0 2 1 1 0
0 1 0 0 0 1 Move ‘a’ 0 1 0 0 0 1
0 0 0 1 0 1 0 0 0 1 0 1
0 0 0 0 0 0 0 0 0 0 0 0
Before After
Now, the final goal is reached in 3 moves. The next step in the moves.txt file is a single step ‘s’
in ‘n’ direction, this move shouldn’t be executed as the player has already reached the final goal.
The top10players.txt file after updating the ‘Charles’ details become:
Here ‘Charles’ should be inserted at the top of the file, because the player has less number of
moves compared to any other player in the file.
Charles, 3
patrick, 4
Riedesel, 5
chuck, 10
The task of the programmer is to implement the function playGame. The programmer needs to
develop his own function in a new file having the same name, and this function should take 4
input arguments and should return the name (string) of the output file (top-10 players file)
and the updatedMaze after performing the moves from the moves file.
 The entire game can be played using the GameTest function. You are encouraged to
create your own mazes and test them. Simply modify the file names in the GameTest
function for testing. You are also encouraged to create your own sub-functions.
o The input direction must be either ‘n’ for north, ‘s’ for south, ‘w’ for west or ‘e’
for east. The direction must be provided along with the quotes (‘’) in the
moves.txt file.
 Your playGame function should contain the core logic for playing the game and the code
for required file I/O (Use textscan or readtable functions in Matlab). Please look at the
rules of the game and implement those rules in your function.

bestdaixie

评论已关闭。