This repository has been archived by the owner on Dec 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AI.py
85 lines (79 loc) · 2.43 KB
/
AI.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
76
77
78
79
80
81
82
83
84
85
import cards_array;
import cards
def add_cards(hand, deck):
while True:
if len(hand) < 5:
hand.append(deck[0])
deck.remove(deck[0])
else:
break
return hand, deck
def ai_main(hand, deck):
is_bun = False
is_patty = False
is_topping = False
for x in hand:
if x.get_name() == "Bun":
is_bun = True
for x in hand:
if x.get_name() == "Patty":
is_patty = True
for x in hand:
if x.get_name() == "Lettuce" or x.get_name() == "Tomato" or x.get_name() == "Onion" or x.get_name() == "Pickle" or x.get_name() == "Ketchup" or x.get_name() == "Mayo":
is_topping = True
if is_bun == True and is_patty == True and is_topping == True:
ai_card_combo, hand, deck = ai_combo(hand, deck)
hand, deck = add_cards(hand, deck)
return ai_card_combo, hand, deck
else:
ai_card, hand, deck = ai_single(hand, deck)
hand, deck = add_cards(hand, deck)
return ai_card, hand, deck
#####################Single########################
def ai_single(hand, deck):
test_card = cards.card("null", 0)
current_largest = test_card
for x in hand:
if x.get_value() > current_largest.get_value() and x.get_name() != "Mayo" and x.get_name() != "Ketchup" and x.get_name() != "Laxative" and x.get_name() != "Exercise":
current_largest = x;
if current_largest.get_name() == "null":
hand.remove(hand[0])
ai_card = cards.card("Patty", 1)
else:
hand.remove(current_largest)
ai_card = current_largest
hand, deck = add_cards(hand, deck)
ai_card_choice = []
ai_card_choice.append(ai_card.get_name().lower())
return ai_card_choice, hand, deck
def ai_combo(hand, deck):
choices = []
for x in hand:
if x.get_name() == "Bun":
choices.append(x)
break
for x in hand:
if x.get_name() == "Patty":
choices.append(x)
break
for x in hand:
if x.get_name() == "Lettuce" or x.get_name() == "Tomato" or x.get_name() == "Onion" or x.get_name() == "Pickle" or x.get_name() == "Ketchup" or x.get_name() == "Mayo":
choices.append(x)
break
for x in hand:
if x.get_name() == "Bun":
hand.remove(x)
break
for x in hand:
if x.get_name() == "Patty":
hand.remove(x)
break
for x in hand:
if x.get_name() == "Lettuce" or x.get_name() == "Tomato" or x.get_name() == "Onion" or x.get_name() == "Pickle" or x.get_name() == "Ketchup" or x.get_name() == "Mayo":
hand.remove(x)
break
hand, deck = add_cards(hand, deck)
ai_card_combo = []
for x in choices:
ai_card_combo.append(x.get_name().lower())
return ai_card_combo, hand, deck