def init_chip(self): print("inside init chip") data_file = utils.load_bin_file(self.data_file) inst_file = utils.load_bin_file(self.inst_file) config_file = utils.load_bin_file(self.config_file) cpu = CPU(config_file, self.clk_mgr) self.chip = Chip(cpu, inst_file, data_file) cpu.set_chip(self.chip) cpu.load_config(config_file)
def start_game(playing): while True: print('WELCOME TO BLACKJACK') deck = Deck(suits, ranks) deck.shuffle() player_hand = Hand(values) player_hand.add_card(deck.deal()) player_hand.add_card(deck.deal()) dealer_hand = Hand(values) dealer_hand.add_card(deck.deal()) dealer_hand.add_card(deck.deal()) player_chips = Chip() player_chips.take_bet() player = Player(player_hand, dealer_hand, player_chips.bet) player.show_some() while playing: player.hit_or_stand(deck, player_hand) player.show_some() if player_hand.value > 21: player.player_busts(player_chips) if player_hand.value <= 21: while dealer_hand.value < player_hand.value: player.dealer_hit(deck) player.show_all() if dealer_hand.value > 21: player.dealer_busts(player_chips) elif dealer_hand.value > player_hand.value: player.dealer_wins(player_chips) elif dealer_hand.value < player_hand.value: player.player_wins(player_chips) else: player.push() print('\nPlayer total chips are at: {}'.format(player_chips.total)) new_game = input('Would you like to play another game?(y/n) ') if new_game.lower() == 'y': playing = True continue else: print('You brings {} chips'.format(player_chips.total)) break break
def _startChips(self): for _ in range(2): self._chipQueueIn.append(queue.Queue()) self._chips.append( Chip(0, self._chipLock, self._chipQueueIn[0], self._chipQueueOut, self._l2queue1, self._l2queue2, self._guiQueues[1:6], self._mainwin)) self._chips.append( Chip(1, self._chipLock, self._chipQueueIn[1], self._chipQueueOut, self._l2queue2, self._l2queue1, self._guiQueues[6:11], self._mainwin)) self._chips[0].start() self._chips[1].start()
def make_move(self, col_number): '''stores the chips into the proper position of the board''' #Creating a counter value that counts number of chips in the specified column not_full = 0 #Going through the column, in order to check each cell value for i in range(len(self.board_list[0].column_list) - 1, -1, -1): #Checking if the certain position is empty if self.board_list[col_number].column_list[i].hold == None: #If the position is empty, drop the chip into that position self.board_list[col_number].column_list[i].hold = Chip( str(self.chip_color)) #Once this is done, break out of the for loop break #When if statement passes, moving onto else statement else: #Adding a number to the counter value not_full to count how many chips are filled in the column not_full = not_full + 1 #Checking if the player is making invalid move, such as trying to drop the chip onto the column that is already full if not_full == 6: #Return the message to the game in order to inform the player to make different move return self.error
def initialize_chips(self): for io_channel in range(1, 5): for chip in self.uart_data['network']['1'][str( io_channel)]['nodes']: if not chip['chip_id'] == 'ext': self.chips.append( Chip(self.serial_num, 1, io_channel, chip['chip_id']))
def add_chip(self, row, col, mouse_x, mouse_y): chip = Chip(self.side, self.get_player_color(), row * self.side, col * self.side, mouse_y) self.chip_count += 1 self.chips[row][col] = chip self.is_red = not self.is_red if self.chip_count >= self.num_row * self.num_col: print("The game is over")
def populateScene(self): self.scene = QGraphicsScene() image = QImage(":/qt4logo.png") # Populate scene xx = 0 nitems = 0 for i in range(-11000, 11000, 110): xx += 1 yy = 0 for j in range(-7000, 7000, 70): yy += 1 x = (i + 11000) / 22000.0 y = (j + 7000) / 14000.0 color = QColor(image.pixel(int(image.width() * x), int(image.height() * y))) item = Chip(color, xx, yy) item.setPos(QPointF(i, j)) self.scene.addItem(item) nitems += 1
def spawn_chip(self, name): # Load list of all chips in json with open(constants.CHIPS_JSON, 'r') as file: truth_tables = json.load(file) for tt in truth_tables: if tt['name'] == name: inputs = len(utilities.string_to_bool(str(list(tt.keys())[-1]))) # Length of the list of the last key of the truth table (inputs) outputs = len(utilities.string_to_bool(str(list(tt.values())[-1]))) # Length of the list of the last value of the truth table (outputs) self.chips.append(Chip(name, random.randrange(constants.WIDTH*0.25, constants.WIDTH*0.75), random.randrange(constants.HEIGHT*0.25, constants.HEIGHT*0.75), inputs, outputs)) return
def main(): pygame.init() logo = pygame.image.load("./img/Play.png") pygame.display.set_icon(logo) pygame.display.set_caption("Emulator") screen = pygame.display.set_mode((640, 320)) running = True pixel = pygame.Surface((10, 10)) chip = Chip() while running: chip.emulate_cycle() for event in pygame.event.get(): if event.type == pygame.QUIT: running = False keys = pygame.key.get_pressed() key_pressed(chip, keys) print_pixel(screen, pixel, chip) pygame.display.update()
class Gun: def __init__(self): self.chip = Chip() self.gun_statu = GUNPUT # 装弹夹 def load_chip(self): print("弹夹安装完毕") # 射击 def shoot_bullet(self, guner, enemy): if self.chip.sub_bullet(): print("成功射击%s" % enemy.name) if self.chip.bullet.hurt_enemy(enemy): return True else: return False else: guner.put_gun() self.chip.add_bullet(random.randint(1, CHIPVOLUME)) self.load_chip() return False
def add_chip(self, row, col): if self.is_over: return chip = Chip(self.side, self.get_player_color(), row * self.side, col * self.side) self.chip_count += 1 self.chips[row][col] = chip if self.check_if_win(row, col): self.is_over = True print("Red wins" if self.is_red else "Yellow wins") self.is_red = not self.is_red return self.is_red = not self.is_red print("Computer turn" if not self.is_red else "Red please") if self.chip_count >= self.num_row * self.num_col: print("The game is over")
class App: def __init__(self): args = sys.argv #self.inst_file = args[1] #self.data_file = args[2] #self.config_file = args[3] self.inst_file = "..//tc//tc1//inst.txt" self.data_file = "..//tc//tc1//data.txt" self.config_file = "..//tc//tc1//config.txt" self.result_file = "..//tc//tc1//mine.txt" self.chip = None self.clk_mgr = ClockMgr() self.init_chip() def init_chip(self): print("inside init chip") data_file = utils.load_bin_file(self.data_file) inst_file = utils.load_bin_file(self.inst_file) config_file = utils.load_bin_file(self.config_file) cpu = CPU(config_file, self.clk_mgr) self.chip = Chip(cpu, inst_file, data_file) cpu.set_chip(self.chip) cpu.load_config(config_file) def start_cpu(self): #print("**************** before starting cpu: ", self.chip.cpu.__dict__) while True: print("-------------------") print("Running cycle number: {}".format(self.clk_mgr.get_clock())) res = self.chip.execute() self.clk_mgr.increament_clock() if res == -1: break print("-------------------\n\n")
import sys import argparse from chip import Chip import pyglet from pyglet.window import key, FPSDisplay ################################ # Pyglet functions # ################################ chip = Chip() window = pyglet.window.Window() fps_display = FPSDisplay(window) @window.event def on_draw(): window.clear() draw(chip.display_buffer) fps_display.draw() @window.event def on_key_press(symbol, modifiers): try: key_index = Chip.KEY_INPUTS[symbol] chip.key_inputs[key_index] = 1 #print(key_index, chip.key_inputs) except KeyError: pass
def __init__(self, number): self.name = input(f"Player {number}, what is your name? \n>> ") self.hand = Hand() self.chips = { 1: [Chip(1), Chip(1), Chip(1), Chip(1), Chip(1)], 5: [Chip(5), Chip(5), Chip(5), Chip(5), Chip(5)], 25: [Chip(25)] } self.bet = {1: 0, 5: 0, 25: 0}
def push(self): for chip, amt in self.bet.items(): for _ in range(amt): self.chips[chip].append(Chip(chip))
def main(): main_memory = Memory() cache_L1_00 = L1(0, 'P0') cache_L1_01 = L1(0, 'P1') cache_L1_10 = L1(1, 'P0') cache_L1_11 = L1(1, 'P1') cache_L2_0 = L2(0) cache_L2_1 = L2(1) time.sleep(5) #Invocacion para generar los chips chip0 = Chip(0, main_memory, cache_L1_00, cache_L1_01, cache_L1_10, cache_L1_11, cache_L2_0, cache_L2_1) chip1 = Chip(1, main_memory, cache_L1_00, cache_L1_01, cache_L1_10, cache_L1_11, cache_L2_0, cache_L2_1) chip0.start() chip1.start() print('Hola mainLoop') root = Tk() root.configure(bg='light cyan') root.geometry('1400x700') #Titulo de tablas #Cache L1 00 label_titulo_L100 = Label(text='L1, P0,0') label_titulo_L100.config(font=('Arial', 20)) label_titulo_L100.config(bg="light cyan") label_titulo_L100.place(x=100, y=150) #Cache L1 01 label_titulo_L101 = Label(text='L1, P1,0') label_titulo_L101.config(font=('Arial', 20)) label_titulo_L101.config(bg="light cyan") label_titulo_L101.place(x=100, y=300) #Cache L2 0 label_titulo_L101 = Label(text='L2, 0') label_titulo_L101.config(font=('Arial', 20)) label_titulo_L101.config(bg="light cyan") label_titulo_L101.place(x=100, y=450) #Cache L1 10 label_titulo_L100 = Label(text='L1, P0,1') label_titulo_L100.config(font=('Arial', 20)) label_titulo_L100.config(bg="light cyan") label_titulo_L100.place(x=1160, y=150) #Cache L1 11 label_titulo_L101 = Label(text='L1, P1,1') label_titulo_L101.config(font=('Arial', 20)) label_titulo_L101.config(bg="light cyan") label_titulo_L101.place(x=1160, y=300) #Cache L2 1 label_titulo_L101 = Label(text='L2, 1') label_titulo_L101.config(font=('Arial', 20)) label_titulo_L101.config(bg="light cyan") label_titulo_L101.place(x=1160, y=450) #Memoria label_titulo_M = Label(text='Memoria Principal') label_titulo_M.config(font=('Arial', 20)) label_titulo_M.config(bg="light cyan") label_titulo_M.place(x=570, y=100) #Tablas #Tabla para cache L1 P0 chip 0 table_L100 = Table(root, 3, 4) titles = ['#Linea', 'Estado', 'Dir Memoria', 'Dato'] table_L100.createTable(titles, 'gray', 'white', True) table_L100.place(x=80, y=200) #Tabla para cache L1 P1 chip 0 table_L101 = Table(root, 3, 4) titles = ['#Linea', 'Estado', 'Dir Memoria', 'Dato'] table_L101.createTable(titles, 'gray', 'white', True) table_L101.place(x=80, y=350) #Tabla para cache L2 chip 0 table_L20 = Table(root, 5, 5) titles = ['#Linea', 'Estado', 'Dueño', 'Dir Memoria', 'Dato'] table_L20.createTable(titles, 'gray', 'white', True) table_L20.place(x=40, y=500) #Tabla para cache L1 P0 chip 1 table_L110 = Table(root, 3, 4) titles = ['#Linea', 'Estado', 'Dir Memoria', 'Dato'] table_L110.createTable(titles, 'gray', 'white', True) table_L110.place(x=980, y=200) #Tabla para cache L1 P0 chip 1 table_L111 = Table(root, 3, 4) titles = ['#Linea', 'Estado', 'Dir Memoria', 'Dato'] table_L111.createTable(titles, 'gray', 'white', True) table_L111.place(x=980, y=350) #Tabla para cache L2 chip 0 table_L21 = Table(root, 5, 5) titles = ['#Linea', 'Estado', 'Dueño', 'Dir Memoria', 'Dato'] table_L21.createTable(titles, 'gray', 'white', True) table_L21.place(x=940, y=500) #Tabla para cache L2 chip 0 table_memory = Table(root, 17, 4) titles = ['Direccion', 'Estado', 'Dueño(s)', 'Dato'] table_memory.createTable(titles, 'gray', 'white', False) table_memory.place(x=530, y=150) #Tabla de instrucciones #Tabla para cache L2 chip 0 inst_1 = StringVar() instruction00 = Label(textvariable=inst_1, font=("Helvetica", 14), bg='light cyan') instruction00.pack() instruction00.place(x=80, y=50) inst_2 = StringVar() instruction01 = Label(textvariable=inst_2, font=("Helvetica", 14), bg='light cyan') instruction01.pack() instruction01.place(x=80, y=75) inst_3 = StringVar() instruction10 = Label(textvariable=inst_3, font=("Helvetica", 14), bg='light cyan') instruction10.pack() instruction10.place(x=1020, y=50) inst_4 = StringVar() instruction11 = Label(textvariable=inst_4, font=("Helvetica", 14), bg='light cyan') instruction11.pack() instruction11.place(x=1020, y=75) while (True): time.sleep(1) # Need this to slow the changes down inst_1.set(chip0.core0.instruction) inst_2.set(chip0.core1.instruction) inst_3.set(chip1.core0.instruction) inst_4.set(chip1.core1.instruction) #Tabla de cache L1 00 actualizada table_L100.set(1, 1, cache_L1_00.lines[0].state) table_L100.set(1, 2, cache_L1_00.lines[0].directionBin) table_L100.set(1, 3, cache_L1_00.lines[0].data) table_L100.set(2, 1, cache_L1_00.lines[1].state) table_L100.set(2, 2, cache_L1_00.lines[1].directionBin) table_L100.set(2, 3, cache_L1_00.lines[1].data) #Tabla de cache L1 01 actualizada table_L101.set(1, 1, cache_L1_01.lines[0].state) table_L101.set(1, 2, cache_L1_01.lines[0].directionBin) table_L101.set(1, 3, cache_L1_01.lines[0].data) table_L101.set(2, 1, cache_L1_01.lines[1].state) table_L101.set(2, 2, cache_L1_01.lines[1].directionBin) table_L101.set(2, 3, cache_L1_01.lines[1].data) #Tabla de cache L2 0 actualizada table_L20.set(1, 1, cache_L2_0.lines[0].state) table_L20.set(1, 2, cache_L2_0.lines[0].owner) table_L20.set(1, 3, cache_L2_0.lines[0].directionBin) table_L20.set(1, 4, cache_L2_0.lines[0].data) table_L20.set(2, 1, cache_L2_0.lines[1].state) table_L20.set(2, 2, cache_L2_0.lines[1].owner) table_L20.set(2, 3, cache_L2_0.lines[1].directionBin) table_L20.set(2, 4, cache_L2_0.lines[1].data) table_L20.set(3, 1, cache_L2_0.lines[2].state) table_L20.set(3, 2, cache_L2_0.lines[2].owner) table_L20.set(3, 3, cache_L2_0.lines[2].directionBin) table_L20.set(3, 4, cache_L2_0.lines[2].data) table_L20.set(4, 1, cache_L2_0.lines[3].state) table_L20.set(4, 2, cache_L2_0.lines[3].owner) table_L20.set(4, 3, cache_L2_0.lines[3].directionBin) table_L20.set(4, 4, cache_L2_0.lines[3].data) #Tabla de cache L1 10 actualizada table_L110.set(1, 1, cache_L1_10.lines[0].state) table_L110.set(1, 2, cache_L1_10.lines[0].directionBin) table_L110.set(1, 3, cache_L1_10.lines[0].data) table_L110.set(2, 1, cache_L1_10.lines[1].state) table_L110.set(2, 2, cache_L1_10.lines[1].directionBin) table_L110.set(2, 3, cache_L1_10.lines[1].data) #Tabla de cache L1 11 actualizada table_L111.set(1, 1, cache_L1_11.lines[0].state) table_L111.set(1, 2, cache_L1_11.lines[0].directionBin) table_L111.set(1, 3, cache_L1_11.lines[0].data) table_L111.set(2, 1, cache_L1_11.lines[1].state) table_L111.set(2, 2, cache_L1_11.lines[1].directionBin) table_L111.set(2, 3, cache_L1_11.lines[1].data) #Tabla de cache L2 1 actualizada table_L21.set(1, 1, cache_L2_1.lines[0].state) table_L21.set(1, 2, cache_L2_1.lines[0].owner) table_L21.set(1, 3, cache_L2_1.lines[0].directionBin) table_L21.set(1, 4, cache_L2_1.lines[0].data) table_L21.set(2, 1, cache_L2_1.lines[1].state) table_L21.set(2, 2, cache_L2_1.lines[1].owner) table_L21.set(2, 3, cache_L2_1.lines[1].directionBin) table_L21.set(2, 4, cache_L2_1.lines[1].data) table_L21.set(3, 1, cache_L2_1.lines[2].state) table_L21.set(3, 2, cache_L2_1.lines[2].owner) table_L21.set(3, 3, cache_L2_1.lines[2].directionBin) table_L21.set(3, 4, cache_L2_1.lines[2].data) table_L21.set(4, 1, cache_L2_1.lines[3].state) table_L21.set(4, 2, cache_L2_1.lines[3].owner) table_L21.set(4, 3, cache_L2_1.lines[3].directionBin) table_L21.set(4, 4, cache_L2_1.lines[3].data) #Tabla de memoria principal actualizada table_memory.set(1, 1, main_memory.lines[0].state) table_memory.set(1, 2, main_memory.lines[0].owner) table_memory.set(1, 3, main_memory.lines[0].data) table_memory.set(2, 1, main_memory.lines[1].state) table_memory.set(2, 2, main_memory.lines[1].owner) table_memory.set(2, 3, main_memory.lines[1].data) table_memory.set(3, 1, main_memory.lines[2].state) table_memory.set(3, 2, main_memory.lines[2].owner) table_memory.set(3, 3, main_memory.lines[2].data) table_memory.set(4, 1, main_memory.lines[3].state) table_memory.set(4, 2, main_memory.lines[3].owner) table_memory.set(4, 3, main_memory.lines[3].data) table_memory.set(5, 1, main_memory.lines[4].state) table_memory.set(5, 2, main_memory.lines[4].owner) table_memory.set(5, 3, main_memory.lines[4].data) table_memory.set(6, 1, main_memory.lines[5].state) table_memory.set(6, 2, main_memory.lines[5].owner) table_memory.set(6, 3, main_memory.lines[5].data) table_memory.set(7, 1, main_memory.lines[6].state) table_memory.set(7, 2, main_memory.lines[6].owner) table_memory.set(7, 3, main_memory.lines[6].data) table_memory.set(8, 1, main_memory.lines[7].state) table_memory.set(8, 2, main_memory.lines[7].owner) table_memory.set(8, 3, main_memory.lines[7].data) table_memory.set(9, 1, main_memory.lines[8].state) table_memory.set(9, 2, main_memory.lines[8].owner) table_memory.set(9, 3, main_memory.lines[8].data) table_memory.set(10, 1, main_memory.lines[9].state) table_memory.set(10, 2, main_memory.lines[9].owner) table_memory.set(10, 3, main_memory.lines[9].data) table_memory.set(11, 1, main_memory.lines[10].state) table_memory.set(11, 2, main_memory.lines[10].owner) table_memory.set(11, 3, main_memory.lines[10].data) table_memory.set(12, 1, main_memory.lines[11].state) table_memory.set(12, 2, main_memory.lines[11].owner) table_memory.set(12, 3, main_memory.lines[11].data) table_memory.set(13, 1, main_memory.lines[12].state) table_memory.set(13, 2, main_memory.lines[12].owner) table_memory.set(13, 3, main_memory.lines[12].data) table_memory.set(14, 1, main_memory.lines[13].state) table_memory.set(14, 2, main_memory.lines[13].owner) table_memory.set(14, 3, main_memory.lines[13].data) table_memory.set(15, 1, main_memory.lines[14].state) table_memory.set(15, 2, main_memory.lines[14].owner) table_memory.set(15, 3, main_memory.lines[14].data) table_memory.set(16, 1, main_memory.lines[15].state) table_memory.set(16, 2, main_memory.lines[15].owner) table_memory.set(16, 3, main_memory.lines[15].data) root.update_idletasks() root.update() root.mainloop()
elif cmd[0] == 'f': self.continue_to_frame() except IndexError: print("Invalid command") except KeyboardInterrupt: return def step(self): self.emu.cycle() self.emu._print_instruction() np.set_printoptions(threshold=maxsize) emu = Chip() debugger = Debugger(emu) def main(): parser = argparse.ArgumentParser() parser.add_argument('filename', help='Location of CHIP-8 ROM') args = parser.parse_args() filename = args.filename emu.load(filename) print("Debugging " + filename) print("Press 'h' to see commands") debugger.repl()
def __init__(self): self.chip = Chip() self.gun_statu = GUNPUT
import sys from Qt import QtCore, QtGui, QtWidgets from chip import Chip if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) app.setAttribute(QtCore.Qt.AA_DontCreateNativeWidgetSiblings) window = QtWidgets.QWidget() scene = QtWidgets.QGraphicsScene(window) chip = Chip(QtGui.QColor(QtCore.Qt.green), 0, 0) scene.addItem(chip) layout = QtWidgets.QGridLayout() view = QtWidgets.QGraphicsView(scene) layout.addWidget(view) window.setLayout(layout) window.show() sys.exit(app.exec_())
def __init__(self): Hand.__init__(self) self.chips = Chip() self.bet = 0 # default bet amount
help='opens up an interactive matplotlib visualization') return parser.parse_args() if __name__ == '__main__': # Parse command-line arguments argv = parse_arguments() utils.argv = argv if not (argv.chip_name in ["e5-2667v4", "phi7250", "base2", "base3"]): utils.abort("Chip '" + argv.chip_name + "' not supported") else: argv.chip = Chip(argv.chip_name, argv.power_benchmark) if (argv.num_chips < 1): utils.abort("The number of chips (--numchips, -n) should be >0") if (argv.layout_scheme == "stacked") or ( argv.layout_scheme == "rectilinear_straight") or ( argv.layout_scheme == "rectilinear_diagonal") or ( argv.layout_scheme == "linear_random_greedy") or ( argv.layout_scheme == "checkerboard") or ( argv.layout_scheme == "cradle") or (argv.layout_scheme == "bridge"): argv.diameter = argv.num_chips if (argv.diameter < 1): utils.abort("The diameter (--diameter, -d) should be >0")
class Player(Hand): def __init__(self): Hand.__init__(self) self.chips = Chip() self.bet = 0 # default bet amount def ask_for_bet(self): print(f'Player\'s current chip amount is: {self.chips.total}\n') # ask the player how much they would like to bet try: amount = int(input("How much would you like to bet?\n")) self.place_bet(amount) except: print('Whoops! Could not place your bet. Please try again') self.ask_for_bet() def place_bet(self, amount): # check to make sure the bet amount is valid if (self.chips.total >= amount and amount > 0): # set the bet and subtract the amount from the player's chip total self.bet = amount self.chips.subtract(amount) elif (self.chips.total >= amount): print( "Whoops! You can not place a bet that exceeeds your chip amount. Please place a new bet." ) self.ask_for_bet() elif (amount <= 0): print( "Whoops! You can not place a bet less than or eqal to zero. Please place a new bet." ) self.ask_for_bet() else: print( "Whoops! Something is wrong with your bet. Please place a new bet." ) self.ask_for_bet() def hit(self, deck): print('Player hits.') # take a card from the deck new_card = deck.deal() self.add_card(new_card) def hit_or_stand(self, deck): playing = True while True: # ask the player if they want to hit or stand resp = input( "\nDo you want to hit or stand? Enter 'h' or 's'").lower() # if player chose hit draw a card from the deck if (resp.startswith('h')): self.hit(deck) elif (resp.startswith('s')): print("Player stands. Dealer is playing.") playing = False else: print('Sorry, please try again.') continue break return playing def clear_hand(self): self.cards = [] self.value = 0 self.aces = 0 self.bet = 0 print('Player\'s hand was cleared.')
def __init__(self): self.hand = Hand() self.chips = { 1: [Chip(1), Chip(1), Chip(1), Chip(1), Chip(1)], 5: [Chip(5), Chip(5), Chip(5), Chip(5), Chip(5)], 25: [Chip(25)] }
def key_pressed(chip: Chip, keys): chip.keys[0x1] = int(keys[pygame.K_1]) chip.keys[0x2] = int(keys[pygame.K_2]) chip.keys[0x3] = int(keys[pygame.K_3]) chip.keys[0xC] = int(keys[pygame.K_4]) chip.keys[0x4] = int(keys[pygame.K_q]) chip.keys[0x5] = int(keys[pygame.K_w]) chip.keys[0x6] = int(keys[pygame.K_e]) chip.keys[0xD] = int(keys[pygame.K_r]) chip.keys[0x7] = int(keys[pygame.K_a]) chip.keys[0x8] = int(keys[pygame.K_s]) chip.keys[0x9] = int(keys[pygame.K_d]) chip.keys[0xE] = int(keys[pygame.K_f]) chip.keys[0xA] = int(keys[pygame.K_z]) chip.keys[0x0] = int(keys[pygame.K_x]) chip.keys[0xB] = int(keys[pygame.K_c]) chip.keys[0xF] = int(keys[pygame.K_v])
def main(): filename = sys.argv[1] if not exists(filename): raise Exception("file not found") c = Chip(read_file_byte(filename)) c.dump_ram()
while True: print("\nWelcome to BLACKJACK") deck = Deck() deck.shuffle() player_hand = Hand() player_hand.add_card(deck.deal()) player_hand.add_card(deck.deal()) dealer_hand = Hand() dealer_hand.add_card(deck.deal()) dealer_hand.add_card(deck.deal()) player_chips = Chip() take_bet(player_chips) show_some(player_hand, dealer_hand) while playing: hit_or_stand(deck, player_hand) show_some(player_hand, dealer_hand) if player_hand.value > 21: player_busts(player_hand, dealer_hand, player_chips) break if player_hand.value <= 21: while dealer_hand.value < 17: hit(deck, dealer_hand)