Exemple #1
0
def main():
    _, m1 = reader('input-17.txt')
    checker(m1)

    m2 = shuffle_matrix(m1)
    checker(m2)

    print_matrix(m1)
    print_matrix(m2)

    test_isomorphism(m1, m2)
Exemple #2
0
def read_matrix():
    with open('v.txt', 'r') as file:
        n = int(file.readline())
        m = [[0] * n for _ in range(n)]
        for i in range(n):
            s = file.readline().split(' ')
            for j in range(n):
                if i < j:

                    if i - j == -1 or i == 0 and j == 11:
                        m[i][j] = 0
                    else:
                        m[i][j] = 0 if '-' in s[j] else 1
                else:
                    m[i][j] = 0
        helper.print_matrix(m)
        return n, m
Exemple #3
0
 def show(self):
     print_matrix(self.tetramino_matrix)
Exemple #4
0
	            <Inventory>
	            </Inventory>
	        </AgentStart>
	        <AgentHandlers>
	            <ChatCommands/>
	            <ContinuousMovementCommands turnSpeedDegs="360"/>
	            <AbsoluteMovementCommands/>
	            <ObservationFromNearbyEntities>
	                <Range name="entities" xrange="''' + str(
                                                   Constants.ARENA_COL
                                               ) + '''" yrange="2" zrange="''' + str(
                                                   Constants.ARENA_ROW
                                               ) + '''" />
	            </ObservationFromNearbyEntities>
	            <ObservationFromFullStats/>
	            <RewardForCollectingItem>
	                <Item type="''' + Constants.GOAL_TYPE + '''" reward="''' + str(
                                                   Constants.GOAL_REWARD
                                               ) + '''"/>
	            </RewardForCollectingItem>
	        </AgentHandlers>
	    </AgentSection>

	</Mission>'''


if __name__ == '__main__':
    print 'Actual Percent: {:.3f}'.format(generate_Matrix())

    print helper.print_matrix(Constants.MATRIX)
Exemple #5
0
 def print_active_tetramino_on_matrix(self):
     self.spawn_active_tetramino()
     print_matrix(self.temp_PLAY_AREA)
#!/usr/bin/python

from __future__ import print_function
import sys

from helper import print_matrix
from Game import Game


if __name__ == '__main__':

    myGame = Game()
    execute_instruction = {'q': sys.exit, 
                           'p': (lambda: print_matrix(myGame.PLAY_AREA)),
                           'g': myGame.read_play_area,
                           'c': myGame.clear_matrix,
                           '?s': myGame.display_score,
                           '?n': myGame.display_n_lines_cleared,
                           's': myGame.one_step,
                           't': (lambda: myGame.active_tetramino.show()),
                           'I': (lambda: myGame.set_active_tetramino('I')),
                           'O': (lambda: myGame.set_active_tetramino('O')),
                           'Z': (lambda: myGame.set_active_tetramino('Z')),
                           'S': (lambda: myGame.set_active_tetramino('S')),
                           'J': (lambda: myGame.set_active_tetramino('J')),
                           'L': (lambda: myGame.set_active_tetramino('L')),
                           'T': (lambda: myGame.set_active_tetramino('T')),
                           ')': (lambda: myGame.active_tetramino.rotate_cw()),
                           ';': (lambda: print('\n', end=''))}

    while True:
Exemple #7
0
    total_err += np.abs(err)

    print(
        '(' + "({0:2d},{1:2d}) -> ({2:2d},{3:2d})".format(
            d[n][0], d[n][1], d[n][2], d[n][3]) + ') = ' +
        "{0:8.2f} / {1:8.2f}   diff: {2:8.2f} 1/cm".format(d[n][4], fit, err))

print("\nTotal error/no of lines = {0:6.5f}\n".format(total_err / len(d)))

###############################################
# calculate predictions
###############################################

print()
print_params(result)

(Yg, Ye) = make_params_dunham(result)

#print_matrix(Yg)
#print_matrix(Ye)

(Ug, Ue) = reduce_dunham(Yg, Ye)

print_matrix(Ug)
print_matrix(Ue)
make_report(Ug, Ue, vmax=1, Jmax=1, save_filename='lines_dunham.txt')

#print_matrix(Ug)
#print_matrix(Ue)
Exemple #8
0
def frank_fish(m):
    n = len(m)
    merged = [i for i in range(n)]

    # Исходный граф:
    step = 0
    print(f'step = {step}')
    print('Source graph:')
    print_matrix(m)

    for step in range(1, 6):
        print(f'step = {step}')

        # cut:
        max_w = -1
        for i in range(n):
            if merged[i] != i:
                continue

            max_w = max(max_w, m[i][0])

        print(f'max_w = {max_w}')

        # merge:
        for i in range(n):
            for j in range(i):
                if m[i][j] >= max_w:
                    merged[i] = j

        # update merged
        need_next = True
        while need_next:
            need_next = False
            for i in range(len(merged)):
                if merged[i] != i and merged[i] != merged[merged[i]]:
                    merged[i] = merged[merged[i]]
                    need_next = True

        print('merged:')
        print(merged)

        lst = [set() for _ in range(n)]
        for i in range(n):
            if i != merged[i]:
                lst[merged[i]].add(i)

        # update matrix:
        for i in range(n):
            if lst[i]:
                for j in lst[i]:
                    for k in range(n):
                        if k != i:
                            m[k][i] = max(m[k][i], m[k][j])
                            m[i][k] = m[k][i]
        print(lst)

        new_m = [[-1] * n for _ in range(n)]
        for i in range(n):
            for j in range(n):
                if merged[i] == i and merged[j] == j:
                    new_m[i][j] = m[i][j]

        m = new_m
        checker(m)
        print_matrix(m)