def start():
    global arg, line, row, house, house_list, start_line, start_row, history, failed_set, driver, num_map

    #origin_house at house_list[0]
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    #print travel(2, 2, 1)
    '''
    history = ''
    if travel(0, 1, 1):
        url = 'http://www.qlcoder.com/train/crcheck?x='+str(2+1)+'&y='+str(2+1)+'&path='+history
        print url
    '''
    print 'search 3'
    for i in range(line):
        for j in range(row):
            if house[i][j] == 3:
                #print '%d,%d\r' % (i, j),
                #print 'walk', i, j
                history = ''
                if travel(i, j, 1):
                    url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+history
                    print url
                    return url
    timing.stop()

    print 'search 2'
    timing.start()
    del house_list[:]
    house_list = []
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 2:
                #print '%d,%d\r' % (i, j),
                #print 'walk', i, j
                history = ''
                if travel(i, j, 1):
                    url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+history
                    print url
                    return url
    timing.stop()

    print 'search 1,4'
    timing.start()
    del house_list[:]
    house_list = []
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 4 or house[i][j] == 1:
                #print '%d,%d\r' % (i, j),
                #print 'walk', i, j
                history = ''
                if travel(i, j, 1):
                    url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+history
                    print url
                    return url

    return None
    def robotStart(self):

        #origin_house at self.house_list[0]

        #print travel(2, 2, 1)
        '''
        self.house_list.append((copy.deepcopy(self.house), copy.deepcopy(self.num_map)))
        self.history = ''
        i = 30
        j = 6
        result = travel_first(i, j, 1)
        if result[0]:
            url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+self.history
            print url
        '''
        # print 'search '+str(mission_type)+' '+str(reverse)
        timing.start()
        self.house_list.append((copy.deepcopy(self.house), copy.deepcopy(self.num_map)))

        while True:
            i, j = (-1, -1)
            self.data_lock.acquire()
            result_size = self.result.qsize()
            queue_size = self.queue.qsize()
            if queue_size > 0:
                i, j = self.queue.get()
                self.data_lock.release()
            else:
                self.data_lock.release()
                print self.name+' break1'
                break

            if i != -1 and j != -1 and result_size == 0:
                self.sum_walk += 1
                # print '%d,%d\r' % (i, j),
                print '(%d, %d)\twalk\t%d, %d\t%s%d/%d' \
                      % (self.mission_type, self.reverse, i, j,
                         '+' if self.reverse == 0 else '-', self.total_queue-queue_size, self.total_queue)
                self.history = ''
                result = self.travel(i, j, 1)
                if result[0]:
                    url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+self.history
                    print url
                    self.sum_second += timing.stop(bPrint=False)
                    return url
            else:
                print self.name+' break2'
                break
        self.sum_second += timing.stop(bPrint=False)

        return None
Beispiel #3
0
    def robotStart(self, mission_type, reverse):

        #origin_house at self.house_list[0]

        #print travel(2, 2, 1)
        '''
        self.house_list.append((copy.deepcopy(self.house), copy.deepcopy(self.num_map)))
        self.history = ''
        i = 30
        j = 6
        result = travel_first(i, j, 1)
        if result[0]:
            url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+self.history
            print url
        '''
        # print 'search '+str(mission_type)+' '+str(reverse)
        timing.start()
        self.house_list.append(
            (copy.deepcopy(self.house), copy.deepcopy(self.num_map)))
        i_range = range(self.line)
        j_range = range(self.row)
        if reverse == 1:
            i_range.reverse()
            j_range.reverse()
        for i in i_range:
            for j in j_range:
                self.data_lock.acquire()
                queue_size = self.queue.qsize()
                self.data_lock.release()
                if self.house[i][j] == int(mission_type) and queue_size == 0:
                    self.sum_walk += 1
                    # print '%d,%d\r' % (i, j),
                    print '(%d, %d) walk %d %d' % (self.mission_type,
                                                   self.reverse, i, j)
                    self.history = ''
                    result = self.travel_first(i, j, 1)
                    if result[0]:
                        url = 'http://www.qlcoder.com/train/crcheck?x=' + str(
                            i + 1) + '&y=' + str(j +
                                                 1) + '&path=' + self.history
                        print url
                        self.sum_second += timing.stop()
                        return url
        self.sum_second += timing.stop()

        return None
    def robotStart(self, mission_type, reverse):

        #origin_house at self.house_list[0]

        #print travel(2, 2, 1)
        '''
        self.house_list.append((copy.deepcopy(self.house), copy.deepcopy(self.num_map)))
        self.history = ''
        i = 30
        j = 6
        result = travel_first(i, j, 1)
        if result[0]:
            url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+self.history
            print url
        '''
        # print 'search '+str(mission_type)+' '+str(reverse)
        timing.start()
        self.house_list.append((copy.deepcopy(self.house), copy.deepcopy(self.num_map)))
        i_range = range(self.line)
        j_range = range(self.row)
        if reverse == 1:
            i_range.reverse()
            j_range.reverse()
        for i in i_range:
            for j in j_range:
                self.data_lock.acquire()
                queue_size = self.queue.qsize()
                self.data_lock.release()
                if self.house[i][j] == int(mission_type) and queue_size == 0:
                    self.sum_walk += 1
                    # print '%d,%d\r' % (i, j),
                    print '(%d, %d) walk %d %d' % (self.mission_type, self.reverse, i, j)
                    self.history = ''
                    result = self.travel_first(i, j, 1)
                    if result[0]:
                        url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+self.history
                        print url
                        self.sum_second += timing.stop()
                        return url
        self.sum_second += timing.stop()

        return None
    if content.__contains__(u"请先登陆"):
        driver_login()
        driver_sendAnswer(ans)


if __name__ == "__main__":
    driver_init()
    try:
        if True:
            timing.start()
            init(
                """
level=79&x=29&y=30&map=001000100000011111000000011000000010001000000100011000000010000000011000100101110010001110111101110000100001000110100000001001000100001000001000100001000010000001100010101000010001011110100011001110000001000001001100001100011000110101100001100001000100001010010000001001001001110000100011000011101111000000000010010000100000001100011000001011000010100000011100011000100010001010011100000000011110001110000001000000000010000110000100000101111110000000110110010001000001110001100100000100000011011000000101110000000001101100011000001001000000111001101100100011101000000000001000100110001010000000100000000010000100011010010110111000011000000001001001000110000000000011111000001100001111000111110000001000111110000000010000100100000010000000110000100110100001011000100011110010010000001001010000101011000111000001000000010100100000010110000100000000000100000111110000110000
"""
            )
            ans = start()
            timing.stop()
        else:
            while True:
                timing.start()
                init(driver_getQuestion())
                ans = start()
                if ans is not None:
                    driver_sendAnswer(ans)
                timing.stop()
    except Exception, e:
        timing.stop()
        print "error", e
        print traceback.format_exc()
    driver_quit()
def start():
    global arg, line, row, house, house_list, start_line, start_row, history, failed_set, driver, num_map, shadow, sum_walk, sum_second

    #origin_house at house_list[0]

    #print travel(2, 2, 1)
    '''
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    history = ''
    i = 30
    j = 6
    result = travel_first(i, j, 1)
    if result[0]:
        url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+history
        print url
    '''
    print 'search 3'
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 3:
                sum_walk += 1
                #print '%d,%d\r' % (i, j),
                print 'walk', i, j
                history = ''
                result = travel_first(i, j, 1)
                if result[0]:
                    url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+history
                    print url
                    return url
    sum_second += timing.stop()
    timing.start()


    print 'search 2'
    del house_list[:]
    house_list = []
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 2:
                sum_walk += 1
                #print '%d,%d\r' % (i, j),
                print 'walk', i, j
                history = ''
                result = travel_first(i, j, 1)
                if result[0]:
                    url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+history
                    print url
                    return url
    sum_second += timing.stop()
    timing.start()


    print 'search 1,4'
    del house_list[:]
    house_list = []
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 4 or house[i][j] == 1:
                sum_walk += 1
                #print '%d,%d\r' % (i, j),
                print 'walk', i, j
                history = ''
                result = travel_first(i, j, 1)
                if result[0]:
                    url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+history
                    print url
                    return url

    return None
        driver_sendAnswer(ans)


if __name__ == '__main__':
    global arg, line, row, house, house_list, start_line, start_row, history, failed_set, driver, num_map, shadow, sum_walk, sum_second
    dev = True
    if dev is False:
        driver_init()
    try:
        if dev:
            timing.start()
            init('''
level=112&x=40&y=41&map=00010011110001100110000000000111001110001010000110001011000101111100000010000100010001100000010000100010011010000001001001111000000100111001000000000111000110110000000011100010010000110000111100100001001000010001100100100000001000001000010000110110000010011001010000010001000100001110000110000001110000100100001000000000111100101101110000001100100010000000111110000001010000001000111001110000000100010000001010001011000100000011100111000010000110010000110000001000010110000000100000100101111100001000010110100001100011010001100000000001000100001001000111010010001100000010001110001110110100101110010110010011110000100000011001101000001000101100100000000100011100010000000001000100000011100010001100010010000001000001100000000001010001000010001111111010011000011000010000110000000111110011110110000001110000001100001000000011100000100110000011001010001001110011100000011100001100000110000100011000100000000100000000000110000101111100100001000100111000110001100000101001100001010000100000011100101001000100000010000010001000000110111100011000100000010001000100110100000001111110011111001110000000001100000010001110000000100000011101100011111000100100010000000100000110000011110001111101000010000100000001100001001110000010000000100110001001100001000010000100000000100000011000011000001000001101101111110101110001110000011000000000001001010010001000001000011110000001011001000010100100001000010010100111000000110011001100000000010110111101000000000000000100011100001100000001000000100000000000100010110001111000100000111011000110111000000101001000111001111000000011001001110100001010100001000100000110010000110000001110010001000000111000000001
''')
            ans = start()
            sum_second += timing.stop(False)
            print '%s: %.2f mins, %d walks, avg: %.2f seconds' % (g_version, sum_second/float(60), sum_walk, sum_second*1.0/sum_walk)
        else:
            while True:
                timing.start()
                init(driver_getQuestion())
                ans = start()
                if ans is not None:
                    driver_sendAnswer(ans)
                sum_second += timing.stop(False)
                print '%s: %.2f mins, %d walks, avg: %.2f seconds' % (g_version, sum_second/float(60), sum_walk, sum_second*1.0/sum_walk)
    except Exception, e:
        timing.stop()
        print 'error', e
        print traceback.format_exc()
    if dev is False:
    time.sleep(3)
    content = driver.find_element_by_xpath("//body").text
    if content.__contains__(u'请先登陆'):
        driver_login()
        driver_sendAnswer(ans)


if __name__ == '__main__':
    driver_init()
    try:
        if True:
            timing.start()
            init('''
level=79&x=29&y=30&map=001000100000011111000000011000000010001000000100011000000010000000011000100101110010001110111101110000100001000110100000001001000100001000001000100001000010000001100010101000010001011110100011001110000001000001001100001100011000110101100001100001000100001010010000001001001001110000100011000011101111000000000010010000100000001100011000001011000010100000011100011000100010001010011100000000011110001110000001000000000010000110000100000101111110000000110110010001000001110001100100000100000011011000000101110000000001101100011000001001000000111001101100100011101000000000001000100110001010000000100000000010000100011010010110111000011000000001001001000110000000000011111000001100001111000111110000001000111110000000010000100100000010000000110000100110100001011000100011110010010000001001010000101011000111000001000000010100100000010110000100000000000100000111110000110000
''')
            ans = start()
            timing.stop()
        else:
            while True:
                timing.start()
                init(driver_getQuestion())
                ans = start()
                if ans is not None:
                    driver_sendAnswer(ans)
                timing.stop()
    except Exception, e:
        timing.stop()
        print 'error', e
        print traceback.format_exc()
    driver_quit()
def start():
    global arg, line, row, house, house_list, start_line, start_row, history, failed_set, driver, num_map, shadow, sum_walk, sum_second

    #origin_house at house_list[0]

    #print travel(2, 2, 1)
    '''
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    history = ''
    i = 30
    j = 6
    result = travel_first(i, j, 1)
    if result[0]:
        url = 'http://www.qlcoder.com/train/crcheck?x='+str(i+1)+'&y='+str(j+1)+'&path='+history
        print url
    '''
    print 'search 3'
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 3:
                sum_walk += 1
                #print '%d,%d\r' % (i, j),
                print 'walk', i, j
                history = ''
                result = travel_first(i, j, 1)
                if result[0]:
                    url = 'http://www.qlcoder.com/train/crcheck?x=' + str(
                        i + 1) + '&y=' + str(j + 1) + '&path=' + history
                    print url
                    return url
    sum_second += timing.stop()
    timing.start()

    print 'search 2'
    del house_list[:]
    house_list = []
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 2:
                sum_walk += 1
                #print '%d,%d\r' % (i, j),
                print 'walk', i, j
                history = ''
                result = travel_first(i, j, 1)
                if result[0]:
                    url = 'http://www.qlcoder.com/train/crcheck?x=' + str(
                        i + 1) + '&y=' + str(j + 1) + '&path=' + history
                    print url
                    return url
    sum_second += timing.stop()
    timing.start()

    print 'search 1,4'
    del house_list[:]
    house_list = []
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 4 or house[i][j] == 1:
                sum_walk += 1
                #print '%d,%d\r' % (i, j),
                print 'walk', i, j
                history = ''
                result = travel_first(i, j, 1)
                if result[0]:
                    url = 'http://www.qlcoder.com/train/crcheck?x=' + str(
                        i + 1) + '&y=' + str(j + 1) + '&path=' + history
                    print url
                    return url

    return None
        driver_sendAnswer(ans)


if __name__ == '__main__':
    global arg, line, row, house, house_list, start_line, start_row, history, failed_set, driver, num_map, shadow, sum_walk, sum_second
    dev = True
    if dev is False:
        driver_init()
    try:
        if dev:
            timing.start()
            init('''
level=112&x=40&y=41&map=00010011110001100110000000000111001110001010000110001011000101111100000010000100010001100000010000100010011010000001001001111000000100111001000000000111000110110000000011100010010000110000111100100001001000010001100100100000001000001000010000110110000010011001010000010001000100001110000110000001110000100100001000000000111100101101110000001100100010000000111110000001010000001000111001110000000100010000001010001011000100000011100111000010000110010000110000001000010110000000100000100101111100001000010110100001100011010001100000000001000100001001000111010010001100000010001110001110110100101110010110010011110000100000011001101000001000101100100000000100011100010000000001000100000011100010001100010010000001000001100000000001010001000010001111111010011000011000010000110000000111110011110110000001110000001100001000000011100000100110000011001010001001110011100000011100001100000110000100011000100000000100000000000110000101111100100001000100111000110001100000101001100001010000100000011100101001000100000010000010001000000110111100011000100000010001000100110100000001111110011111001110000000001100000010001110000000100000011101100011111000100100010000000100000110000011110001111101000010000100000001100001001110000010000000100110001001100001000010000100000000100000011000011000001000001101101111110101110001110000011000000000001001010010001000001000011110000001011001000010100100001000010010100111000000110011001100000000010110111101000000000000000100011100001100000001000000100000000000100010110001111000100000111011000110111000000101001000111001111000000011001001110100001010100001000100000110010000110000001110010001000000111000000001
''')
            ans = start()
            sum_second += timing.stop(False)
            print '%s: %.2f mins, %d walks, avg: %.2f seconds' % (
                g_version, sum_second / float(60), sum_walk,
                sum_second * 1.0 / sum_walk)
        else:
            while True:
                timing.start()
                init(driver_getQuestion())
                ans = start()
                if ans is not None:
                    driver_sendAnswer(ans)
                sum_second += timing.stop(False)
                print '%s: %.2f mins, %d walks, avg: %.2f seconds' % (
                    g_version, sum_second / float(60), sum_walk,
                    sum_second * 1.0 / sum_walk)
    except Exception, e:
Beispiel #11
0
Using a custom made timing script, markers can be timed with ease.
All you need to do is input marker names, and press enter when you complete them.
'''

os.system("clear")
marker = "blank"
markers = []
while marker != "":
    marker = input("Marker name: ")
    if marker:
        markers.append(marker)

os.system("clear")

for i in range(10):
    print(str(10 - i) + " seconds remaining to start...")
    time.sleep(1)
    os.system("clear")

os.system("clear")

for marker in markers:
    timing.start(marker)
    input("Timing for marker \"" + marker + "\"")
    timing.stop(marker)
    os.system("clear")

os.system("clear")

timing.sumtimes(markers)
def start():
    global arg, line, row, house, house_list, start_line, start_row, history, failed_set, driver, num_map

    #origin_house at house_list[0]
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    #print travel(2, 2, 1)
    '''
    history = ''
    if travel(0, 1, 1):
        url = 'http://www.qlcoder.com/train/crcheck?x='+str(2+1)+'&y='+str(2+1)+'&path='+history
        print url
    '''
    print 'search 3'
    for i in range(line):
        for j in range(row):
            if house[i][j] == 3:
                #print '%d,%d\r' % (i, j),
                #print 'walk', i, j
                history = ''
                if travel(i, j, 1):
                    url = 'http://www.qlcoder.com/train/crcheck?x=' + str(
                        i + 1) + '&y=' + str(j + 1) + '&path=' + history
                    print url
                    return url
    timing.stop()

    print 'search 2'
    timing.start()
    del house_list[:]
    house_list = []
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 2:
                #print '%d,%d\r' % (i, j),
                #print 'walk', i, j
                history = ''
                if travel(i, j, 1):
                    url = 'http://www.qlcoder.com/train/crcheck?x=' + str(
                        i + 1) + '&y=' + str(j + 1) + '&path=' + history
                    print url
                    return url
    timing.stop()

    print 'search 1,4'
    timing.start()
    del house_list[:]
    house_list = []
    house_list.append((copy.deepcopy(house), copy.deepcopy(num_map)))
    for i in range(line):
        for j in range(row):
            if house[i][j] == 4 or house[i][j] == 1:
                #print '%d,%d\r' % (i, j),
                #print 'walk', i, j
                history = ''
                if travel(i, j, 1):
                    url = 'http://www.qlcoder.com/train/crcheck?x=' + str(
                        i + 1) + '&y=' + str(j + 1) + '&path=' + history
                    print url
                    return url

    return None