Beispiel #1
0
 def testCube(self):
     result = c.cube(3)
     expected = 27
     self.assertEqual(result, expected)
     self.assertEqual(
         c.cube(3), 27
     )  #these two assertEqual statements are equivalent. just different ways of writing the same test
Beispiel #2
0
def setup_game():
    global gs
    gs.update()
    gs.snacks.clear()
    gs.snake1 = snake.snake(gs, 1)
    gs.snake1.setGS(gs)

    if gs.obstacles_on:
        for _ in range(5):
            gs.obstacles.append(cube.cube(gs, random_obstacle(), color=gs.color.grey))
    gs.surface = pygame.display.set_mode((gs.width, gs.width + gs.banner_height))
    if gs.mode == "race" or gs.mode == "melee":
        gs.snake2 = snake.snake(gs, 2)
        gs.snake2.setGS(gs)
        gs.scr = score.score(gs, True)
    else:
        gs.scr = score.score(gs, False)
    if gs.mode == "melee":
        gs.snake1.grow = True
        if gs.snake2:
            gs.snake2.grow = True

    if gs.borders_on:
        for x in range(gs.rows):
            for y in range(gs.rows):
                if x == 0 or y == 0 or y == gs.rows-1 or x == gs.rows-1:
                    gs.obstacles.append(cube.cube(gs, (x,y), color=gs.color.grey))

    if gs.mode != "melee":
        for i in range(gs.fruit_count):
            gs.snacks.append(cube.cube(gs, random_snack(), color=gs.color.green))
Beispiel #3
0
def main():
    global rows, width, s, snack
    width = 500
    rows = 20
    win = pygame.display.set_mode((width, width))

    s = snake((255, 0, 0), (10, 10))
    snack = cube(randomSnack(rows, s), color=(0, 255, 0))
    flag = True

    clock = pygame.time.Clock()

    while flag:
        pygame.time.delay(50)
        clock.tick(10)
        s.move()
        if s.body[0].pos == snack.pos:
            s.addCube()
            snack = cube(randomSnack(rows, s), color=(0, 255, 0))

        for x in range(len(s.body)):
            if s.body[x].pos in list(map(lambda z: z.pos, s.body[x + 1:])):
                print('Score: ', len(s.body))
                message_box('You Lost!', 'Play again...')
                s.reset((10, 10))
                break
        redrawWindow(win)
Beispiel #4
0
def main():
    global screen_size, rows, s, snack

    screen_size = 500
    rows = 20

    win = pygame.display.set_mode((screen_size, screen_size))
    s = sn.snake((0, 255, 0), (10, 10))
    snack = cb.cube(random_Snack(rows, s), color=(255, 0, 0))

    clock = pygame.time.Clock()

    flag = True
    while flag:
        pygame.time.delay(50)
        clock.tick(10)
        s.move()

        if s.body[0].pos == snack.pos:
            s.add_Cube()
            snack = cb.cube(random_Snack(rows, s), color=(255, 0, 0))

        for x in range(len(s.body)):
            if s.body[x].pos in list(map(lambda z: z.pos, s.body[x + 1:])):
                print('Score: ', len(s.body))
                message_Box('Game Over', 'Play Again')
                s.reset((0, 255, 0), (10, 10))
                flag = False
                break

        redraw_Window(win)
Beispiel #5
0
def display():
    global globalTranslate
    global splinePoints1
    global splinePoints2
    global eye

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    loadGlobalCoord()

    glPushMatrix()
    
    glTranslatef(globalTranslate.x, globalTranslate.y, globalTranslate.z)

    drawCrossSections(splinePoints1)
    drawCatmullRomSections(splinePoints2)

    c1 = cube(xyz(-25, 10, 10), xyz(-25, 10, -10), xyz(-5, 10, -10), xyz(-5, 10, 10), xyz(-25, -10, 10), xyz(-25, -10, -10), xyz(-5, -10, -10), xyz(-5, -10, 10))
    s1 = c1.getSortedSurfaces(eye)
    drawMaterialSurfaces(s1)

    c2 = cube(xyz(5, 10, 10), xyz(5, 10, -10), xyz(25, 10, -10), xyz(25, 10, 10), xyz(5, -10, 10), xyz(5, -10, -10), xyz(25, -10, -10), xyz(25, -10, 10))
    s2 = c2.getSortedSurfaces(eye)
    drawTranslucentSurfaces(s2)
    

    glPopMatrix()

    lightOff()
    lightOn()

    glutSwapBuffers()
Beispiel #6
0
def main():
    global gs, h_scr, seconds_left
    pygame.display.set_caption("PythonPythonGame")
    
    # ***** Main Loop ***** #
    main_loop = True

    while main_loop:

        while gs.on_menu:
            menu()

        while gs.on_settings:
            settings_menu()

        if gs.playing:
            setup_game()
            if gs.mode == "race":
                timer_thread = threading.Thread(target=timer, name="Countdown")
                seconds_left = 60
                timer_thread.start()
        while gs.playing:
            redraw_window()
            if gs.snake1.move(gs):
                collision(True, 1) if gs.snake2 else collision(False, 1)
                reset_game()
                break
            if gs.snake2:
                if gs.snake2.move(gs):
                    collision(True, 2)
                    reset_game()
                    break
            for snack in gs.snacks:
                if gs.snake1.body[0].pos == snack.pos:
                    gs.snake1.addCube()
                    gs.scr.add_score(1)
                    gs.snacks.remove(snack)
                    gs.snacks.append(cube.cube(gs, random_snack(), color=gs.color.green))
                if gs.snake2 and gs.snake2.body[0].pos == snack.pos:
                    gs.snake2.addCube()
                    gs.scr.add_score(2)
                    gs.snacks.remove(snack)
                    gs.snacks.append(cube.cube(gs, random_snack(), color=gs.color.green))

            if check_collision():
                pygame.display.update()
                reset_game()
                break

            if gs.mode == "race" and seconds_left < 1:
                reset_game()
                break

            gs.clock.tick(10)
    d.close()
    pygame.quit()
    quit()
Beispiel #7
0
    def test_stringstomoves(self):
        numcube = cube()  #operations like F2,F3 tested
        ccwcube = cube()  #operations like F'
        correct = cube()  #manual rotation for checks

        #test basic string to list parsing
        teststring = "FRLFUDBF"
        moves = correct.string_to_movelist(teststring)
        for move, char in zip(moves, teststring):
            self.assertTrue(move == char)

        #this tests counter clockwise and triple rotation for all sides
        #(ccw and tripple rotation {ex F3 = F 3 times} are the same)
        for side in correct.sides:
            ccwmoves = ccwcube.string_to_movelist(side + "\'")
            nummoves = numcube.string_to_movelist(side + "3")
            ccwcube.do_moves(nummoves)
            numcube.do_moves(nummoves)
            correct.rotations[side]()  #F3 is the same as F'
            correct.rotations[side]()
            correct.rotations[side]()

            #F3 == F F F == F'
            self.assertTrue(correct == numcube)
            self.assertTrue(correct == ccwcube)

            #revert all three back to solved
            correct.rotations[side]()
            ccwcube.rotations[side]()
            numcube.rotations[side]()
            self.assertTrue(correct == self.testcube)
            self.assertTrue(correct == numcube)

        #this tests double rotations (ex. F2 is F 2 times)
        for side in correct.sides:
            moves = numcube.string_to_movelist(side + "2")
            numcube.do_moves(moves)
            correct.rotations[side]()
            correct.rotations[side]()
            self.assertTrue(correct == numcube)

            #revert both back to solved
            correct.rotations[side]()
            correct.rotations[side]()
            numcube.do_moves(moves)
            self.assertTrue(correct == numcube)
        del numcube
        del correct
        del ccwcube
    def test_stringstomoves(self):
        numcube = cube()    #operations like F2,F3 tested
        ccwcube = cube()    #operations like F'
        correct = cube()    #manual rotation for checks

        #test basic string to list parsing
        teststring = "FRLFUDBF"
        moves = correct.string_to_movelist(teststring)
        for move,char in zip(moves,teststring):
            self.assertTrue(move == char)

        #this tests counter clockwise and triple rotation for all sides
        #(ccw and tripple rotation {ex F3 = F 3 times} are the same)
        for side in correct.sides:
            ccwmoves = ccwcube.string_to_movelist(side+"\'")
            nummoves = numcube.string_to_movelist(side+"3")
            ccwcube.do_moves(nummoves)
            numcube.do_moves(nummoves)
            correct.rotations[side]() #F3 is the same as F'
            correct.rotations[side]()
            correct.rotations[side]()

            #F3 == F F F == F'
            self.assertTrue(correct == numcube)
            self.assertTrue(correct == ccwcube)

            #revert all three back to solved
            correct.rotations[side]()
            ccwcube.rotations[side]()
            numcube.rotations[side]()
            self.assertTrue(correct == self.testcube)
            self.assertTrue(correct == numcube)

        #this tests double rotations (ex. F2 is F 2 times)
        for side in correct.sides:
            moves = numcube.string_to_movelist(side+"2")
            numcube.do_moves(moves)
            correct.rotations[side]()
            correct.rotations[side]()
            self.assertTrue(correct == numcube)

            #revert both back to solved
            correct.rotations[side]()
            correct.rotations[side]()
            numcube.do_moves(moves)
            self.assertTrue(correct == numcube)
        del numcube
        del correct
        del ccwcube
Beispiel #9
0
    def add_cube(self):
        tail = self.body[-1]
        dx, dy = tail.dirnx, tail.dirny

        if dx == 1 and dy == 0:
            self.body.append(cube((tail.pos[0] - 1, tail.pos[1])))
        elif dx == -1 and dy == 0:
            self.body.append(cube((tail.pos[0] + 1, tail.pos[1])))
        elif dx == 0 and dy == 1:
            self.body.append(cube((tail.pos[0], tail.pos[1] - 1)))
        elif dx == 0 and dy == -1:
            self.body.append(cube((tail.pos[0], tail.pos[1] + 1)))

        self.body[-1].dirnx = dx
        self.body[-1].dirny = dy
Beispiel #10
0
 def reset(self, color, pos):
     self.head = cb.cube(pos, color=color)
     self.body = []
     self.body.append(self.head)
     self.turns = {}
     self.dirx = 1
     self.diry = 0
Beispiel #11
0
def create_targets():
    targets = []
    for _ in range(30):
        targets.append(cube(texture1))

    cordZ = -7
    cordX = -9
    for i in range(0,10):
        targets[i].add_to_x(cordX)
        targets[i].add_to_y(0)
        targets[i].add_to_z(cordZ)
        cordX += 2


    cordX = -9
    for i in range(10,20):
        targets[i].add_to_x(cordX)
        targets[i].add_to_y(2)
        targets[i].add_to_z(cordZ)
        cordX += 2

    cordX = -9
    for i in range(20,30):
        targets[i].add_to_x(cordX)
        targets[i].add_to_y(4)
        targets[i].add_to_z(cordZ)
        cordX += 2

    return targets
Beispiel #12
0
 def reset(self):
     self.head = cube.cube(self.gs, self.start_pos, color=self.color)
     self.body = []
     self.body.append(self.head)
     self.turns = {}
     self.dirnx = 1
     self.dirny = 0
Beispiel #13
0
 def __init__(self, color, pos):
     self.color = color
     self.head = cube(pos)
     self.body.append(self.head)
     self.dirnx = 0
     self.dirny = 1
     self.visited.append(pos)
Beispiel #14
0
 def reset(self, pos):
     self.head = cube(pos)
     self.body = []
     self.body.append(self.head)
     self.turns = {}
     self.dirnx = 0
     self.dirny = 1
Beispiel #15
0
 def __init__(self, color, pos):
     #pos is given as coordinates on the grid ex (1,5)
     self.color = color
     self.head = cube(pos)
     self.body.append(self.head)
     self.dirnx = 0
     self.dirny = 1
 def setUp(self):
     self.testcube = solver()
     self.solved = cube()
     self.strings = ["FRLUULRFFBLF","FBFRRBLF","UULLFBLUURRDDBDRDLLFBBB",
                     "DBLURFBLURUDDDBFRLLRUFFB","BRBULFFUDDUBRBURLDUBLDRU",
                     "BFRDUFRLURFBDURBFLRUULRDBFLRUFBRLDUFRDDRFBLDUFBDRLUBF",
                     "UBRDULRUDRURBFURDBFRDLUBFRLUDBFRDUBFRLUDBFRURDFBURLBF"]
Beispiel #17
0
def main():
    n = int(input("\n\tNumber to calculate firts n-Cubes: "))
    # cube ( n ): Return the _sum of the first 'n' cubes, the computational time
    # of the algorithm and a list of the sum of nth cubes.
    _sum, count, cubelist = cube(n)
    print("\n\tThe sum of the first ", n, " cubes is: C ( ", n, " ) = ", _sum,
          "\n")
    graph(_sum, count, cubelist, n)
 def setUp(self):
     self.testcube = solver()
     self.solved = cube()
     self.strings = [
         "FRLUULRFFBLF", "FBFRRBLF", "UULLFBLUURRDDBDRDLLFBBB",
         "DBLURFBLURUDDDBFRLLRUFFB", "BRBULFFUDDUBRBURLDUBLDRU",
         "BFRDUFRLURFBDURBFLRUULRDBFLRUFBRLDUFRDDRFBLDUFBDRLUBF",
         "UBRDULRUDRURBFURDBFRDLUBFRLUDBFRDUBFRLUDBFRURDFBURLBF"
     ]
Beispiel #19
0
 def reset(self, pos):
     '''
     reset the snake
     :param pos: tuple(int, int)
     :return: None
     '''
     self.body.clear()
     self.turn_pos.clear()
     self.body.append(cube(pos))
Beispiel #20
0
 def test_do_moves(self):
     manual = cube()  #manual moves for comparison
     self.testcube.do_moves(['F', 'F', 'R', 'L'])
     manual.F()
     manual.F()
     manual.R()
     manual.L()
     self.assertTrue(manual == self.testcube)
     del manual
 def test_do_moves(self):
     manual = cube()  #manual moves for comparison
     self.testcube.do_moves(['F','F','R','L'])
     manual.F()
     manual.F()
     manual.R()
     manual.L()
     self.assertTrue(manual == self.testcube)
     del manual
Beispiel #22
0
    def add_Cube(self):
        tail = self.body[-1]
        x, y = tail.dirx, tail.diry

        if x == 1 and y == 0:
            self.body.append(
                cb.cube((tail.pos[0] - 1, tail.pos[1]), color=self.color))
        elif x == -1 and y == 0:
            self.body.append(
                cb.cube((tail.pos[0] + 1, tail.pos[1]), color=self.color))
        elif x == 0 and y == 1:
            self.body.append(
                cb.cube((tail.pos[0], tail.pos[1] - 1), color=self.color))
        elif x == 0 and y == -1:
            self.body.append(
                cb.cube((tail.pos[0], tail.pos[1] + 1), color=self.color))

        self.body[-1].dirx = x
        self.body[-1].diry = y
Beispiel #23
0
def main():
    if square(50) != 50**2:
        print("Square function does not work")

    if cube(50) != 50**3:
        print("Cube function does not work")

    numbers = [1, 2, 3, 4, 5]
    if sum(numbers) != 15:
        print("Sum function does not work")
Beispiel #24
0
def main():
    parameters = []
    n = int(input("\n\tNumber to calculate firts n-Cubes: "))
    # cube ( n ): Return a list of tuples with the sum of the numbers to the
    # power '3' and the Computational Time of the Algorithm [ ( C ( n ), T ( n ) ) ].
    for i in range(1, n + 1):
        parameters.append(cube(i, 0))
    print("\n\tCubesum ( ", n, " ): ", parameters[len(parameters) - 1][0],
          "\n")
    graph(parameters[len(parameters) - 1], parameters, n)
Beispiel #25
0
def main(argv):
    global width, rows, s, snack, scores
    width = 500
    scores = []
    rows = 20

    win = pygame.display.set_mode((width, width))
    s = snake((255, 0, 0), (10, 10))
    snack = cube(randomSnack(rows, s), color=(0, 255, 0))
    flag = True
    redrawWindow(win)
    clock = pygame.time.Clock()
    count = 0

    while flag and count < 50:
        pygame.time.delay(10)
        clock.tick(10)
        s.move_with_mode(argv[0], snack)
        if s.body[0].pos == snack.pos:
            s.add_cube()
            snack = cube(randomSnack(rows, s), color=(0, 255, 0))

        # Lose from collision with wall
        if ((s.body[0].pos[0] == -1) or (s.body[0].pos[0] == rows)
                or (s.body[0].pos[1] == -1) or (s.body[0].pos[1] == rows)):
            game_over(s, argv)
            count = count + 1
        # Lose by collision with body
        for x in range(len(s.body)):
            if s.body[x].pos in list(map(lambda z: z.pos, s.body[x + 1:])):
                game_over(s, argv)
                count = count + 1
                break

        redrawWindow(win)

    # Save Score results to an outfile
    with open(
            argv[0] + datetime.datetime.today().strftime('%d-%m-%Y') + '.txt',
            'w') as f:
        for listitem in scores:
            f.write('%s\n' % listitem)
Beispiel #26
0
def main(args):
    a = 1
    b = 6
    c = 9
    x = args.x
    print("Lets compute the polynomial of %d*x^3 + %d*x^2 + %d*x" % (a, b, c))
    result = sum([a * cube(x), b * square(x), c * x])
    print("The result is %d" % result)
    true_result = a * x**3 + b * x**2 + c * x
    if true_result == result:
        print("Success class complete!")
    else:
        print("Woops. Try again")
Beispiel #27
0
 def addCube(self):
     '''
     add a cube when a snack is eaten
     :return: None
     '''
     last_cube = self.body[-1]
     last_pos = last_cube.pos
     if last_cube.dir_x == 1:
         newcube_pos = (last_pos[0] - 1, last_pos[1])
         newcube = cube(newcube_pos, last_cube.dir_x, last_cube.dir_y)
         self.body.append(newcube)
     elif last_cube.dir_x == -1:
         newcube_pos = (last_pos[0] + 1, last_pos[1])
         newcube = cube(newcube_pos, last_cube.dir_x, last_cube.dir_y)
         self.body.append(newcube)
     elif last_cube.dir_y == 1:
         newcube_pos = (last_pos[0], last_pos[1] - 1)
         newcube = cube(newcube_pos, last_cube.dir_x, last_cube.dir_y)
         self.body.append(newcube)
     elif last_cube.dir_y == -1:
         newcube_pos = (last_pos[0], last_pos[1] + 1)
         newcube = cube(newcube_pos, last_cube.dir_x, last_cube.dir_y)
         self.body.append(newcube)
Beispiel #28
0
def fuzzOrder():
    c = cube()

    orders = set([])
    acts = {}
    for length in range(7):
        for actions in itertools.product("UDLRFB", repeat=length):
            actions = "".join(actions)
            order = c.order(actions)
            orders.add(order)
            res = fun(order)
            acts[res] = actions
    print(acts)
    return orders
Beispiel #29
0
    def addCube(self):
        tail = self.body[-1]
        dx, dy = tail.dirnx, tail.dirny

        if dx == 1 and dy == 0:
            self.body.append(
                cube.cube(self.gs, (tail.pos[0] - 1, tail.pos[1]),
                          color=self.color))
        elif dx == -1 and dy == 0:
            self.body.append(
                cube.cube(self.gs, (tail.pos[0] + 1, tail.pos[1]),
                          color=self.color))
        elif dx == 0 and dy == 1:
            self.body.append(
                cube.cube(self.gs, (tail.pos[0], tail.pos[1] - 1),
                          color=self.color))
        elif dx == 0 and dy == -1:
            self.body.append(
                cube.cube(self.gs, (tail.pos[0], tail.pos[1] + 1),
                          color=self.color))

        self.body[-1].dirnx = dx
        self.body[-1].dirny = dy
Beispiel #30
0
    def __init__(self, gs, player):
        self.gs = gs
        self.player = player
        self.color = gs.s_colors[self.player - 1]
        self.start_pos = gs.s_starts[player - 1]
        self.width = gs.width
        self.rows = gs.rows
        self.grow = False

        self.head = cube.cube(self.gs, self.start_pos, color=self.color)
        self.body = []
        self.body.append(self.head)
        self.turns = {}
        self.dirnx = 1
        self.dirny = 0
Beispiel #31
0
    def test_rotations(self):
        solved = cube()  #solved cube for comparisons

        #each rotation is a different rotation function (F,R,L,etc)
        for rotation in self.testcube.rotations.itervalues():
            rotation()
            self.assertTrue(not self.testcube == solved)
            rotation()
            rotation()
            rotation()
            self.assertTrue(self.testcube == solved)

        #3-cycle: doing this move sequence 3 times brings cube back to solved
        self.cycle1()
        self.assertFalse(self.testcube == solved)
        self.cycle1()
        self.assertFalse(self.testcube == solved)
        self.cycle1()
        self.assertTrue(self.testcube == solved)
        del solved
    def test_rotations(self):
        solved = cube() #solved cube for comparisons

        #each rotation is a different rotation function (F,R,L,etc)
        for rotation in self.testcube.rotations.itervalues():
            rotation()
            self.assertTrue(not self.testcube == solved)
            rotation()
            rotation()
            rotation()
            self.assertTrue(self.testcube == solved)

        #3-cycle: doing this move sequence 3 times brings cube back to solved
        self.cycle1()
        self.assertFalse(self.testcube == solved)
        self.cycle1()
        self.assertFalse(self.testcube == solved)
        self.cycle1()
        self.assertTrue(self.testcube == solved)
        del solved
 def test_2(self):
     assert cube.cube(2) == 8
Beispiel #34
0

# Glut init
# --------------------------------------
glut.glutInit(sys.argv)
glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH)
glut.glutCreateWindow("Textured Cube")
glut.glutReshapeWindow(512, 512)
glut.glutReshapeFunc(reshape)
glut.glutKeyboardFunc(keyboard)
glut.glutDisplayFunc(display)
glut.glutTimerFunc(1000 / 60, timer, 60)

# Build cube data
# --------------------------------------
vertices, indices, _ = cube()
vertices = VertexBuffer(vertices)
indices = IndexBuffer(indices)

# Build program
# --------------------------------------
program = Program(vertex, fragment)
program.bind(vertices)
program["u_texture"] = np.load("crate.npy")
program["u_texture"].interpolation = gl.GL_LINEAR

# Build view, model, projection & normal
# --------------------------------------
view = np.eye(4, dtype=np.float32)
model = np.eye(4, dtype=np.float32)
projection = np.eye(4, dtype=np.float32)
 def test_1(self):
     self.assertEqual(cube.cube(1), 1)
from cube import cube
from solver import solver

cb = solver()
done = False
while not done:
    ms = raw_input("Scramble String: ")
    ms = ms.upper()
    done = True
    for c in ms:
        done = done and ((c in cb.sides) or (c in ["2", "3"]) or (c == "'"))
    if not done:
        print "You used an invalid character"

cb.do_string(ms)
cb.solve()
disp = cube()
disp.do_string(ms)

print "Initial cube state:"
disp.print_cube()
for step in cb.solmoves:
    raw_input("next move is: " + step)
    disp.do_string(step)
    disp.print_cube()
 def test_0(self):
     assert cube.cube(0) == 0
Beispiel #38
0
#!/usr/bin/env python

from cube import cube

c = cube(3, 4, 5, debug = True)
print "Created cube."
print "Cube volume is", c.volume
c.width = 10
c.height = 10
c.depth = 10
print "Updated cube."
print "Cube volume is", c.volume
print "Cube volume is still", c.volume
print "Cube volume is still", c.volume
 def test_exception_str(self):
     with pytest.raises(TypeError):
         cube.cube('x')
Beispiel #40
0
def cubeToString(cube):
	order = "ULFRBD"
	colors_string = ""
	for face in list(order):
		for i in xrange(0, 3):
			colors_string += ''.join([list(ids.keys())[list(ids.values()).index(x)] for x in c.cube[face].struc[i]])
	return colors_string

moves = generateMoves()
faces = generateFaces()
print "*" * 52
print "BE SURE TO WRITE THIS DOWN INCASE YOU LOSE YOUR CUBE"
print "*" * 52, "\n"
print "Color (Facing): %s" % faces[0]
print "Color (Right): %s" % faces[1]
print "Generated Moves: %s" % moves

colors = [faces[0][0], opposites[faces[0][0]],
		  opposites[faces[1][0]], faces[1][0],
		  tops[faces[0][0] + faces[1][0]], opposites[tops[faces[0][0] + faces[1][0]]]]
colors = [ids[color] for color in colors]
c = cube(colors)
c = doMoves(c, moves)
print c.strCube()

colors_string = cubeToString(c)
print "Passphrase: %s" % colors_string
print "Secret Exp: %s" % sha256(colors_string, mode="colors")
print "Passphrase: %s" % colorToNumbers(colors_string)
print "Secret Exp: %s" % sha256(colors_string, mode="numbers")
Beispiel #41
0

# Glut init
# --------------------------------------
glut.glutInit(sys.argv)
glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH)
glut.glutCreateWindow('Colored Cube')
glut.glutReshapeWindow(512,512)
glut.glutReshapeFunc(reshape)
glut.glutKeyboardFunc(keyboard )
glut.glutDisplayFunc(display)
glut.glutTimerFunc(1000/60, timer, 60)

# Build cube data
# --------------------------------------
vertices, filled, outline = cube()
vertices = VertexBuffer(vertices)
filled = IndexBuffer(filled)
outline = IndexBuffer(outline)

# Build program
# --------------------------------------
program = Program(vertex, fragment)
program.bind(vertices)

# Build view, model, projection & normal
# --------------------------------------
view = np.eye(4,dtype=np.float32)
model = np.eye(4,dtype=np.float32)
projection = np.eye(4,dtype=np.float32)
translate(view, 0,0,-5)
 def mdx_cube(self):
     """ Return a MDX parser of the from clause of a MDX query """
     mdx = Word(alphas+'_')
     mdx.setParseAction(lambda s,a,toks: cube.cube(toks[0]))
     return mdx
 def test_1(self):
     assert cube.cube(1) == 1
 def test_no_arguments(self):
     with pytest.raises(TypeError):
         cube.cube()
Beispiel #45
0
from cube import cube

print(cube(10))
 def test_3(self):
     self.assertEqual(cube.cube(3), 27)
Beispiel #47
0
def show_cube():
    cube.cube()
 def test_3(self):
     assert cube.cube(3) == 27
 def test_2(self):
     self.assertEqual(cube.cube(2), 8)
 def test_exception_str(self):
     with self.assertRaises(TypeError):
         cube.cube('x')
 def test_no_arguments(self):
     with self.assertRaises(TypeError):
         cube.cube()
 def setUp(self):
     self.testcube = cube()
 def test_0(self):
     self.assertEqual(cube.cube(0), 0)
def test_cube(n, expected):
    assert cube.cube(n) == expected
Beispiel #55
0
import cube

print(cube.cube(int(input("insert number: "))))
Beispiel #56
0

# Glut init
# --------------------------------------
glut.glutInit(sys.argv)
glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH)
glut.glutCreateWindow('Lighted Cube')
glut.glutReshapeWindow(512,512)
glut.glutReshapeFunc(reshape)
glut.glutKeyboardFunc(keyboard )
glut.glutDisplayFunc(display)
glut.glutTimerFunc(1000/60, timer, 60)

# Build cube data
# --------------------------------------
V,F,O = cube()
vertices = VertexBuffer(V)
faces = IndexBuffer(F)
outline = IndexBuffer(O)

# Build view, model, projection & normal
# --------------------------------------
view = np.eye(4,dtype=np.float32)
model = np.eye(4,dtype=np.float32)
projection = np.eye(4,dtype=np.float32)
translate(view, 0,0,-5)
normal = np.array(np.matrix(np.dot(view,model)).I.T)

# Build program
# --------------------------------------
program = Program(vertex, fragment)