Пример #1
0
	def regenerate_problem( self ):
		try:
			self.question.remove()
			self.answer.remove()
		except:
			pass
		self.question_text, self.answer_text, null = expr.generate()
		self.question = entity.SentenceEntity( ( 177, 450 ), self.question_text, size=20 )
		self.answer = entity.SentenceEntity( ( 178, 522 ), self.answer_text, size=20 )
		self.world.add_entity( self.question )
		self.world.add_entity( self.answer )
Пример #2
0
    def __init__(self):
        pygame.init()

        # set the dimensions of the display window
        self.SIZE = self.WIDTH, self.HEIGHT = 800, 600

        # set the FPS
        self.FPS = 30

        # the actual FPS value refers to the delay, so let's update it properly
        # 1000ms/self.FPS = delay (but we're still calling it FPS)
        self.FPS = 1000 / self.FPS

        # create the window and display it
        self.window = gamewindow.GameWindow(self.SIZE)
        self.window.set_title(CalculusBlasters.TITLE)
        self.window.set_flags(pygame.HWSURFACE
                              | pygame.DOUBLEBUF)  # | pygame.FULLSCREEN )
        self.window.display()

        self.clock = pygame.time.Clock()

        self.keys = {
            pygame.K_ESCAPE: False,
            pygame.K_LEFT: False,
            pygame.K_RIGHT: False,
            pygame.K_z: False,
            pygame.K_x: False
        }

        self.world = world.World((800, 600))
        self.world.set_background("blasters-gui.png")
        self.world.debug = True

        # create the viewport that will view the world
        self.viewport = viewport.Viewport(self.window, self.world)

        self.question_text, self.answer_text, self.null = expr.generate()
        self.question = entity.SentenceEntity((177, 450),
                                              self.question_text,
                                              size=20)
        self.answer = entity.SentenceEntity((178, 522),
                                            self.answer_text,
                                            size=20)
        self.world.add_entity(self.question)
        self.world.add_entity(self.answer)

        self.delta = 0.0
        self.fps_count = 0.0

        self.running = True
        while self.running:
            self.game_loop()
Пример #3
0
def cal_bank_init():
	global z, zt, net

	li = []
	global test_sample_count
	for i in range(test_sample_count):
		li.append(expr.generate(net, z, im=zt['IM'][i])+'\n')

	output = open('blank-init-results.txt','wb')
	try:
		output.writelines(li)
	finally:
		output.close()
Пример #4
0
 def regenerate_problem(self):
     try:
         self.question.remove()
         self.answer.remove()
     except:
         pass
     self.question_text, self.answer_text, null = expr.generate()
     self.question = entity.SentenceEntity((177, 450),
                                           self.question_text,
                                           size=20)
     self.answer = entity.SentenceEntity((178, 522),
                                         self.answer_text,
                                         size=20)
     self.world.add_entity(self.question)
     self.world.add_entity(self.answer)
Пример #5
0
def cal_similar_init():
	global z, zt, net
	context = 5

	li = []
	global test_sample_count
	for i in range(test_sample_count):
		similar = get_similar_init(net,z,zt['IM'][i], context=context)[0]
		li.append(' '.join(similar) + ' ' + expr.generate(net, z, im=zt['IM'][i], init=similar)+'\n')
	
	output = open('similar-init-results.txt', 'wb')
	try:
		output.writelines(li)
	finally:
		output.close()
Пример #6
0
	def __init__( self ):
		pygame.init()

		# set the dimensions of the display window
		self.SIZE = self.WIDTH, self.HEIGHT = 800, 600

		# set the FPS
		self.FPS = 30

		# the actual FPS value refers to the delay, so let's update it properly
		# 1000ms/self.FPS = delay (but we're still calling it FPS)
		self.FPS = 1000 / self.FPS

		# create the window and display it
		self.window = gamewindow.GameWindow( self.SIZE )
		self.window.set_title( CalculusBlasters.TITLE )
		self.window.set_flags( pygame.HWSURFACE | pygame.DOUBLEBUF )# | pygame.FULLSCREEN )
		self.window.display()

		self.clock = pygame.time.Clock()

		self.keys = {
			pygame.K_ESCAPE : False,
			pygame.K_LEFT : False,
			pygame.K_RIGHT : False,
			pygame.K_z : False,
			pygame.K_x : False
		}

		self.world = world.World( ( 800, 600 ) )
		self.world.set_background( "blasters-gui.png" )
		self.world.debug = True

		# create the viewport that will view the world
		self.viewport = viewport.Viewport( self.window, self.world )

		self.question_text, self.answer_text, self.null = expr.generate()
		self.question = entity.SentenceEntity( ( 177, 450 ), self.question_text, size=20 )
		self.answer = entity.SentenceEntity( ( 178, 522 ), self.answer_text, size=20 )
		self.world.add_entity( self.question )
		self.world.add_entity( self.answer )

		self.delta = 0.0
		self.fps_count = 0.0

		self.running = True
		while self.running:
			self.game_loop()