-
Notifications
You must be signed in to change notification settings - Fork 0
/
arena.py
56 lines (46 loc) · 1.62 KB
/
arena.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
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
# Import the auctioneer, to run your auctions
from auctioneer import Auctioneer
# Import some bots to play with
# We have given you some basic bots to start with in the bots folder
# You can also add your own bots to test against
from bots import flat_bot_10
from bots import random_bot
from bots import u1234321
def run_basic_auction():
"""
An example function that runs a basic auction with 3 bots
"""
# Setup a room of bots to play against each other, imported above from the bots folder
room = [u1234321, flat_bot_10, random_bot]
# Set the game type between "value" or "collection"
game_type = "collection"
# Setup the auction
my_auction = Auctioneer(room=room, game_type=game_type)
# Play the auction
my_auction.run_auction()
def run_lots_of_auctions():
"""
An example if you want to run alot of auctions at once
"""
# A large room with a few bots of the same type
room = [random_bot, random_bot, random_bot, u1234321]
# Set the game type between "value" or "collection"
game_type = "value"
win_count = 0
run_count = 50
for i in range(run_count):
# Setup the auction
# slowdown = 0 makes it fast
my_auction = Auctioneer(room=room, game_type=game_type, slowdown=0)
# run_auction() returns a list of winners, sometimes there are more than one winner if there is a tie
winners = my_auction.run_auction()
# Check if the bot's name, "my_bot", was a winner
if "1234321" in winners:
win_count +=1
print("My bot won {} of {} games".format(win_count, run_count))
if __name__=="__main__":
run_lots_of_auctions()