add more intelligent discard
If a card can be a lot of things, it will be discarded over something that we know more about
This commit is contained in:
parent
38d3e2f829
commit
7ed8df1360
|
@ -7,13 +7,14 @@ def format_hint(h):
|
||||||
if h == HINT_COLOR:
|
if h == HINT_COLOR:
|
||||||
return "color"
|
return "color"
|
||||||
return "rank"
|
return "rank"
|
||||||
|
|
||||||
class SkillIssuePlayer(agent.Agent):
|
class SkillIssuePlayer(agent.Agent):
|
||||||
def __init__(self, name, pnr):
|
def __init__(self, name, pnr):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.hints = {}
|
self.hints = {}
|
||||||
self.pnr = pnr
|
self.pnr = pnr
|
||||||
self.explanation = []
|
self.explanation = []
|
||||||
|
|
||||||
def get_action(self, nr, hands, knowledge, trash, played, board, valid_actions, hints, hits, cards_left):
|
def get_action(self, nr, hands, knowledge, trash, played, board, valid_actions, hints, hits, cards_left):
|
||||||
for player,hand in enumerate(hands):
|
for player,hand in enumerate(hands):
|
||||||
for card_index,_ in enumerate(hand):
|
for card_index,_ in enumerate(hand):
|
||||||
|
@ -32,6 +33,11 @@ class SkillIssuePlayer(agent.Agent):
|
||||||
for i,k in enumerate(my_knowledge):
|
for i,k in enumerate(my_knowledge):
|
||||||
if util.is_playable(k, board):
|
if util.is_playable(k, board):
|
||||||
return Action(PLAY, card_index=i)
|
return Action(PLAY, card_index=i)
|
||||||
|
|
||||||
|
#if util.maybe_playable(k, board):
|
||||||
|
# if (util.probability(util.playable(board), k) >= 0 and hits < 2):
|
||||||
|
# return Action(PLAY, card_index=i)
|
||||||
|
|
||||||
if util.is_useless(k, board):
|
if util.is_useless(k, board):
|
||||||
potential_discards.append(i)
|
potential_discards.append(i)
|
||||||
|
|
||||||
|
@ -78,7 +84,11 @@ class SkillIssuePlayer(agent.Agent):
|
||||||
|
|
||||||
if hints > 0:
|
if hints > 0:
|
||||||
hints = util.filter_actions(HINT_COLOR, valid_actions) + util.filter_actions(HINT_RANK, valid_actions)
|
hints = util.filter_actions(HINT_COLOR, valid_actions) + util.filter_actions(HINT_RANK, valid_actions)
|
||||||
|
|
||||||
|
#this will give one of the hints inside the list of possible things to hint.
|
||||||
|
|
||||||
hintgiven = random.choice(hints)
|
hintgiven = random.choice(hints)
|
||||||
|
|
||||||
if hintgiven.type == HINT_COLOR:
|
if hintgiven.type == HINT_COLOR:
|
||||||
for i,card in enumerate(hands[hintgiven.player]):
|
for i,card in enumerate(hands[hintgiven.player]):
|
||||||
if card.color == hintgiven.color:
|
if card.color == hintgiven.color:
|
||||||
|
@ -90,7 +100,87 @@ class SkillIssuePlayer(agent.Agent):
|
||||||
|
|
||||||
return hintgiven
|
return hintgiven
|
||||||
|
|
||||||
return random.choice(util.filter_actions(DISCARD, valid_actions))
|
|
||||||
|
|
||||||
|
|
||||||
|
#for i,k in enumerate(my_knowledge):
|
||||||
|
# print(k)
|
||||||
|
|
||||||
|
|
||||||
|
#print(board)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if it could be a value that's useful, it goes into num
|
||||||
|
nums = [0, 0, 0, 0, 0]
|
||||||
|
#if it could be a value, it goes into denom
|
||||||
|
denoms = [0, 0, 0, 0, 0]
|
||||||
|
|
||||||
|
|
||||||
|
#For each card:
|
||||||
|
cardIndex = 0
|
||||||
|
for i in my_knowledge:
|
||||||
|
|
||||||
|
#print(my_knowledge[cardIndex])
|
||||||
|
#print(cardIndex)
|
||||||
|
#for the colors in the card:
|
||||||
|
colorIndex = 0
|
||||||
|
for j in i:
|
||||||
|
#print(my_knowledge[cardIndex][colorIndex])
|
||||||
|
cardOnBoard = board[colorIndex][1]
|
||||||
|
|
||||||
|
#print(cardOnBoard)
|
||||||
|
|
||||||
|
|
||||||
|
for k in j:
|
||||||
|
denoms[cardIndex] = denoms[cardIndex] + k
|
||||||
|
if cardOnBoard < k:
|
||||||
|
nums[cardIndex] = nums[cardIndex] + k
|
||||||
|
#print("num is: ")
|
||||||
|
#print(nums)
|
||||||
|
#print("denom is ")
|
||||||
|
#print(denoms)
|
||||||
|
colorIndex = colorIndex + 1
|
||||||
|
|
||||||
|
cardIndex = cardIndex + 1
|
||||||
|
|
||||||
|
#print("num is: ")
|
||||||
|
#print(nums)
|
||||||
|
#print("denom is ")
|
||||||
|
#print(denoms)
|
||||||
|
totals = [0.0, 0.0, 0.0, 0.0, 0.0]
|
||||||
|
|
||||||
|
#doing it like this because idk why python wouldn't accept the other way
|
||||||
|
i = 0
|
||||||
|
for total in totals:
|
||||||
|
totals[i] = totals[i] + nums[i] / denoms[i]
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
|
||||||
|
#print(totals)
|
||||||
|
|
||||||
|
index = 0
|
||||||
|
i = 0
|
||||||
|
max = 50
|
||||||
|
for denom in denoms:
|
||||||
|
if max <= denom:
|
||||||
|
index = i
|
||||||
|
max = denom
|
||||||
|
i = i + 1
|
||||||
|
#print(max)
|
||||||
|
#print(index)
|
||||||
|
|
||||||
|
possibleDiscards = util.filter_actions(DISCARD, valid_actions)
|
||||||
|
|
||||||
|
return possibleDiscards[index]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def inform(self, action, player):
|
def inform(self, action, player):
|
||||||
if action.type in [PLAY, DISCARD]:
|
if action.type in [PLAY, DISCARD]:
|
||||||
|
@ -101,4 +191,6 @@ class SkillIssuePlayer(agent.Agent):
|
||||||
self.hints[(player,action.card_index+i)] = self.hints[(player,action.card_index+i+1)]
|
self.hints[(player,action.card_index+i)] = self.hints[(player,action.card_index+i+1)]
|
||||||
self.hints[(player,action.card_index+i+1)] = set()
|
self.hints[(player,action.card_index+i+1)] = set()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
agent.register("skill", "Skill Issue Player", SkillIssuePlayer)
|
agent.register("skill", "Skill Issue Player", SkillIssuePlayer)
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
Treatment: ('skill', 3668)
|
||||||
|
[(0, 1), (3, 1), (4, 4), (4, 2), (2, 5), (0, 1), (4, 1), (0, 3), (1, 3), (1, 4), (2, 2), (3, 3), (0, 3), (1, 1), (3, 1), (3, 2), (3, 3), (0, 1), (1, 2), (3, 4), (4, 2), (0, 2), (2, 4), (0, 4), (2, 1), (3, 4), (2, 3), (2, 1), (4, 4), (0, 4), (3, 2), (4, 3), (4, 1), (3, 5), (0, 2), (1, 2), (1, 1), (3, 1), (1, 3), (4, 1)]
|
||||||
|
MOVE: 0 1 None 1 None 1
|
||||||
|
skill hints You about all their 1 hints remaining: 7
|
||||||
|
You has white 2, yellow 5, white 4, yellow 4, yellow 1
|
||||||
|
MOVE: 1 2 4 1 None None
|
||||||
|
You plays yellow 1 successfully! Board is now green 0, yellow 1, white 0, blue 0, red 0
|
||||||
|
You now has white 2, yellow 5, white 4, yellow 4, green 1
|
||||||
|
MOVE: 0 1 None 1 None 1
|
||||||
|
skill hints You about all their 1 hints remaining: 6
|
||||||
|
You has white 2, yellow 5, white 4, yellow 4, green 1
|
||||||
|
MOVE: 1 1 None 0 None 1
|
||||||
|
You hints skill about all their 1 hints remaining: 5
|
||||||
|
skill has red 3, white 1, red 5, white 3, green 5
|
||||||
|
MOVE: 0 0 None 1 0 None
|
||||||
|
skill hints You about all their green cards hints remaining: 4
|
||||||
|
You has white 2, yellow 5, white 4, yellow 4, green 1
|
||||||
|
MOVE: 1 2 4 1 None None
|
||||||
|
You plays green 1 successfully! Board is now green 1, yellow 1, white 0, blue 0, red 0
|
||||||
|
You now has white 2, yellow 5, white 4, yellow 4, blue 1
|
||||||
|
MOVE: 0 1 None 1 None 1
|
||||||
|
skill hints You about all their 1 hints remaining: 3
|
||||||
|
You has white 2, yellow 5, white 4, yellow 4, blue 1
|
||||||
|
MOVE: 1 0 None 0 2 None
|
||||||
|
You hints skill about all their white cards hints remaining: 2
|
||||||
|
skill has red 3, white 1, red 5, white 3, green 5
|
||||||
|
MOVE: 0 2 1 None None None
|
||||||
|
skill plays white 1 successfully! Board is now green 1, yellow 1, white 1, blue 0, red 0
|
||||||
|
skill now has red 3, red 5, white 3, green 5, red 4
|
||||||
|
MOVE: 1 2 4 1 None None
|
||||||
|
You plays blue 1 successfully! Board is now green 1, yellow 1, white 1, blue 1, red 0
|
||||||
|
You now has white 2, yellow 5, white 4, yellow 4, red 2
|
||||||
|
MOVE: 0 1 None 1 None 2
|
||||||
|
skill hints You about all their 2 hints remaining: 1
|
||||||
|
You has white 2, yellow 5, white 4, yellow 4, red 2
|
||||||
|
MOVE: 1 2 0 1 None None
|
||||||
|
You plays white 2 successfully! Board is now green 1, yellow 1, white 2, blue 1, red 0
|
||||||
|
You now has yellow 5, white 4, yellow 4, red 2, white 5
|
||||||
|
MOVE: 0 1 None 1 None 4
|
||||||
|
skill hints You about all their 4 hints remaining: 0
|
||||||
|
You has yellow 5, white 4, yellow 4, red 2, white 5
|
||||||
|
MOVE: 1 3 2 1 None None
|
||||||
|
You discards yellow 4
|
||||||
|
trash is now yellow 4
|
||||||
|
You now has yellow 5, white 4, red 2, white 5, green 1
|
||||||
|
MOVE: 0 1 None 1 None 1
|
||||||
|
skill hints You about all their 1 hints remaining: 0
|
||||||
|
You has yellow 5, white 4, red 2, white 5, green 1
|
||||||
|
MOVE: 1 2 4 1 None None
|
||||||
|
You plays green 1 and fails. Board was green 1, yellow 1, white 2, blue 1, red 0
|
||||||
|
You now has yellow 5, white 4, red 2, white 5, red 1
|
||||||
|
MOVE: 0 3 0 None None None
|
||||||
|
skill discards red 3
|
||||||
|
trash is now yellow 4, green 1, red 3
|
||||||
|
skill now has red 5, white 3, green 5, red 4, green 3
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays red 2 and fails. Board was green 1, yellow 1, white 2, blue 1, red 0
|
||||||
|
You now has yellow 5, white 4, white 5, red 1, yellow 3
|
||||||
|
MOVE: 0 0 None 1 4 None
|
||||||
|
skill hints You about all their red cards hints remaining: 0
|
||||||
|
You has yellow 5, white 4, white 5, red 1, yellow 3
|
||||||
|
MOVE: 1 2 3 1 None None
|
||||||
|
You plays red 1 successfully! Board is now green 1, yellow 1, white 2, blue 1, red 1
|
||||||
|
You now has yellow 5, white 4, white 5, yellow 3, yellow 4
|
||||||
|
MOVE: 0 3 0 None None None
|
||||||
|
skill discards red 5
|
||||||
|
trash is now yellow 4, green 1, red 3, red 2, red 5
|
||||||
|
skill now has white 3, green 5, red 4, green 3, white 2
|
||||||
|
MOVE: 1 2 1 1 None None
|
||||||
|
You plays white 4 and fails. Board was green 1, yellow 1, white 2, blue 1, red 1
|
||||||
|
You now has yellow 5, white 5, yellow 3, yellow 4, blue 3
|
||||||
|
Score 6
|
|
@ -0,0 +1,51 @@
|
||||||
|
Treatment: ('skill', 6912)
|
||||||
|
[(4, 2), (3, 1), (3, 4), (1, 2), (0, 4), (2, 2), (0, 3), (3, 5), (1, 2), (2, 1), (4, 1), (3, 2), (2, 2), (3, 1), (2, 3), (3, 2), (1, 1), (2, 4), (0, 5), (0, 1), (0, 4), (1, 3), (1, 3), (1, 1), (1, 4), (4, 4), (1, 1), (3, 3), (4, 5), (3, 1), (2, 4), (0, 3), (4, 1), (2, 1), (2, 3), (2, 5), (0, 1), (2, 1), (1, 5), (3, 3)]
|
||||||
|
MOVE: 0 0 None 1 0 None
|
||||||
|
skill hints You about all their green cards hints remaining: 7
|
||||||
|
You has red 3, red 3, green 1, red 1, red 2
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays green 1 successfully! Board is now green 1, yellow 0, white 0, blue 0, red 0
|
||||||
|
You now has red 3, red 3, red 1, red 2, red 2
|
||||||
|
MOVE: 0 0 None 1 4 None
|
||||||
|
skill hints You about all their red cards hints remaining: 6
|
||||||
|
You has red 3, red 3, red 1, red 2, red 2
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays red 1 successfully! Board is now green 1, yellow 0, white 0, blue 0, red 1
|
||||||
|
You now has red 3, red 3, red 2, red 2, blue 1
|
||||||
|
MOVE: 0 1 None 1 None 2
|
||||||
|
skill hints You about all their 2 hints remaining: 5
|
||||||
|
You has red 3, red 3, red 2, red 2, blue 1
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays red 2 successfully! Board is now green 1, yellow 0, white 0, blue 0, red 2
|
||||||
|
You now has red 3, red 3, red 2, blue 1, blue 4
|
||||||
|
MOVE: 0 1 None 1 None 3
|
||||||
|
skill hints You about all their 3 hints remaining: 4
|
||||||
|
You has red 3, red 3, red 2, blue 1, blue 4
|
||||||
|
MOVE: 1 2 1 1 None None
|
||||||
|
You plays red 3 successfully! Board is now green 1, yellow 0, white 0, blue 0, red 3
|
||||||
|
You now has red 3, red 2, blue 1, blue 4, yellow 2
|
||||||
|
MOVE: 0 0 None 1 3 None
|
||||||
|
skill hints You about all their blue cards hints remaining: 3
|
||||||
|
You has red 3, red 2, blue 1, blue 4, yellow 2
|
||||||
|
MOVE: 1 2 3 1 None None
|
||||||
|
You plays blue 4 and fails. Board was green 1, yellow 0, white 0, blue 0, red 3
|
||||||
|
You now has red 3, red 2, blue 1, yellow 2, green 4
|
||||||
|
MOVE: 0 1 None 1 None 1
|
||||||
|
skill hints You about all their 1 hints remaining: 2
|
||||||
|
You has red 3, red 2, blue 1, yellow 2, green 4
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays blue 1 successfully! Board is now green 1, yellow 0, white 0, blue 1, red 3
|
||||||
|
You now has red 3, red 2, yellow 2, green 4, white 2
|
||||||
|
MOVE: 0 1 None 1 None 4
|
||||||
|
skill hints You about all their 4 hints remaining: 1
|
||||||
|
You has red 3, red 2, yellow 2, green 4, white 2
|
||||||
|
MOVE: 1 2 3 1 None None
|
||||||
|
You plays green 4 and fails. Board was green 1, yellow 0, white 0, blue 1, red 3
|
||||||
|
You now has red 3, red 2, yellow 2, white 2, green 3
|
||||||
|
MOVE: 0 1 None 1 None 2
|
||||||
|
skill hints You about all their 2 hints remaining: 0
|
||||||
|
You has red 3, red 2, yellow 2, white 2, green 3
|
||||||
|
MOVE: 1 2 3 1 None None
|
||||||
|
You plays white 2 and fails. Board was green 1, yellow 0, white 0, blue 1, red 3
|
||||||
|
You now has red 3, red 2, yellow 2, green 3, blue 5
|
||||||
|
Score 5
|
|
@ -0,0 +1,58 @@
|
||||||
|
Treatment: ('skill', 7307)
|
||||||
|
[(0, 1), (2, 5), (2, 2), (4, 5), (4, 3), (2, 4), (4, 1), (1, 1), (1, 4), (4, 1), (2, 3), (2, 3), (4, 2), (2, 1), (1, 2), (1, 3), (4, 3), (4, 4), (2, 2), (4, 2), (2, 4), (3, 2), (3, 1), (1, 1), (0, 2), (3, 4), (3, 1), (0, 3), (0, 3), (0, 5), (1, 1), (3, 3), (4, 4), (3, 4), (1, 2), (3, 5), (4, 1), (0, 1), (3, 2), (3, 3)]
|
||||||
|
MOVE: 0 0 None 1 3 None
|
||||||
|
skill hints You about all their blue cards hints remaining: 7
|
||||||
|
You has yellow 4, green 2, blue 1, green 1, white 1
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays blue 1 successfully! Board is now green 0, yellow 0, white 0, blue 1, red 0
|
||||||
|
You now has yellow 4, green 2, green 1, white 1, green 1
|
||||||
|
MOVE: 0 1 None 1 None 1
|
||||||
|
skill hints You about all their 1 hints remaining: 6
|
||||||
|
You has yellow 4, green 2, green 1, white 1, green 1
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays green 1 successfully! Board is now green 1, yellow 0, white 0, blue 1, red 0
|
||||||
|
You now has yellow 4, green 2, white 1, green 1, white 5
|
||||||
|
MOVE: 0 1 None 1 None 2
|
||||||
|
skill hints You about all their 2 hints remaining: 5
|
||||||
|
You has yellow 4, green 2, white 1, green 1, white 5
|
||||||
|
MOVE: 1 2 1 1 None None
|
||||||
|
You plays green 2 successfully! Board is now green 2, yellow 0, white 0, blue 1, red 0
|
||||||
|
You now has yellow 4, white 1, green 1, white 5, white 2
|
||||||
|
MOVE: 0 0 None 1 2 None
|
||||||
|
skill hints You about all their white cards hints remaining: 4
|
||||||
|
You has yellow 4, white 1, green 1, white 5, white 2
|
||||||
|
MOVE: 1 2 1 1 None None
|
||||||
|
You plays white 1 successfully! Board is now green 2, yellow 0, white 1, blue 1, red 0
|
||||||
|
You now has yellow 4, green 1, white 5, white 2, red 5
|
||||||
|
MOVE: 0 1 None 1 None 2
|
||||||
|
skill hints You about all their 2 hints remaining: 3
|
||||||
|
You has yellow 4, green 1, white 5, white 2, red 5
|
||||||
|
MOVE: 1 2 3 1 None None
|
||||||
|
You plays white 2 successfully! Board is now green 2, yellow 0, white 2, blue 1, red 0
|
||||||
|
You now has yellow 4, green 1, white 5, red 5, red 3
|
||||||
|
MOVE: 0 0 None 1 2 None
|
||||||
|
skill hints You about all their white cards hints remaining: 2
|
||||||
|
You has yellow 4, green 1, white 5, red 5, red 3
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays white 5 and fails. Board was green 2, yellow 0, white 2, blue 1, red 0
|
||||||
|
You now has yellow 4, green 1, red 5, red 3, white 4
|
||||||
|
MOVE: 0 0 None 1 4 None
|
||||||
|
skill hints You about all their red cards hints remaining: 1
|
||||||
|
You has yellow 4, green 1, red 5, red 3, white 4
|
||||||
|
MOVE: 1 2 2 1 None None
|
||||||
|
You plays red 5 and fails. Board was green 2, yellow 0, white 2, blue 1, red 0
|
||||||
|
You now has yellow 4, green 1, red 3, white 4, red 1
|
||||||
|
MOVE: 0 1 None 1 None 1
|
||||||
|
skill hints You about all their 1 hints remaining: 0
|
||||||
|
You has yellow 4, green 1, red 3, white 4, red 1
|
||||||
|
MOVE: 1 2 4 1 None None
|
||||||
|
You plays red 1 successfully! Board is now green 2, yellow 0, white 2, blue 1, red 1
|
||||||
|
You now has yellow 4, green 1, red 3, white 4, yellow 1
|
||||||
|
MOVE: 0 3 0 None None None
|
||||||
|
skill discards yellow 3
|
||||||
|
trash is now white 5, red 5, yellow 3
|
||||||
|
skill now has green 4, white 1, yellow 5, green 4, yellow 4
|
||||||
|
MOVE: 1 2 1 1 None None
|
||||||
|
You plays green 1 and fails. Board was green 2, yellow 0, white 2, blue 1, red 1
|
||||||
|
You now has yellow 4, red 3, white 4, yellow 1, red 1
|
||||||
|
Score 6
|
Loading…
Reference in New Issue