Exemplo n.º 1
0
 def _init_bank(self):
     """
     Init bank
     """
     if self._game_setting["is_limited"] is True:
         self._epic_bank = bank.Bank(
             '99', 'EpicBank', self._bank_data['data']['house_number'],
             self._bank_data['data']['hotel_number'])
     else:
         self._epic_bank = bank.Bank('99', 'EpicBank', 99, 99)
Exemplo n.º 2
0
    def test_id_increments(self):
        sample_bank = b.Bank()
        cust = c.Customer(sample_bank)
        departure1 = e.CustomerDepartureEvent(1, cust)
        departure2 = e.CustomerDepartureEvent(1, cust)

        assert departure2.get_id() == departure1.get_id() + 1
Exemplo n.º 3
0
    def test_id_increments(self):
        sample_bank = b.Bank()
        cust = c.Customer(sample_bank)
        arrival1 = e.CustomerArrivalEvent(1, cust)
        arrival2 = e.CustomerArrivalEvent(1, cust)

        assert arrival2.get_id() == arrival1.get_id() + 1
Exemplo n.º 4
0
 def start(self):
     rank1 = all_rank_1_cards()
     rank2 = all_rank_2_cards()
     rank3 = all_rank_3_cards()
     rank4 = all_noble_cards()
     self.board = board.Board(
         rank1, rank2, rank3, rank4, bank.Bank(5, 5, 5, 5, 5))
Exemplo n.º 5
0
    def get_bank(self):
        """
        Create a bank and subtract from its reserves the cash allotted to players.
        """

        self.bank = bank.Bank()
        self.bank.cash -= self.players_remaining * 1500
Exemplo n.º 6
0
def main():

    my_account = bank.Bank(1500)
    print('Init balance: ', my_account.get_balance())
    my_account.deposit(500)
    print('balance: ', my_account.get_balance())
    print(my_account)
Exemplo n.º 7
0
    def test_two_customers_two_turns_of_service(self):
        bank = b.Bank()
        bank.hire_tellers(1)
        bank.customers_arrive(2, 2)

        # First customer gets 2 turns of service
        bank.simulate_tick()
        bank.simulate_tick()
        # Second gets 2 turns of service
        bank.simulate_tick()
        bank.simulate_tick()

        # Should have six events now
        # Two arrivals, a service, a departure, a service, and a departure

        event_list = bank.get_event_record().get_event_list()

        assert type(event_list[0]) == e.CustomerArrivalEvent
        assert type(event_list[1]) == e.CustomerArrivalEvent
        assert type(event_list[2]) == e.CustomerServiceEvent
        assert type(event_list[3]) == e.CustomerDepartureEvent
        assert type(event_list[4]) == e.CustomerServiceEvent
        assert type(event_list[5]) == e.CustomerDepartureEvent

        # Now check the departures
        assert event_list[3].get_wait_time() == 0
        assert event_list[3].get_total_time() == 2

        assert event_list[5].get_wait_time() == 2
        assert event_list[5].get_total_time() == 4
Exemplo n.º 8
0
    def __init__(self,
                 rank_1_deck=None,
                 rank_2_deck=None,
                 rank_3_deck=None,
                 noble_deck=None,
                 game_bank=None):
        if rank_1_deck is None:
            self.rank_1_deck = deck.Deck(None)
        else:
            self.rank_1_deck = deck.Deck(rank_1_deck)

        if rank_2_deck is None:
            self.rank_2_deck = deck.Deck(None)
        else:
            self.rank_2_deck = deck.Deck(rank_2_deck)

        if rank_3_deck is None:
            self.rank_3_deck = deck.Deck(None)
        else:
            self.rank_3_deck = deck.Deck(rank_3_deck)

        if noble_deck is None:
            self.noble_deck = deck.Deck(None)
        else:
            self.noble_deck = deck.Deck(noble_deck)

        if game_bank is None:
            self.bank = bank.Bank(0, 0, 0, 0, 0)
        else:
            self.bank = game_bank

        self.rank_1_cards_deployed = []
        self.rank_2_cards_deployed = []
        self.rank_3_cards_deployed = []
        self.noble_cards_deployed = []
Exemplo n.º 9
0
    def test_ten_turns_ten_tellers(self):
        bank = b.Bank()
        bank.hire_tellers(10)

        for i in range(10):
            bank.customers_arrive(10, 1)
            bank.simulate_tick()

        while bank.are_customers_in_bank():
            bank.simulate_tick()

        events = bank.get_event_record()

        # Ensure 300 events are in system
        # There are 100 customers, each of whom generates 3 events
        assert len(events.get_event_list()) == 300

        # And ensure that the last event occurs in the 10th tick
        assert events.get_event_list()[-1].get_time() == 10

        # And also check that every customer waits 0 turns
        departures = events.filter_by_type(
            e.CustomerDepartureEvent).get_event_list()
        
        wait_times = [event.get_wait_time() for event in departures]
        assert wait_times.count(0) == 100

        # And check that every one of them is in the bank for 1 turn
        total_times = [event.get_total_time() for event in departures]
        assert total_times.count(1) == 100
Exemplo n.º 10
0
    def test_id_increments(self):
        sample_bank = b.Bank()
        cust = c.Customer(sample_bank)
        tell = t.Teller()
        service1 = e.CustomerServiceEvent(1, cust, tell)
        service2 = e.CustomerServiceEvent(1, cust, tell)

        assert service2.get_id() == service1.get_id() + 1
Exemplo n.º 11
0
    def test_teller_event_published(self):
        sample_bank = b.Bank()
        cust = c.Customer(sample_bank)
        sample_teller = t.Teller()
        sample_bank.save_event = MagicMock()
        cust.go_to_teller(sample_teller)

        assert sample_bank.save_event.called
Exemplo n.º 12
0
 def test_longer_service_time_false(self):
     sample_bank = b.Bank()
     sample_bank.get_time = MagicMock(return_value=1)
     cust = c.Customer(sample_bank, 2)
     sample_teller = t.Teller()
     sample_bank.get_time = MagicMock(return_value=2)
     cust.go_to_teller(sample_teller)
     assert ~cust.accept_teller_service()
Exemplo n.º 13
0
    def test_one_cust_no_turns(self):
        bank = b.Bank()
        bank.hire_tellers(1)
        bank.customers_arrive(1)

        bank.simulate_tick()

        assert m.get_average_wait_time(bank) == 0
Exemplo n.º 14
0
    def test_time_reached_teller(self):
        sample_bank = b.Bank()
        cust = c.Customer(sample_bank)

        sample_teller = t.Teller()
        sample_bank.get_time = MagicMock(return_value=2)
        cust.go_to_teller(sample_teller)

        assert cust.get_time_reached_teller() == 2
Exemplo n.º 15
0
    def test_service_customer_with_two_turns_once(self):
        sample_teller = t.Teller()
        sample_bank = b.Bank()
        sample_cust = c.Customer(sample_bank, 2)

        sample_teller.take_customer(sample_cust)
        sample_teller.work_one_turn()

        assert sample_teller.has_customer()
Exemplo n.º 16
0
    def test_take_two_customers(self):
        sample_teller = t.Teller()
        sample_bank = b.Bank()

        sample_cust1 = c.Customer(sample_bank)
        sample_cust2 = c.Customer(sample_bank)

        sample_teller.take_customer(sample_cust1)
        with pytest.raises(Exception) as exception_info:
            sample_teller.take_customer(sample_cust2)
Exemplo n.º 17
0
    def test_take_customer(self):
        sample_teller = t.Teller()
        sample_bank = b.Bank()
        sample_cust = c.Customer(sample_bank)

        sample_cust.go_to_teller = MagicMock(return_value=1)

        sample_teller.take_customer(sample_cust)

        assert sample_cust.go_to_teller.called
Exemplo n.º 18
0
    def test_total_time(self):
        sample_bank = b.Bank()
        sample_bank.get_time = MagicMock(return_value=1)
        cust = c.Customer(sample_bank)

        sample_teller = t.Teller()
        sample_bank.get_time = MagicMock(return_value=2)
        cust.go_to_teller(sample_teller)

        cust.accept_teller_service()
        assert cust.get_total_time() == 2
Exemplo n.º 19
0
    def test_filter_by_type_returns_none(self):
        bank = b.Bank()
        cust = c.Customer(bank)

        e1 = e.CustomerArrivalEvent(1, cust)
        e2 = e.CustomerArrivalEvent(1, cust)
        e_list = [e1, e2]

        rec = er.EventRecord(e_list)

        filtered_rec = rec.filter_by_type(e.CustomerServiceEvent)
        assert filtered_rec.get_event_list() == []
Exemplo n.º 20
0
    def test_filter_by_type_with_mixed_events(self):
        bank = b.Bank()
        cust = c.Customer(bank)

        e1 = e.CustomerArrivalEvent(1, cust)
        e2 = e.CustomerArrivalEvent(1, cust)
        e3 = e.CustomerDepartureEvent(3, cust)
        e_list = [e1, e2, e3]

        rec = er.EventRecord(e_list)

        filtered_rec = rec.filter_by_type(e.CustomerArrivalEvent)
        assert filtered_rec.get_event_list() == [e1, e2]
Exemplo n.º 21
0
 def __init__(self):
     self.num_of_player = 0
     self.players_details = {}
     self.bank = bank.Bank()
     self.remainning_players = None
     self.board = []
     self.players = None
     self.remainning_players_list = []
     self.timer = datetime.datetime.now() + datetime.timedelta(
         hours=config.set_time_limit)  # set timer
     self.no_of_houses = 32
     self.no_of_hotels = 12
     self.monopoly_property_dict = {}
     self.board_df = pd.read_csv('board.csv')  # read board file
Exemplo n.º 22
0
 def test_bank_withdraw_too_much(self):
     b = bank.Bank(7, 7, 8, 7, 7)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     b.withdraw_one_coin(yildor.emerald)
     self.assertTrue(b.balance(yildor.emerald) == 0)
Exemplo n.º 23
0
    def test_one_customer(self):
        bank = b.Bank()
        bank.hire_tellers(1)
        bank.customers_arrive(1, 1)

        bank.simulate_tick()

        event_list = bank.get_event_record().get_event_list()

        # Check that all 3 events for the one customer are recorded in order
        assert type(event_list[0]) == e.CustomerArrivalEvent
        assert type(event_list[1]) == e.CustomerServiceEvent
        assert type(event_list[2]) == e.CustomerDepartureEvent

        # Check that the date for the departure event is accurate
        assert event_list[2].get_wait_time() == 0
        assert event_list[2].get_total_time() == 1
Exemplo n.º 24
0
    def test_ten_turns_one_teller(self):
        bank = b.Bank()
        bank.hire_tellers(1)

        for i in range(10):
            bank.customers_arrive(10, 1)
            bank.simulate_tick()

        while bank.are_customers_in_bank():
            bank.simulate_tick()

        events = bank.get_event_record()

        # Ensure 300 events are in system
        # There are 100 customers, each of whom generates 3 events
        assert len(events.get_event_list()) == 300

        # And ensure that the last event occurs in the 100th tick
        assert events.get_event_list()[-1].get_time() == 100
Exemplo n.º 25
0
def atm():
    user_balance = int(input('What is your balance: $'))
    b = bank.Bank()
    b.set_balance(user_balance)
    user_deposit = input('Would you like to deposit? ')
    if user_deposit == 'Yes' or user_deposit == 'yes':
        deposit_amount = int(input('How much would you like to deposit: $'))
        print(b.deposit(deposit_amount))
    else:
        print('Okay')
    user_withdrawl = input('Would you like to withdraw? ')
    if user_withdrawl == 'Yes' or user_withdrawl == 'yes':
        withdrawl_amount = int(input('How much would you like to withdraw: $'))
        print(b.withdraw(withdrawl_amount))
    else:
        print('okay')
    transfer_ans = input('Would you like to do a tansfer? ')
    if transfer_ans == 'Yes' or transfer_ans == 'yes':
        trans_amount = int(input('How much would you like to transfer: $'))
        print(b.set_savings(savings))
    else:
        print('Okay, Have a great day!')
Exemplo n.º 26
0
def main():
    """Runs the bank :)"""
    bankie = bank.Bank()  # creates a bank
    connect_db()  # connecting (creating) a database 'card'
    while True:
        global flag
        flag = False
        display_menu(bankie)
        choice = input()
        if choice == '0':
            break
        if choice == '1':
            create_client(bankie)
            continue
        elif choice == '2':
            print()
            successful = bank.Bank.log_in(bankie)
            if not successful:
                print('\nWrong card number or PIN!\n')
            else:
                print('\nYou have successfully logged in!\n')
                while True:
                    display_menu(bankie)
                    option = input()
                    if option == '1':
                        display_balance(bankie)
                        continue
                    if option == '2':
                        bank.Bank.log_out(bankie)
                        print('\nYou have successfully logged out!\n')
                        break
                    if option == '0':
                        flag = True
                        break
            if flag:
                break

    print('\nBye!')
Exemplo n.º 27
0
def main():
    """Simulates banks and then produces a graph of wait times"""
    NUM_OF_BANKS = 10

    # Create 10 banks in a list
    banks = [b.Bank() for i in range(NUM_OF_BANKS)]

    # Now hire tellers
    # For each number 1 to 10, get a bank and hire that many tellers
    for i in range(NUM_OF_BANKS):
        banks[i].hire_tellers(i + 1)

    # The next step is to send 10 customers to each bank per turn
    # while simulating, for 10 turns
    # Each customer has a service time of 1
    for i in range(10):
        for bank in banks:
            bank.customers_arrive(10, 1)
            bank.simulate_tick()

    # Simulate ticks for each bank until the bank runs out of customers
    for bank in banks:
        while bank.are_customers_in_bank():
            bank.simulate_tick()

    average_wait_times = [get_average_wait_time(bank) for bank in banks]

    print(average_wait_times)

    plt.plot(range(1, 11), average_wait_times, 'ro')
    plt.title(
        "Dependence of customer wait time on the number of tellers at a bank")
    plt.xlabel("Number of tellers")
    plt.ylabel("Average wait time")
    plt.axis([0, 11, 0, 50])
    plt.show()
Exemplo n.º 28
0
def main():
    bank = np.array([[2, 0, 0, 0, 0, 2], [0, 0, 0, 0, 0, 0],
                     [2, 0, 0, 0, 0, 2]])
    # Environment setup
    env = bk.Bank(bank)
    values = np.zeros((20, 1))
    gamma = 0.1
    epsilon = 0.0001

    # Compute the value function for different gamma and plot them.
    for index, gamma in enumerate(np.linspace(0.01, 0.99, 20)):
        V, _ = bk.value_iteration(env, gamma, epsilon)
        values[index] = V[env.map[(0, 0, 1, 2)]]
    plt.plot(np.linspace(0.01, 0.99, 20), values)
    plt.xlabel("Gamma")
    plt.ylabel("Expected reward")
    plt.title("Value function at initial state as a function of gamma")
    plt.show()

    # Illustrate the different policies for small and large discount factors.
    _, policy = bk.value_iteration(env, 0.01, epsilon)
    bk.illustrate_policy(env, policy, 0.01)
    _, policy = bk.value_iteration(env, 0.99, epsilon)
    bk.illustrate_policy(env, policy, 0.99)
Exemplo n.º 29
0
import bank
import mailbox
from uwldap import getUser
import pickle
import comms

imap_username = '******'
imap_password = '******'

#Our mailbox for receiving addresses
mbox = mailbox.MailBox(imap_username, imap_password)

#watcoind
bnk = bank.Bank()
bnk.ensureServer()

#load users from database

users= pickle.load(open( "users.pic", "rb" ) )

#Each user is a dictionary:
# bank - the account name. Same as quest.
# quest - The quest ID
# name - Real name
# sendTo - BTC address to send coins to.
#serial responder:
sr = comms.SerialResponder(bnk,users)


Exemplo n.º 30
0
 def _init_bank(self):
     self._epic_bank = bank.Bank('99', 'EpicBank',
                                 self._bank_data['data']['house_number'],
                                 self._bank_data['data']['hotel_number'])