MATLAB Answers

Hi guys help pls I am in an exam I could'nt solve this question

3 views (last 30 days)
ahmet bal
ahmet bal on 31 May 2020
Commented: ahmet bal on 31 May 2020
When an attacker moves towards his enemy, he moves 2 steps forward with 50% probability and 1 step back with 50% probability. If it reaches its enemy, the dagger will try to neutralize its target with the arrow if it cannot approach. He can defeat his enemy with a probability of 45% with arrow and 90% with dagger. If he could not reach his enemy up to 100 moves, the arrow would otherwise use daggers, so what is the probability of neutralizing his enemy, which is 70 steps away from 100 moves? Write a monte carlo simulation code to answer this question. You can answer the question by repeating 100000 (one hundred thousand) times and averaging it. (It gonna be in script file)

  0 Comments

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 31 May 2020
Hint:
x = 0
hasArrow = 1;
hasDagger = 0;
for k = 1 : 100000 % Experiment number
for moves = 1 : 100 % Moves number
p = rand(1)
if p < 10 %............
% more code to count neutralizings depending on weapon.
end
end
end
p = count / 100000 % Average probability of neutralizing
When an attacker moves towards his enemy, he moves 2 steps forward with 50% probability and 1 step back with 50% probability. If it reaches its enemy, the dagger will try to neutralize its target with the arrow if it cannot approach. He can defeat his enemy with a probability of 45% with arrow and 90% with dagger. If he could not reach his enemy up to 100 moves, the arrow would otherwise use daggers, so what is the probability of neutralizing his enemy, which is 70 steps away from 100 moves? Write a monte carlo simulation code to answer this question. You can answer the question by repeating 100000 (one hundred thousand) times and averaging it. (It gonna be in script file)

  1 Comment

ahmet bal
ahmet bal on 31 May 2020
thanx sir but what happend there ('if')?
I need to certainly answer

Sign in to comment.


Translated by