首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导program编程设计、讲解Python语言程序 辅导Python程序|辅导R语言程序
项目预算:
开发周期:
发布时间:
要求地区:
Project 3: Ghostbusters
I can hear you, ghost.
Running won’t save you from my
Particle Filter!
Introduction
Pacman spends his life running from ghosts, but things were not always so. Legend has it that many years
ago, Pacman’s great grandfather Grandpac learned to hunt ghosts for sport. However, he was blinded by
his power and could only track ghosts by their banging and clanging.
In this project, you will design Pacman agents that use sensors to locate and eat invisible ghosts. You’ll
advance from locating sittng, stationary ghosts to hunting packs of multiple moving ghosts with ruthless
efficiency.
The code for this project contains the following files, available as a zip archive from the Canvas page.
Files you will edit:
busterAgents.py Agents for playing the Ghostbusters variant of Pacman.
inference.py Code for tracking ghosts over time using their sounds
Files you will not edit:
busters.py The main entry to Ghostbusters (replacing pacman.py)
bustersGhostAgents.py New ghost agents for Ghostbusters
distanceCalculator.py Computes maze distances
game.py Inner workings and helper classes for Pacman
ghostAgents.py Agents to control ghosts
graphicsDisplay.py Graphics for Pacman
graphicsUtils.py Support for Pacman graphics
keyboardAgents.py Keyboard interfaces to control Pacman
layout.py Code for reading layout files and storing their contents
util.py Utility functions
What to submit:
You will fill in portions of bustersAgents.py and inference.py during the assignment. You should submit
these files with your code and comments. Please do not change the other files in this distribution or submit
any other files.
Evaluation
Your code will be run through the autograder for technical correctness. Please do not change the names of
any provided functions or classes within the code, or you will wreak havoc on the autograder. However, the
correctness of your implementation – not the autograder’s judgments – will be the final judge of your score.
I will review and grade assignments individually to ensure that you receive due credit for your work.
Ghostbusters and BNs
In Ghostbusters, the goal is to hunt down scared but invisible ghosts. Pacman, ever resourceful, is equipped
with sonar (ears) that provides noisy readings of the Manhattan distance to each ghost. The game ends
when Pacman has eaten all the ghosts. To start, try playing a game yourself using the keyboard.
python busters.py
The blocks of color indicate where the each ghost could possibly be, given the noisy distance reading provided
to Pacman. The noisy distances at the bottom of the display are always non-negative, and always within 7
of the true distance. The probability of a distance reading decreases exponentially with its difference from
the true distance.
Your primary task in this project is to implement inference to track the ghosts. For the keyboard based
game above, a crude form of inference was implemented for you by default: all squares in which a ghost
could possibly be are shaded by the color of the ghost. Naturally, we want a better estimate of the ghosts’
positions. Fortunately, Bayes’ Nets provide us with powerful tools for making the most of the information
we have. Throughout the rest of this project, you will implement algorithms for performing both exact and
approximate inference using Bayes’ Nets. The lab is challenging, so we do encourage you to start early and
seek help when necessary.
While watching and debugging your code with the autograder, it will be helpful to have some understanding
of what the autograder is doing. There are two types of tests in this project, as differentiated by their *.test
files found in the subdirectories of the test_cases folder. For tests of class DoubleInferenceAgentTest,
you will see visualizations of the inference distributions generated by your code, but all Pacman actions
will be preselected according to the actions of the staff implementation. This is necessary in order to allow
comparison of your distributions with the staff’s distributions. The second type of test is GameScoreTest,
in which your BustersAgent will actually select actions for Pacman and you will watch your Pacman play
and win games.
As you implement and debug your code, you may find it useful to run a single test at a time. In order to do
this, you will need to use the -t flag with the autograder. For example if you only want to run the first test
of question 1, use:
python autograder.py -t test_cases/q1/1-ExactObserve
In general, all test cases can be found inside test_cases/q*
Question 1: Exact Inference Observation (6 points)
In this question, you will update the observe method in ExactInference class of inference.py to correctly
update the agent’s belief distribution over ghost positions given an observation from Pacman’s sensors. A
correct implementation should also handle one special case: when a ghost is eaten, you should place that
ghost in its prison cell, as described in the comments of observe.
To run the autograder for this question and visualize the output:
python autograder.py -q q1
As you watch the test cases, be sure that you understand how the squares converge to their final coloring.
In test cases where is Pacman boxed in (which is to say, he is unable to change his observation point), why
does Pacman sometimes have trouble finding the exact location of the ghost?
Note: Your busters agents have a separate inference module for each ghost they are tracking. That’s why
if you print an observation inside the observe function, you’ll only see a single number even though there
may be multiple ghosts on the board.
Hints:
• You are implementing the online belief update for observing new evidence. Before any readings, Pacman
believes the ghost could be anywhere: a uniform prior (see initializeUniformly). After receiving a
reading, the observe function is called, which must update the belief at every position.
• Before typing any code, write down the equation of the inference problem you are trying to solve.
• Try printing noisyDistance, emissionModel, and PacmanPosition (in the observe function) to get
started.
• In the Pacman display, high posterior beliefs are represented by bright colors, while low beliefs are
represented by dim colors. You should start with a large cloud of belief that shrinks over time as more
evidence accumulates.
• Beliefs are stored as util.Counter objects (like dictionaries) in a field called self.beliefs, which
you should update.
• You should not need to store any evidence. The only thing you need to store in ExactInference is
self.beliefs.
Question 2: Exact Inference with Time Elapse (4 points)
In the previous question you implemented belief updates for Pacman based on his observations. Fortunately,
Pacman’s observations are not his only source of knowledge about where a ghost may be. Pacman also has
knowledge about the ways that a ghost may move, namely that the ghost can not move through a wall or
more than one space in one timestep.
To understand why this is useful to Pacman, consider the following scenario in which there is Pacman and
one ghost. Pacman receives many observations which indicate the ghost is very near, but then one which
indicates the ghost is very far. The reading indicating the ghost is very far is likely to be the result of a
buggy sensor. Pacman’s prior knowledge of how the ghost may move will decrease the impact of this reading
since Pacman knows the ghost could not move so far in only one move.
In this question, you will implement the elapseTime method in ExactInference. Your agent has access to
the action distribution for any GhostAgent. In order to test your elapseTime implementation separately
from your observe implementation in the previous question, this question will not make use of your observe
implementation.
Since Pacman is not utilizing any observations about the ghost, this means that Pacman will start with
a uniform distribution over all spaces, and then update his beliefs according to how he knows the ghost
is able to move. Since Pacman is not observing the ghost, this means the ghost’s actions will not impact
Pacman’s beliefs. Over time, Pacman’s beliefs will come to reflect places on the board where he believes
ghosts are most likely to be given the geometry of the board and what Pacman already knows about their
valid movements.
For the tests in this question we will sometimes use a ghost with random movements and other times we will
use the GoSouthGhost. This ghost tends to move south over time, and without any observations, Pacman’s
belief distribution should begin to focus around the bottom of the board. To see which ghost is used for
each test case, you can look in the .test files.
To run the autograder for this question and visualize the output:
python autograder.py -q q2
As an example of the GoSouthGhostAgent, you can run
python autograder.py -t test_cases/q2/2-ExactElapse
and observe that the distribution becomes concentrated at the bottom of the board.
As you watch the autograder output, remember that lighter squares indicate that pacman believes a ghost is
more likely to occupy that location, and darker squares indicate a ghost is less likely to occupy that location.
For which of the test cases do you notice differences emerging in the shading of the squares? Can you explain
why some squares get lighter and some squares get darker?
Hints:
• Instructions for obtaining a distribution over where a ghost will go next, given its current position and
the gameState, appears in the comments of ExactInference.elapseTime in inference.py.
• We assume that ghosts still move independently of one another, so while you can develop all of your
code for one ghost at a time, adding multiple ghosts should still work correctly.
Question 3: Exact Inference Full Test (3 points)
Now that Pacman knows how to use both his prior knowledge and his observations when figuring out where
a ghost is, he is ready to hunt down ghosts on his own. This question will use your observe and elapseTime
implementations together, along with a simple greedy hunting strategy which you will implement for this
question. In the simple greedy strategy, Pacman assumes that each ghost is in its most likely position
according to its beliefs, then moves toward the closest ghost. Up to this point, Pacman has moved by
randomly selecting a valid action.
Implement the chooseAction method in GreedyBustersAgent in bustersAgents.py. Your agent should
first find the most likely position of each remaining (uncaptured) ghost, then choose an action that minimized
the distance to the closes ghost. If correctly implemented, your agent should win the game in
q3/3-gameScoreTest with a score greater than 700 at least 8 out of 10 times. Note: the autograder will
also check the correctness of your inference directly, but the outcome of games is a reasonable sanity check.
To run the autograder for this question and visualize the output:
python autograder.py -q q3
Note: If you want to run this test (or any of the other test) without graphics you can add the following flag:
python autograder.py -q q3 --no-graphics
Hints:
• When correctly implemented, your agent will thrash around a bit in order to capture a ghost.
• The comments of chooseAction provide you with useful method calls for computing maze distance
and successor positions.
• Make sure to only consider the living ghosts, as described in the comments.
Question 4: Approximate Inference Observation (4 points)
Approximate inference is very trendy among ghost hunters this season. Next, you will implement a particle
filtering algorithm for tracking a single ghost.
Implement the functions initializeUniformly, getBeliefDistribution, and observe for the ParticleFilter
class in inference.py. A correct implementation should also handle two special cases.
(1) When all your particles receive zero weight based on the evidence, you should resample all particles
from the prior to recover.
(2) When a ghost is eaten, you should update all particles to place that ghost in its prison cell, as described
in the comments of observe.
When complete, you should be able to track ghosts nearly as effectively as with exact inference.
To run the autograder for this question and visualize the output:
python autograder.py -q q4
Hints:
• A particle (sample) is a ghost position in this inference problem.
• The belief cloud generated by a particle filter will look noisy compared to the one for exact inference.
Question 5: Approximate Inference with Time Elapse (3 points)
Implement the elapseTime function for the ParticleFilter class in inference.py. When complete, you
should be able to track ghosts nearly as effectively as with exact inference.
Note that in this question, we will test both the elapseTime function in isolation, as well as the full
implementation of the particle filter combining elapseTime and observe.
To run the autograder for this question and visualize the output:
python autograder.py -q q5
For the tests in this question we will sometimes use a ghost with random movements and other times we will
use the GoSouthGhost. This ghost tends to move south over time, and without any observations, Pacman’s
belief distribution should begin to focus around the bottom of the board. To see which ghost is used for
each test case you can look in the .test files. As an example, you can run
python autograder.py -t test_cases/q5/2-ParticleElapse
and observe that the distribution becomes concentrated at the bottom of the board.
Extra Credit Question 6: Joint Particle Filter Observation (3 points)
So far, we have tracked each ghost independently, which works fine for the default RandomGhost or more advanced
DirectionalGhost. However, the prized DispersingGhost chooses actions that avoid other ghosts.
Since the ghosts’ transition models are no longer independent, all ghosts must be tracked jointly in a dynamic
Bayes’ net!
The Bayes’ net has the following structure, where the hidden variables G represent ghost positions and the
emission variables E are the noisy distances to each ghost. This structure can be extended to more ghosts,
but only two (a and b) are shown below.
You will now implement a particle filter that tracks multiple ghosts simultaneously. Each particle will
represent a tuple of ghost positions that is a sample of where all the ghosts are at the present time. The
code is already set up to extract marginal distributions about each ghost from the joint inference algorithm
you will create, so that belief clouds about individual ghosts can be displayed.
Complete the initializeParticles, getBeliefDistribution and observeState methods in JointParticleFilter
to weight and resample the whole list of particles based on new evidence. As before, a correct implementation
should also handle two special cases:
(1) When all your particles receive zero weight based on the evidence, you should resample all particles
from the prior to recover.
(2) When a ghost is eaten, you should update all particles to place that ghost in its prison cell, as described
in the comments of observeState.
You should now effectively track dispersing ghosts. To run the autograder for this question and visualize the
output:
python autograder.py -q q6
Extra Credit Question 7: Joint Particle Filter with Elapse Time (2 points)
Complete the elapseTime method in JointParticleFilter in inference.py to resample each particle
correctly for the Bayes’ net. In particular, each ghost should draw a new position conditioned on the
positions of all the ghosts at the previous time step. The comments in the method provide instructions for
support functions to help with sampling and creating the correct distribution.
Note that completing this question involves removing the call to util.raiseNotDefined(). This means
that the autograder will now grade both question 6 and question 7. Since these questions involve more
computational power (and time) to grade, please be patient!
As you run the autograder note that q7/1-JointParticleElapse and q7/2-JointParticleElapse test
your elapseTime implementations only, and pacman knows that the ghosts will move to the sides of the
gameboard. What is different between the tests, and why?
To run the autograder for this question, use:
python autograder.py -q q7
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!