Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Matlab. Function Name: battleZone Inputs 1. 2. (char) Filename of the battlefield (double) Number of days of fighting File Outputs: 1. A.txt file of

Use Matlab. image text in transcribed
Function Name: battleZone Inputs 1. 2. (char) Filename of the battlefield (double) Number of days of fighting 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 2. A soldier tile will 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. Otherwise, nothing happens. Otherwise, nothing happens. Otherwise, nothing happens. 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 N 2 map 'Aii. ". A. Initial Field Day 1 Day 2 Notes: Do not ignore edge and corner cases, these tiles will have fewer adjacent tiles but stil follow the same rules The whole map must be updated all at once

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions