Search for question
Question

Assessment Task 1: Client's Briefing #2 Partial Transcript

Hello, it's Elton, your QUT Data Services representative, again. I wanted to thank you for

submitting your two symbol designs on time. I've sent them to our back-room boffins for

evaluation and they'll get their verdict back to you as quickly as possible.

Given this show of faith, I'm now authorised to entrust you with the data sets we need visual-

ised. Time is of the essence because we need your complete, finished program by the end of

Week 7.

Our customers are data analysts who need to understand data sets that record the way certain

competing forces jostle for supremacy in a confined area. These data sets appear as lists of

numbers and text strings, which makes it difficult to understand exactly what the competitors

do. Your job, therefore, is to write the function which displays the data sets' content visually,

in an easily interpreted form.

In the program you've just submitted you'll recall that you drew the two competitors in the

grid cells marked by dots. These are the "home" locations for the two competitors. You will

have also noticed that the grid is divided into two halves.

[Runs the demonstration solution from the last briefing

and points out the home cells and the dividing line]

Each competitor aims to occupy cells in the other competitor's half of the grid. Our data ana-

lysts are interested in how many cells each competitor "captures" in the other half, but this is

not obvious merely by looking at the raw data sets. Your program is going to solve this problem

for us, by showing the data sets visually.

The data sets tell us which direction the competitors want to move in each step, if they can.

However, as we'll see, they may not always be able to do so. To provide you with data sets to

visualise, our data analysts have created a Python module called assign-

ment_1_data_source, which you can find accompanying this briefing. You're welcome

to study this code but you don't need to do so in detail.

[Shows the contents of the assignment_1_data_source module]

If you put this module in the same folder as the original Python template we gave you, it will

cause the program to generate a new data set each time the program is run. Let's try it.

[Runs the template file a few times with the data module in place]

As you can see, each time you run the program you get a different data set. These are the data

sets of interest to our analysts, but in this form they're very hard to understand. It's not imme-

diately obvious by looking at them what the competitors do.

Let's have a look at a typical data set.

[Points out the features of a particular data set]

In summary, each data set generated consists of a sequence of intended moves. The first value

in each move is a step counter that begins at zero and increases by one with each move gener-

ated. The second value is the identity of the competitor attempting to move; "Competitor A"/nis the one you drew to the left of the grid and "Competitor B" is the one on the right. The third

value is the direction in which the competitor wants to move, if possible.

However, there are two constraints on the moves a competitor is allowed to make.

1. A competitor cannot move outside the grid.

2. A competitor cannot move into a cell which has previously been occupied by either

competitor. In other words, a competitor cannot move into a cell which has already

been visited by its opposition, and it cannot backtrack along its own path.

Any attempt to violate either of these contraints results in the competitor forfeiting the move

and staying in its current cell.

Finally, when your simulation has processed all the moves in the data set, you must display the

number of cells each competitor has "captured" in the other competitor's half of the grid.

To show you what's expected our back-room boffins have extended their sample solution, so

I'll run their demonstration on a few different data sets.

Let's look at some examples where the competitors move without interacting or attempting to

backtrack.

[Shows examples where both competitors move but don't

interact directly (Seeds 51958 and 3199)]

However, as I mentioned, a competitor can't move onto a previously occupied cell. If they try

they waste the move, as in the following examples.

[Shows examples where the competitors forfeit moves by trying to go into a

cell previously occupied by the other competitor (Seeds 82570 and 16223)]

The constraint about not moving into a cell which has been previously visited (including one

which is still currently occupied, of course) includes cells previously visited by the competitor

itself, so they can't backtrack on their own path.

[Shows examples where the competitors try to backtrack

along their own path (Seeds 79000 and 35842)]

And the final constraint is that the competitors can't leave the grid. Again, they forfeit the

move if they try.

[Shows examples where the competitors try to

leave the grid (Seeds 26796 and 85053)]

In summary, therefore, you need to follow the moves in the data sets in the same way as these

examples, but using the two symbols you designed for us earlier, of course.

Your code must start the two competitors in their home cells.

• For each move in the data set (north, south, east or west) you must redraw the appro-

priate competitor in its new cell, unless

o doing so would move the competitor into a previously-occupied cell, or

o doing so would take the competitor outside the grid./nAnd finally, you must write the number of cells captured by each competitor from the

other competitor's half of the grid on the drawing canvas.

To help you, each data set generated is printed to the shell window, as you have just seen. More

importantly, however, the data set is also returned as a list by function data_set, which

makes it available to your visualise_data function. Let's have a look at the code.

[Shows the call to data set in the template's main program]

Your task is to complete the visualise_data function; all of your code goes in or is called

by this function, where the pass statement appears.

You also need to ensure that your code does not call function data_set because it's already

called in the main program. Any attempt by your code to call function data_set (or its

helper function raw_data) will cause the program to crash.

Finally, we fully appreciate how difficult it is to work with large data sets that change randomly.

To help you develop your program with some unchanging data sets, our boffins have therefore

incorporated some features into the Python template code that allow the data sets to be fixed

temporarily. The first is that if you add an integer argument in the call to function data_set

in the main program it will always generate the same list of values.

For instance, if you put seed value 11495 into the call to data_set it will always produce a

list of moves in which Competitor A wins. Let's see how it works with the boffins' sample

solution.

[Shows how to use Seed 11495 to produce a repeatable behaviour]

In the new data source module we've listed many such seeds showing what behaviour to expect

when you use that seed as the argument for function data_set.

[Shows the tests including the "seed" values

documented in the data source module]

You can use this information to help debug your program because it tells you exactly what

should happen for each of the seeds, especially the numbers of cells captured.

Also, to make their own job easier, the boffins have also incorporated a feature in the as-

signment_1_data_source module that allows them to enter seeds or test numbers inter-

actively. You're welcome to use this feature yourself when developing your code, if you like.

[Shows how to activate the "pop-up tester" and use it to

run a particular test (Test no. -26, Seed 47398)]

However, when you submit your final program you must not use a fixed value for the data sets.

Your program must work for any possible data set that function data_set can produce.

When you submit your code, make sure there is no argument in the call to data_set at the

bottom of the template file.

Another helpful feature that the boffins have introduced is to display the seed value in the shell

window every time you run your program, so that you can replay any behaviour of interest/nsimply by copying that value and putting it in the call to data_set while you're developing

your code.

[Points out the seed number displayed in the shell window]

So, as you've seen, there are quite a few things for you to do. We strongly suggest that you

don't try to do everything at once. Solve one problem at a time, for instance:

1. Firstly, work out how to access the moves in the data sets. Your knowledge of param-

eter passing and iterating over lists will be very helpful here.

2. Then work out how to move the competitors in the various directions. This will require

you to remember their current locations and choose which direction to move each time.

3. You'll also need to count and display how cells have been captured from the opposi-

tion's half of the grid. Most likely you'll want to conditionally increment a couple of

variables to do this.

4.

Next work out how to stop the competitors leaving the grid. You can use their current

location to decide whether or not to let them move.

5. Perhaps the most challenging part is preventing the competitors moving into previously

occupied cells. To do so you'll need to remember which grid cells or screen locations

have been visited to date and use this information to decide whether or not to allow

each move.

You don't need to develop your program in this particular sequence, but no matter what order

you follow, focus on just one thing at a time. Trying to do everything at once would be over-

whelming.

When you've completed your program, please upload it to our organisation's IT system just as

you did before. We only need the single Python file, assignment_1.py. Don't send us a

copy of the configuration or data source modules because obviously we already have them, and

we'll use our own copies to test your solution.

As usual, to ensure your solution is portable across any computing platform that our assessment

team may use, it must be written in standard Python 3, and must not rely on any extension

modules that need to be downloaded and installed separately.

Also, we welcome receiving, and encourage you to submit, multiple early drafts as you develop

your solution, as insurance against technical failures, floods, pandemics, cyber attacks, or any

other disaster that could occur before the end of Week 7. If you can't complete the whole job

in time you'll get partial credit for the parts you do complete.

That's all for this set of requirements. Our company is looking forward to receiving your up-

dated program at your earliest convenience. Goodbye.

Fig: 1

Fig: 2

Fig: 3

Fig: 4