Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using MATLAB Function Name: battleZone Inputs 1. (char) Filename of the battlefield 2. (double) Number of days of fighting Using Matlab File Outputs 1. A.txt
Using MATLAB
Function Name: battleZone Inputs 1. (char) Filename of the battlefield 2. (double) Number of days of fighting Using Matlab File Outputs 1. A.txt file of the updated battlefield Background As the high-ranking General you are, it is your job to plan out your battle strategies carefully to ensure the success of your troops. You are aware that battles are complex and disordered, but you can still identify a few trends that happen in terms of the movement of your troops on the battlefield. With little time on your hands, you call upon your trusted ally MATLAB to analyze the field and determine the course of the battle over the next few days Function Description You are given a text file containing a map of a battlefield, with the characters ',', "A. and 'i' representing tiles of open ground, encampments, and soldiers respectively. Every day some changes occur to the battlefield as the fight progresses, based on the following criteria 1. A tile of open ground will become a soldier if it is adjacent to at least one encampment. Otherwise, nothing happens Otherwise, nothing happens Otherwise, nothing happens 2. A soldier tile l become an encampment if it is adjacent to at least two soldiers 3. An encampment become an open tile if it is adjacent to fewer than two soldiers An element is considered adjacent if it is directly above, below, to the right of, or to the left of the element in consideration (diagonals are NOT considered adjacent). You must extract the map from the text file, update the map to show its status after N days and print out the new map to a new file with the same name as the original, but with '_updated.txt' appended. Example: mapAi i" Initial Field Day 1 Day 2 Notes . Do not ignore edge and comer cases, these tiles will have fewer adjacent tiles but still follow the same rules The whole map must be updated all at once . Function Name: battleZone Inputs 1. (char) Filename of the battlefield 2. (double) Number of days of fighting Using Matlab File Outputs 1. A.txt file of the updated battlefield Background As the high-ranking General you are, it is your job to plan out your battle strategies carefully to ensure the success of your troops. You are aware that battles are complex and disordered, but you can still identify a few trends that happen in terms of the movement of your troops on the battlefield. With little time on your hands, you call upon your trusted ally MATLAB to analyze the field and determine the course of the battle over the next few days Function Description You are given a text file containing a map of a battlefield, with the characters ',', "A. and 'i' representing tiles of open ground, encampments, and soldiers respectively. Every day some changes occur to the battlefield as the fight progresses, based on the following criteria 1. A tile of open ground will become a soldier if it is adjacent to at least one encampment. Otherwise, nothing happens Otherwise, nothing happens Otherwise, nothing happens 2. A soldier tile l become an encampment if it is adjacent to at least two soldiers 3. An encampment become an open tile if it is adjacent to fewer than two soldiers An element is considered adjacent if it is directly above, below, to the right of, or to the left of the element in consideration (diagonals are NOT considered adjacent). You must extract the map from the text file, update the map to show its status after N days and print out the new map to a new file with the same name as the original, but with '_updated.txt' appended. Example: mapAi i" Initial Field Day 1 Day 2 Notes . Do not ignore edge and comer cases, these tiles will have fewer adjacent tiles but still follow the same rules The whole map must be updated all at onceStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started