def create_empty_board(res: int, wBlocks: int, hBlocks: int) -> Tuple[Cimpl.Image, List[list]]:
    '''Returns an empty grid (board) as well as a list of all starting states 
    (dead).
    '''
    width, height = real_coords(res, wBlocks, hBlocks)    
    
    emptyBoard = Cimpl.create_image(width, height, Cimpl.Color(255,255,255))
    
    for pixel in emptyBoard:
        x, y = pixel[0], pixel[1]
        if x % res == 0 or y % res == 0:
            Cimpl.set_color(emptyBoard, x, y, Cimpl.Color(170,170,170))
    
    totalStateList = []
    
    for y in range(hBlocks):
        xStateList = []
        
        for x in range(wBlocks):
            xStateList += [0]
            
        totalStateList += [xStateList]
    
    return emptyBoard, totalStateList
예제 #2
0
testfile = Cimpl.load_image(
    input(
        "Input filename of image to be passed through FUNCTION green_channel: "
    ))
print("DISPLAYING TEST IMAGE: ")
Cimpl.show(testfile)

print("PASSING TEST IMAGE INTO function green_channel: ")
outcome = green_channel(testfile)
print("DISPLAYING OUTCOME: ")
Cimpl.show(outcome)
print("COMPARING EXPECTED AND OUTCOME")
#check_equal(expected, outcome)

# These are the test functions
print("---TESTING green_channel FUNCTION QUANTITATIVELY---")
white = Cimpl.create_image(50, 50)
print("DISPLAYING WHITE IMAGE: ")
Cimpl.show(white)

green = Cimpl.create_image(50, 50, Cimpl.create_color(0, 255, 0))
print("DISPLAYING EXPECTED GREEN IMAGE: ")
Cimpl.show(green)

print("PASSING WHITE IMAGE INTO green_channel")
filtered_white = green_channel(white)
print("DISPLAYING FILTERED WHITE IMAGE")
Cimpl.show(filtered_white)
print("COMPARING FILTERED WHITE IMAGE (outcome) AND GREEN IMAGE (expected)")
check_equal(green, filtered_white)
testfile = Cimpl.load_image(
    input(
        "Input filename of image to be passed through FUNCTION blue_channel: ")
)
print("DISPLAYING TEST IMAGE: ")
Cimpl.show(testfile)

print("PASSING TEST IMAGE INTO function blue_channel: ")
outcome = blue_channel(testfile)
print("DISPLAYING OUTCOME: ")
Cimpl.show(outcome)
print("COMPARING EXPECTED AND OUTCOME")
#check_equal(expected, outcome)

# These are the test functions
print("---TESTING blue_channel FUNCTION QUANTITATIVELY---")
white = Cimpl.create_image(50, 50)
print("DISPLAYING WHITE IMAGE: ")
Cimpl.show(white)

blue = Cimpl.create_image(50, 50, Cimpl.create_color(0, 0, 255))
print("DISPLAYING EXPECTED BLUE IMAGE: ")
Cimpl.show(blue)

print("PASSING WHITE IMAGE INTO red_channel")
filtered_white = blue_channel(white)
print("DISPLAYING FILTERED WHITE IMAGE")
Cimpl.show(filtered_white)
print("COMPARING FILTERED WHITE IMAGE (outcome) AND BLUE IMAGE (expected)")
check_equal(blue, filtered_white)
testfile = Cimpl.load_image(
    input(
        "Input filename of image to be passed (AN UNCOLORED IMAGE) through FUNCTION red_channel: "
    ))
print("DISPLAYING TEST IMAGE: ")
Cimpl.show(testfile)

print("PASSING TEST IMAGE INTO function red_channel: ")
outcome = red_channel(testfile)
print("DISPLAYING OUTCOME: ")
Cimpl.show(outcome)

print("---VISUAL TEST COMPLETE---")

# These are the test functions
print("---TESTING red_channel FUNCTION QUANTITATIVELY---")
white = Cimpl.create_image(50, 50)
print("DISPLAYING WHITE IMAGE: ")
Cimpl.show(white)

red = Cimpl.create_image(50, 50, Cimpl.create_color(255, 0, 0))
print("DISPLAYING EXPECTED RED IMAGE: ")
Cimpl.show(red)

print("PASSING WHITE IMAGE INTO red_channel")
filtered_white = red_channel(white)
print("DISPLAYING FILTERED WHITE IMAGE")
Cimpl.show(filtered_white)
print("COMPARING FILTERED WHITE IMAGE (outcome) AND RED IMAGE (expected)")
check_equal(red, filtered_white)
예제 #5
0
print("DISPLAYING RED IMAGE")
Cimpl.show(red)
green = Cimpl.load_image(input("Input green image filename: "))
print("DISPLAYING GREEN IMAGE")
Cimpl.show(green)
blue = Cimpl.load_image(input("Select blue image filename: "))
print("DISPLAYING BLUE IMAGE")
Cimpl.show(blue)

print("COMBINING IMAGES")
outcome = combine(red, green, blue)

print("DISPLAYING combine() function OUTCOME IMAGE:")
Cimpl.show(outcome)
#print("COMPARING OUTCOME AND EXPECTED: ")
#check_equal(expected, outcome)

# These are the tests
print("\n---TESTING function combine() QUANTITATIVELY---")
expected = Cimpl.create_image(50, 50)

red = Cimpl.create_image(50, 50, Cimpl.create_color(255, 0, 0))
green = Cimpl.create_image(50, 50, Cimpl.create_color(0, 255, 0))
blue = Cimpl.create_image(50, 50, Cimpl.create_color(0, 0, 255))

outcome = combine(red, green, blue)
print("DISPLAYING combine FUNCTION OUTCOME")
Cimpl.show(outcome)
print("COMPARING EXPECTED AND OUTCOME")
check_equal(expected, outcome)