Posted: December 18th, 2015

2.1.3 Detailed Instructions and Marking Scheme

In the ﬁle klingon_fillin.py (Fig. 6), ﬁll in the following missing code snippets denoted by “…”.

1. In the ship.__init__(xklingon, yklingon) initialization method, the missing initialization of the entries of p_w for the probability of the location of the klingon should be ﬁlled in. [3 marks] Hint: This is easy: what is the initial probability of the klingon being at a particular location? (Remember the mine search problem and what the initial probability of the mine being at some location was).

2. Fill in the missing code for ship.p_d_cond_w(d,x,y). The method should return p(d|x,y) where x and y are the location of the Klingon and we assume that the sonar returns perfectly accurate distances d of the ship from the Klingon. Note that in that method you have access to the ship’s location via self.x and self.y. In detail, the method should return the probability of 1.0 if the potential position of the Klingon (x,y) has distance d from the ship’s position (self.x,self.y), and 0.0 otherwise. [3 marks]

3. Advanced Task: In ship.measure(d), ﬁll in the Bayesian update for p(w|d) for the Klingon location given the distance. In the code, a variable p_w_cond_d has already been prepared. [3 marks] Hint: check the mines example from the lecture. Hint 2: this task is challenging; if you have diﬃculties with it, leave it to the end. In the meantime, set p_w_cond_d to the equidis

Place an order in 3 easy steps. Takes less than 5 mins.