コード例 #1
0
ファイル: Jeu.py プロジェクト: mrthewhity/cantstop
    def __init__(self, listeJoueur, IA_level):
        '''
		Cette fonction initalise la classe Jeu
		:param listeJoueur : liste
		'''

        self.HEIGHT = {
            2: 3,
            3: 5,
            4: 7,
            5: 9,
            6: 11,
            7: 13,
            8: 11,
            9: 9,
            10: 7,
            11: 5,
            12: 3
        }

        self.blocked_routes = []
        self.listeJoueur = listeJoueur
        self.wait_Form = QtGui.QDialog()
        self.waitObjet = wait()
        self.waitObjet.init(self.wait_Form)
        self.players = Joueur(listeJoueur, IA_level, self.waitObjet)
コード例 #2
0
 def test_timeout(self):
     op = InFlightOperations("test")
     with op(None) as w:
         try:
             yield wait(w, timeout=0, fail=RuntimeError("hi"))
         except RuntimeError as e:
             self.assertEquals(str(e), "hi")
         else:
             raise
         self.assertEquals(list(op), [None])
     self.assertEquals(list(op), [])
コード例 #3
0
# if args.best:
#     saver.restore(sess, save_path=save_path + 'best_model.ckpt')
#     env = breakout_environment(5, 8, 3, 1, 2)
#     ani = breakout_animation(env, 200, q_estimator)
#     ani.save(save_path + 'video_best' + '.mp4', dpi=200)
#     # plt.show(block=False)
#     print('Number of Steps Taken: %.f' % ani.number_of_steps)
#     print('******************* Generated Video for BEST **********************')
# else:
#     for percentage in restore_model_percentages:
#         i_episode = int(percentage * 0.01 * num_episodes)
#         saver.restore(sess, save_path=save_path+'model.ckpt-'+str(i_episode))
#         env = breakout_environment(5, 8, 3, 1, 2)
#         ani = breakout_animation(env, 200, q_estimator)
#         ani.save(save_path + 'video_steps_' + str(i_episode) + '.mp4', dpi=200)
#         # plt.show(block=False)
#         print('Number of Steps Taken: %.f' % ani.number_of_steps)
#         print('******************* Generated Video for Steps: '+ str(i_episode) + '*******************')

saver.restore(sess, save_path=save_path + 'best_model.ckpt')
env = breakout_environment(5, 8, 3, 1, 2)
ani = breakout_animation(env, 200, q_estimator)
# ani.save(save_path + 'video_best' + '.mp4', dpi=200)

plt.show(block=False)
# animation.FuncAnimation(ani._draw_frame, 100)
print('Number of Steps Taken: %.f' % ani.number_of_steps)
print('******************* Generated Video for BEST **********************')

wait('Press enter to quit')
コード例 #4
0
    def test_context_single(self):
        op = InFlightOperations("test")
        with op(1) as w:
            self.assertEquals(list(op), [1])
            self.assertIsInstance(w, defer.Deferred)
            self.assertIdentical(w, op[1])
            self.assertIdentical(op.get(1), op[1])
        self.assertEquals(list(op), [])

        with op(key=2, log=logging.getLogger(LOG_CATEGORY)):
            self.assertEquals(list(op), [2])
            self.assertIsInstance(op.get(2), defer.Deferred)
            self.assertIdentical(op.get(2), op[2])
        self.assertEquals(list(op), [])

        try:
            with op(None, logging.getLogger(LOG_CATEGORY)) as w:
                reactor.callLater(0, w.cancel)  # @UndefinedVariable
                yield wait(w, timeout=None, fail=None)
        except CancelledError:
            pass
        else:
            raise
        self.assertEquals(list(op), [])

        try:
            with op(None, logging.getLogger(LOG_CATEGORY)) as w:
                reactor.callLater(0, w.errback, StompCancelledError("4711"))  # @UndefinedVariable
                yield wait(w)
        except StompCancelledError as e:
            self.assertEquals(str(e), "4711")
        else:
            raise
        self.assertEquals(list(op), [])

        with op(None, logging.getLogger(LOG_CATEGORY)) as w:
            reactor.callLater(0, w.callback, 4711)  # @UndefinedVariable
            result = yield wait(w)
            self.assertEquals(result, 4711)
        self.assertEquals(list(op), [])

        try:
            with op(None) as w:
                raise RuntimeError("hi")
        except RuntimeError:
            pass
        self.assertEquals(list(op), [])
        try:
            yield w
        except RuntimeError as e:
            self.assertEquals(str(e), "hi")
        else:
            raise

        try:
            with op(None) as w:
                d = wait(w)
                raise RuntimeError("hi")
        except RuntimeError:
            pass
        self.assertEquals(list(op), [])
        try:
            yield d
        except RuntimeError as e:
            self.assertEquals(str(e), "hi")
        else:
            pass