-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpowerChoosingAgents.py
75 lines (65 loc) · 2.95 KB
/
powerChoosingAgents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# powerChoosingAgents.py
# ----------------------
# Licensing Information: You are free to use or extend these projects for
# educational purposes provided that (1) you do not distribute or publish
# solutions, (2) you retain this notice, and (3) you provide clear
# attribution to UC Berkeley, including a link to http://ai.berkeley.edu.
#
# Attribution Information: The Pacman AI projects were developed at UC Berkeley.
# The core projects and autograders were primarily created by John DeNero
# (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu).
# Student side autograding was added by Brad Miller, Nick Hay, and
# Pieter Abbeel (pabbeel@cs.berkeley.edu).
# powerAgents.py
# --------------
# Licensing Information: You are free to use or extend these projects for
# educational purposes provided that (1) you do not distribute or publish
# solutions, (2) you retain this notice, and (3) you provide clear
# attribution to UC Berkeley, including a link to http://ai.berkeley.edu.
#
# Attribution Information: The Pacman AI projects were developed at UC Berkeley.
# The core projects and autograders were primarily created by John DeNero
# (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu).
# Student side autograding was added by Brad Miller, Nick Hay, and
# Pieter Abbeel (pabbeel@cs.berkeley.edu).
from powerAgents import *
class ReflexPowerChoosingAgent(ReflexPowerAgent):
"""
The function getAction() is already defined in ReflexPowerAgent.
Students just have to define the power choosing function here and the game
then plays automatically.
"""
def getPowerChoice(self,inferredGhostPowers):
"""
Question 5: Power Prediction
inferredGhostPowers is a dictionary with keys 'laser',
'speed' and 'blast'. These powers were inferred using
your bayesNet inference code.
inferredGhostPowers is guaranteed to have exactly
one power set to 1 and the others set to 0.
Below, you can choose your own agent's powers based on
the inference. Keep in mind that if your agent
chooses powers that are the same as the ghost, they will be less
effective and that some powers are better counterparts
to others. You should figure out the best powers to choose in
response to the ghosts' powers.
You can choose at most one of these three powers!
Your powers dictionary should contain exactly one
entry with a value of 1 and two entries with values of 0.
"""
powers = {}
"*** YOUR CODE HERE ***"
power = None
pacPower = None
for key in inferredGhostPowers.keys():
powers[key] = 0
if inferredGhostPowers[key] == 1:
power = key
if power == 'speed':
pacPower = 'blast'
if power == 'blast':
pacPower = 'laser'
if power == 'laser':
pacPower = 'speed'
powers[pacPower] = 1
return powers