(Python 3.5) Problem Description Building of the diabolical success of their Pok
ID: 3804401 • Letter: #
Question
(Python 3.5)
Problem Description
Building of the diabolical success of their Pokemon evolution experiments, the evil Team Rocket are planning to send their genetically altered war-pokemon to attack Pokemon gyms around the world. To this end, Team Rocket is planning the following simulation experiment to assess the strength of different gyms. Team Rocket wants to know the minimum number of war-pokemon needed to overcome the defenses of the gym in each of several cities. Because unpredictable events can occur during these attacks, Team Rocket is willing to accept an answer that has a 95% chance of being right, according to certain assumptions that are explained below.
You will use Python to answer Team Rocket’s question. Since we don’t have a simple formula, we’ll have to simulate an attack repeatedly, using different numbers of war-pokemon.
Initial conditions : Suppose the area near a gym is divided into a N by N square grid. (We give you 3 scenarios; the value of N depends on the scenario.) The war-pokemon start out occupying the top row of the grid squares. Specifically, each grid square in the top row of the grid starts with an equal number of war-pokemon (which IS allowed to be a floating point number...Team Rocket’s evil experiments might sometimes result in mutant pokemon that are only partially evolved).
Movement of war-pokemon : During an attack, the war-pokemon travel directly southward (towards the bottom of the grid), one grid square at a time, towards a gym defended by gym trainers and their nice pokemon. For the purposes of the simulation, you can imagine that the gym is “below” the bottom row of grid squares.
Static Defenses : Each grid square contains some fortifications (barriers, traps, etc.) that defeat attacking war-pokemon. The strength of the fortifications in a grid square is represented by a non-negative integer. If the fortification value of a grid square is equal to d, then exactly d of the war-pokemon that start in that grid square do not make it to the grid square directly to the south in the next row.
Active Defenses : Each time the war-pokemon attempt to advance one row southward, the pokemon of the defending gym trainers unleash a barrage of attacks. The level of the defending pokemon is represented by an integer p between 0 and 100. The value p depends on the scenario. The defending pokemon are not completely consistent, so each attack barrage destroys a random percentage between 0 and p percent of the war-pokemon that are not defeated by the fortifications in each square of the current grid row. The random percentage of war-pokemon defeated is determined separately for each grid square. Warpokemon in a grid square that do not faint1 due to the fortifications or by the attacks make it to the next row.
Luck : The fact that the defending pokemon are not consistent means that the outcome of an attack is based in part on luck. It is bad planning to count on luck being in your favour! The way to mitigate uncertainty like this is to repeat the scenario many times. Each simulated scenario might be more or less lucky, but if your repeat the simulation a large number of times, you can get a good idea of what should happen. So, don’t draw your conclusions based on one simulation!
Success : From the point of view of Team Rocket, success is determined by the number of war-pokemon that survive the attack, and reach the gym. If the total number of war-pokemon that survive all the defenses is at least k, then the gym is taken. The number k depends on the scenario. Note: Success is not determined by the number of war-pokemon who arrive in the bottom row, but the number who pass the bottom row; there are fortifications in the bottom row, and the defending pokemon will make one last desperate attack! PIKAAA!!!
Scenario files : The program inputs are to be read from a file. The first line of the file contains three numbers separated by a comma: N (the size of the grid), p (the level of the defending pokemon), and k, the number of war-pokemon that must reach the gym in order to capture it. After the first line, there are N more lines each containing N integers separated by commas which are the fortification strengths for each grid square in each row of the grid.
General problem statement :
Write a program which, given the grid size N, the strength of the fortifications in grid square, and the number of war-pokemon that must reach the gym in order to capture it, determines the smallest number of war-pokemon that are needed to start in the top row in order to have a 95% chance of successfully capturing the gym. Note that we want the total number of war-pokemon that start in the top row, not the number in each grid square of the top row.
Also note that that the absolute maximum number of war-pokemon that Team Rocket has at their disposal is one million. If they can’t take a gym with one million war-pokemon, then it can’t be done!
The output of your program (the minimum total number of war-pokemon that must start in the top row in order to have a 95% chance to capture the gym) must be printed to the console.
Hints :
• Divide up the work you need to do to solve this problem into subtasks and determine the best order in which to solve them.
• Make sure the code for each sub-task is working before you proceed to the next one (exercise your testing skills here!).
• In order to determine the chance that a certain fixed number of starting war-pokemon will be able to have a 95% chance of capturing the gym, you will have to run multiple simulations for that number of starting war-pokemon with different random percentages of war-pokemon defeated by attacks for each simulation.
Provided files : These files provide inputs for the simulation of Team Rocket’s war-pokemon attacking Pewter City (a weak gym), Celadon (a stronger gym), and Viridian City (a top-class gym).
Celadon :
20,30,100
4,7,5,4,5,6,7,6,6,5,4,5,4,5,4,7,6,5,5,7
4,5,5,6,4,6,4,4,4,7,4,4,5,7,6,6,6,7,5,4
7,4,7,6,6,4,4,7,4,4,6,4,5,5,4,6,6,7,6,5
4,7,6,4,5,6,6,4,7,7,5,6,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,7,9,9,6,8,6,9,9,5,8,8,8,7,7,7,5,9,5,9,6,7,5,5,7,8,6,9,9,10,7,7,8,7,7,10,10,5,8,10,5,8
7,10,9,7,10,9,7,8,7,10,8,7,8,5,9,10,6,8,7,8,6,10,5,7,5,9,9,10,9,10,10,8,10,6,5,9,8,9,6,5,8,10,5,10,8,10,6,9,5,5,8,9,5,5,9,10,8,9,8,7,6,6,10,8,7,7,9,5,7,10,6,9,9,6,7,6,9,7,8,10,7,7,9,8,8,10,9,10,7,5,5,9,10,10,6,7,6,9,9,10
8,9,10,10,6,8,9,6,10,5,10,6,6,5,7,10,10,8,5,10,8,6,9,10,5,8,6,7,8,5,6,9,9,6,5,9,10,5,7,7,9,7,8,10,6,10,6,5,9,6,5,5,9,7,8,8,9,6,7,10,6,6,5,8,7,10,6,10,10,7,7,10,9,10,8,9,8,8,10,10,6,7,8,8,8,5,6,9,9,6,7,5,5,7,9,7,7,8,6,8
10,5,5,6,5,9,6,9,10,5,6,8,10,5,8,10,7,9,10,7,6,7,6,6,8,10,6,9,8,8,7,7,8,6,6,9,9,8,5,10,5,5,5,10,10,5,9,7,6,5,10,10,6,9,10,5,9,10,6,8,9,6,8,7,7,6,9,9,10,6,5,5,5,8,6,8,9,10,5,5,10,8,8,7,10,10,5,6,9,8,10,5,6,10,6,9,8,9,10,9
10,7,8,6,6,7,5,9,5,10,9,10,8,8,6,10,5,7,8,10,10,10,10,10,5,7,10,9,5,10,9,8,10,10,10,8,9,5,10,8,7,10,9,5,6,8,8,5,6,5,9,10,10,9,8,8,10,10,5,6,9,8,10,9,6,7,10,7,8,6,5,10,10,7,8,5,10,6,7,6,9,9,9,6,10,7,9,8,9,10,8,6,5,6,10,8,7,5,8,10
6,6,10,6,8,10,8,7,8,10,8,7,9,8,7,8,5,5,10,8,5,7,7,9,10,6,7,9,7,9,7,10,9,9,5,7,6,10,6,5,10,5,5,9,10,9,8,6,6,5,5,9,9,8,8,6,7,8,5,5,8,9,10,10,8,9,9,10,6,6,8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,10,10,10,7,6,6,7,10,10,8,10,6,10,9,6,6,5,8,10,7,5,5,8,9,7,5,7,9,9,10,5,5,5,10,5,9,5,7,8,6,7,5,10,8,8,5,7,9,10,5,10,7,5,8,9,7,6
6,10,6,5,6,10,7,10,10,5,10,10,7,9,5,8,9,10,6,5,5,8,9,6,7,9,7,9,5,9,5,6,6,9,10,9,5,9,7,9,7,7,10,6,10,9,5,8,7,10,9,6,8,10,6,8,8,7,9,8,10,8,8,7,10,8,5,10,8,6,9,8,6,10,5,8,8,7,9,7,9,6,9,9,10,10,7,9,10,5,6,8,10,8,5,10,10,5,7,8
8,8,6,5,5,8,9,5,7,6,8,10,7,10,6,5,6,7,8,5,7,6,10,8,6,7,9,8,6,10,6,10,9,5,7,9,9,7,10,8,8,5,6,6,10,5,9,10,9,6,6,7,5,8,9,9,10,10,8,5,10,9,10,9,7,9,5,6,10,9,6,8,9,5,6,9,8,10,8,7,6,9,8,5,10,7,9,9,5,9,8,7,10,6,10,8,9,7,7,9
10,9,8,10,8,5,10,8,8,10,6,8,5,10,5,7,7,9,6,5,5,10,8,6,6,7,7,8,7,6,5,10,10,8,8,5,6,10,9,7,9,8,5,6,7,10,9,6,10,9,6,5,8,10,7,6,5,9,6,6,6,6,6,7,10,5,9,5,8,9,7,6,7,6,5,6,8,7,10,8,5,10,9,9,7,8,6,8,5,10,7,6,6,5,10,7,9,6,8,5
5,9,10,7,9,10,5,8,6,10,7,5,5,8,8,7,10,6,6,6,8,10,6,10,9,9,10,8,7,10,6,6,10,9,8,10,10,8,10,10,9,8,10,9,10,10,6,7,8,5,5,9,8,6,9,10,10,9,9,8,10,6,9,7,10,10,10,8,10,8,6,8,10,6,10,5,7,6,8,7,6,7,6,8,7,7,10,10,6,10,5,8,7,6,9,8,7,5,5,8
5,9,9,8,6,6,7,6,6,8,9,5,5,5,7,5,9,8,7,7,9,9,10,10,6,10,5,5,9,9,10,8,6,8,5,9,8,5,10,9,6,10,8,8,6,8,7,10,9,8,5,5,10,7,10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,7,10,5,10,7,8,5,5,8,9,6,9,7,10,10,5,9,10,5,6,7,10,10,6,9
6,9,10,5,9,5,6,9,9,8,6,9,6,10,6,10,5,6,10,6,7,5,7,6,7,8,8,5,6,7,7,10,8,6,8,9,7,7,9,5,10,7,10,5,6,8,10,7,6,10,8,9,6,9,10,6,8,7,8,8,6,10,8,8,5,6,9,6,10,6,5,8,5,5,5,6,8,8,5,6,9,5,5,9,5,9,6,6,9,9,7,10,5,6,6,7,8,10,9,9
Example :
Suppose the input file is:
3 ,20 ,15
2 ,3 ,1
3 ,1 2
1 ,2 ,3
This means that 15 war-pokemon must reach the gym to capture it, and that the grid is 3 by 3, and between 0 and 20% of war-pokemon in each grid square are defeated by pokemon attacks. Here we show a single simulation with one set of randomly determined percentages of war-pokemon defeated by attacks. The left grid shows the fortification strengths, the middle grid shows the randomly determined percentages of war-pokemon fainted by the defending attacks, and the right grid shows the number of war-pokemon that make it to each grid square and to the gym (below the grid).
If we start with 30 war-pokemon in total, 10 in each grid square of the first row the fortifications in the first column will repel 2 war-pokemon, and 10% of the 8 non-repelled war-pokemon (i.e. 0.8 war-pokemon) are defeated, resulting in 7.2 war-pokemon getting to the second row. In the second column 3 war-pokemon are repelled and 5% of the 7 non-repelled war-pokemon (i.e. 0.35 war-pokemon) are defeated, resulting in 6.65 war-pokemon getting to the second row. In the third column, one war-pokemon is repelled by the fortifications, and 15% of the remaining 9 war-pokemon (i.e. 1.35) are defeated, resulting in 7.65 warpokemon arriving in the second row.
Processing the second row, in the first column, 3 of the 7.2 war-pokemon are repelled, and 20% of the remaining 4.2 (i.e. .84 war-pokemon) are defeated, leaving 3.36 war-pokemon to proceed to the third row. In the second column, 1 of the 6.65 war-pokemon is repelled, and 15% of the remaining 5.65 (i.e. 0.8475 war-pokemon) are defeated, leaving 4.8025 to proceed to the third row. In the 3rd column 2 of the 7.65 war-pokemon are repelled by the fortifications, and and 5% of the remaining 5.65 (i.e. 0.2825) are defeated, leaving 5.3675 to proceed to the third row.
Processing the third row, 1 of the 3.36 war-pokemon in the first column are repelled by the fortifications, and 0% are defeated, leaving 2.36 to attack the gym. In the second column 2 war-pokemon are repelled, and 20% of the 2.8025 remaining (i.e. 0.5605) are defeated, leaving 2.242 war-pokemon to attack the gym. In the third column, 3 of the 5.3675 war-pokemon are repelled, and 20% of the remaining 2.3675 (i.e. 0.4735) are defeated, leaving 1.894 to attack the gym. Thus, in this simulation, 30 war-pokemon initially attack the gym, which was not enough to capture it — the gym trainers are able to defeat the 6.496 war-pokemon that actually reach the gym! This simulation resulted in failure for Team Rocket.
2 3 1 3 1 2 1 2 3 Fortification Strength 10 5 15 20 15 5 o 20 20 Defeated by attacks (determined randomly) 10 10 10 72 6.65 765 3.36 4.8025 5.3675 2,36 2242 1,894 of war pokemon that arrive in each rowExplanation / Answer
data:
Xtrain knowledge - 350 rows, 7 Columns
Xtestdata - forty two Rows, 7 Colums
Ytrain knowledge - 350 rows, 1 Columns
Ytestdata - forty two Rows, 1 Colums
b = [5,7,9,11,13,15]:
sigma square = [.1,.2,.3,.4,.5,.6,.7,.8,.9,1]
Algo:
def KN(b):
rows = Xtraindata.shape[0]
#print (rows)
matrix = numpy.zeros((350,350))
#print(matrix.shape)
for i in range(rows):
for j in range(rows):
val = numpy.exp((-1/b)*(norm(Xtraindata[i]-Xtraindata[j])**2))
matrix[i][j]=val
come matrix
#calculating K(X, Dn)
def K(xTestEntry,b):
rows=len(Xtraindata)
#print (rows)
matrix = numpy.zeros((1,rows))
for i in range(rows):
val = numpy.exp((-1/b)*(norm(Xtraindata[i]-xTestEntry)**2))
matrix[0][i]=val
come matrix
# Loping KN over b and letter of the alphabet square.
n = len(Xtraindata)
for b in [5,7,9,11,13,15]:
for letter of the alphabet in [.1,.2,.3,.4,.5,.6,.7,.8,.9,1]:
kn=KN(b)
ux=[]
for xTestEntry in Xtestdata:
kxdn =K(xTestEntry,b)
idMat = numpy.identity(n)*sigma
middle = numpy.linalg.inv(idMat + kn)
x1 = numpy.dot(kxdn,mid)
ypredict = numpy.dot(x1,Ytraindata)
ux.append(ypredict[0])
rms=sqrt(mean_squared_error(Ytestdata, ux))
print(b,sigma,rms)data:
Xtrain knowledge - 350 rows, 7 Columns
Xtestdata - forty two Rows, 7 Colums
Ytrain knowledge - 350 rows, 1 Columns
Ytestdata - forty two Rows, 1 Colums
b = [5,7,9,11,13,15]:
sigma square = [.1,.2,.3,.4,.5,.6,.7,.8,.9,1]
Algo:
def KN(b):
rows = Xtraindata.shape[0]
#print (rows)
matrix = numpy.zeros((350,350))
#print(matrix.shape)
for i in range(rows):
for j in range(rows):
val = numpy.exp((-1/b)*(norm(Xtraindata[i]-Xtraindata[j])**2))
matrix[i][j]=val
come matrix
#calculating K(X, Dn)
def K(xTestEntry,b):
rows=len(Xtraindata)
#print (rows)
matrix = numpy.zeros((1,rows))
for i in range(rows):
val = numpy.exp((-1/b)*(norm(Xtraindata[i]-xTestEntry)**2))
matrix[0][i]=val
come matrix
# Loping KN over b and letter of the alphabet square.
n = len(Xtraindata)
for b in [5,7,9,11,13,15]:
for letter of the alphabet in [.1,.2,.3,.4,.5,.6,.7,.8,.9,1]:
kn=KN(b)
ux=[]
for xTestEntry in Xtestdata:
kxdn =K(xTestEntry,b)
idMat = numpy.identity(n)*sigma
middle = numpy.linalg.inv(idMat + kn)
x1 = numpy.dot(kxdn,mid)
ypredict = numpy.dot(x1,Ytraindata)
ux.append(ypredict[0])
rms=sqrt(mean_squared_error(Ytestdata, ux))
print(b,sigma,rms)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.