def render_state(s, year, Legal_immi, Illegal_immi): # Note that font creation is only allowed after the Tk root has been # defined. So we check here if the font creation is still needed, # and we do it (the first time this method is called). infos = [s.pp, s.stability, s.gov_support, s.money, s.citizen_approval] the_state_array = state_array() the_state_array.show(infos, year, Legal_immi, Illegal_immi) the_state_array.progress_bar(year)
def render_state(s): # Note that font creation is only allowed after the Tk root has been # defined. So we check here if the font creation is still needed, # and we do it (the first time this method is called). global myFont if not myFont: myFont = font.Font(family="Helvetica", size=18, weight="bold") print("In render_state, state is " + str(s)) # Create the default array of colors tan = (200, 190, 128) blue = (100, 100, 255) brown = (100, 80, 0) purple = (128, 0, 192) cyan = (100, 200, 200) row = [tan] * 3 + [blue] * 2 + [tan] * 3 the_color_array = [row, row[:]] # Now create the default array of string labels. row = ['' for i in range(8)] the_string_array = [row, row[:]] # Adjust colors and strings to match the state. mright = s.n_missionaries_on_right mleft = 3 - mright for i in range(mleft): the_color_array[0][i] = purple the_string_array[0][i] = 'M' for i in range(mright): the_color_array[0][i + 5] = purple the_string_array[0][i + 5] = 'M' cright = s.n_cannibals_on_right cleft = 3 - cright for i in range(cleft): the_color_array[1][i] = cyan the_string_array[1][i] = 'C' for i in range(cright): the_color_array[1][i + 5] = cyan the_string_array[1][i + 5] = 'C' if s.n_boats_on_right == 0: the_color_array[1][3] = brown the_string_array[1][3] = 'B' else: the_color_array[1][4] = brown the_string_array[1][4] = 'B' caption = "Current state of the puzzle. Textual version: " + str(s) the_state_array = state_array(color_array=the_color_array, string_array=the_string_array, text_font=myFont, caption=caption) #print("the_state_array is: "+str(the_state_array)) the_state_array.show()
def render_state(s): # Note that font creation is only allowed after the Tk root has been # defined. So we check here if the font creation is still needed, # and we do it (the first time this method is called). if PROBLEM1.year <= 2032.5: PROBLEM1.year += 0.5 infos = [s.pp, s.stability, s.gov_support, s.money, s.citizen_approval] the_state_array = state_array() the_state_array.show(infos, PROBLEM1.year, PROBLEM1.Legal_immi, PROBLEM1.Illegal_immi) the_state_array.progress_bar(PROBLEM1.year) if PROBLEM1.year == 2023 or PROBLEM1.year == 2028 or PROBLEM1.year == 2033: make_modal_window(infos)
def render_state(s): s = describe_state(s) # Note that font creation is only allowed after the Tk root has been # defined. So we check here if the font creation is still needed, # and we do it (the first time this method is called). global myFont if not myFont: myFont = font.Font(family="Helvetica", size=18, weight="bold") print("In render_state, state is\n" + str(s)) print() # Create the default array of colors white = (255, 255, 255) yellow = (255, 255, 0) red = (255, 0, 0) orange = (255, 128, 0) green = (0, 255, 0) blue = (0, 0, 255) gray = (128, 128, 128) #background #Now create the default array of string labels row = [gray] * 12 the_color_array = [ row, row[:], row[:], row[:], row[:], row[:], row[:], row[:], row[:] ] #Adjust colors and strings to match the state for row in range(0, 9): for column in range(0, 12): if s[row][column] == 0: the_color_array[row][column] = red elif s[row][column] == 1: the_color_array[row][column] = green elif s[row][column] == 2: the_color_array[row][column] = orange elif s[row][column] == 3: the_color_array[row][column] = blue elif s[row][column] == 4: the_color_array[row][column] = white elif s[row][column] == 5: the_color_array[row][column] = yellow else: the_color_array[row][column] = gray the_state_array = state_array(color_array=the_color_array) the_state_array.show()
def render_state(s): # Note that font creation is only allowed after the Tk root has been # defined. So we check here if the font creation is still needed, # and we do it (the first time this method is called). global myFont if not myFont: myFont = font.Font(family="Helvetica", size=18, weight="bold") print("In render_state, state is "+str(s)) # Create the default array of colors global the_color_array global the_string_array if not the_color_array: row = [background for i in range(12)] the_color_array = [row[:] for i in range(15)] # Now create the default array of string labels. if not the_string_array: row = ['' for i in range(12)] the_string_array = [row[:] for i in range(15)] sides=[0,4,2,5] the_color_array[1][6]=orange the_color_array[1][7]=orange the_string_array[1][6]="Sides" for i in range(4): display_cube(s.cubes[i],the_color_array,the_string_array,(2,1+i*4)) the_color_array[2][6+i]=black the_string_array[2][6+i]=str(sides[i]) for j in range(4): the_color_array[3+j][6+i]=cube_colors[s.cubes[j].faces[i]] # Adjust colors and strings to match the state. caption="Current state of the puzzle. Textual version: "+str(s) the_state_array = state_array(color_array=the_color_array, string_array=the_string_array, text_font=myFont, caption=caption) #print("the_state_array is: "+str(the_state_array)) the_state_array.show()
def render_state(s): # Note that font creation is only allowed after the Tk root has been # defined. So we check here if the font creation is still needed, # and we do it (the first time this method is called). global myFont if not myFont: myFont = font.Font(family="Helvetica", size=18, weight="bold") print("In render_state, state is " + str(s)) # Create the default array of colors white = (255, 255, 255) red = (255, 0, 0) blue = (100, 100, 255) row = [white] * 3 the_color_array = [row, row[:], row[:]] # Now create the default array of string labels. row = ['' for i in range(3)] the_string_array = [row, row[:], row[:]] for i in range(len(s.map)): for j in range(len(s.map[i])): if (s.map[i][j] == 1): the_color_array[i][j] = red the_string_array[i][j] = 'X' elif (s.map[i][j] == 2): the_color_array[i][j] = blue the_string_array[i][j] = 'O' else: the_color_array[i][j] = white caption = "Current state of the game. Textual version: " + str(s) the_state_array = state_array(color_array=the_color_array, string_array=the_string_array, text_font=myFont, caption=caption) # print("the_state_array is: "+str(the_state_array)) the_state_array.show()
def render_state(s): # Note that font creation is only allowed after the Tk root has been # defined. So we check here if the font creation is still needed, # and we do it (the first time this method is called). global myFont if not myFont: myFont = font.Font(family="Helvetica", size=28, weight="bold") print("In render_state, state is "+str(s)) # Create the default array of colors tan = (126,115,95) blue = (0,120,215) brown = (100, 80, 0) purple = (177,70,194) cyan = (100, 200, 200) orange=(247, 99, 12) yellow=(255,185,0) black=(76,74,72) red=(232,17,35) row = [tan]*2 + [blue]*4 + [tan]*2 the_color_array = [row, row[:],row[:]] # Now create the default array of string labels. row = ['' for i in range(8)] the_string_array = [row, row[:],row[:]] # Adjust colors and strings to match the state. if s.boat_on_right: the_color_array[0][5]=brown the_string_array[0][5]="Boat" the_color_array[0][7]=yellow the_string_array[0][7]="Farmer" else: the_color_array[0][2]=brown the_string_array[0][2]="Boat" the_color_array[0][1]=yellow the_string_array[0][1]="Farmer" if s.fox_on_right: the_color_array[0][7]=orange the_string_array[0][7]="Fox" else: the_color_array[0][0]=orange the_string_array[0][0]="Fox" if s.chicken_on_right: the_color_array[1][7]=red the_string_array[1][7]="Chicken" else: the_color_array[1][0]=red the_string_array[1][0]="Chicken" if s.grain_on_right: the_color_array[2][7]=purple the_string_array[2][7]="Grain" else: the_color_array[2][0]=purple the_string_array[2][0]="Grain" caption="Current state of the puzzle. Textual version: "+str(s) the_state_array = state_array(color_array=the_color_array, string_array=the_string_array, text_font=myFont, caption=caption) #print("the_state_array is: "+str(the_state_array)) the_state_array.show()