I have a rather specific question:
I want to print out characters at a specific place using the \033[ syntax. This is what the code below should do: (the dict cells has the same keys as coords but with either '*' or '-' as value.)
coords = {'x'+str(x)+'y'+str(y) : (x,y) for x,y, in itertools.product(range(60), range(20))}
for key, value in coords.items():
char = cells[key]
x,y = value
HORIZ=str(x)
VERT=str(y)
char = str(char)
print('\033['+VERT+';'+HORIZ+'f'+char)
However, I noticed that if I put this into a infinite while loop, it does not always prints the same characters at the same position. There are only slight changes, but it deletes some and puts them back in after some loops. I already tried it with lists, and there it seems to behave just fine, so I tend to think it has something todo with the dict, but I can not figure out what it could be. You can see the Problem in a console here: SharedConsole.I am happy for every tip on this matter.
On a related topic:
After the printing, some changes should be made at the values of the cells dict, but for reason unknown to me, the only the first two rules are executed and the rest is ignored. The rules should test how many neighbours (which is in population) are around the cell and apply the according rule. In my implemention of this I have some kind of weird tumor growth (which should not happen, as if there more than three around they should the cell should die) (see FreakingTumor):
if cells_copy [coord] == '-':
if population == 3:
cells [coord] = '*'
if cells_copy [coord] == '*':
if population > 3:
cells [coord] = '-'
elif population <= 1:
cells [coord] = '-'
elif population == 2 or 3:
cells [coord] = '*'
I checked the population variable several times, so I am quite sure that is not the matter.
I am sorry for the slow consoles.
Thanks in advance!
Kyril