Skip to content

Instantly share code, notes, and snippets.

@antlauzon
Created December 3, 2020 22:05
Show Gist options
  • Save antlauzon/3642826f1c553e64b235580d85be0c4e to your computer and use it in GitHub Desktop.
Save antlauzon/3642826f1c553e64b235580d85be0c4e to your computer and use it in GitHub Desktop.
geomancy.py
import json
import sys
def print_figure(figure, on=' * ', off=' '):
for i in range(12):
if i % 3 == 0 and i != 0:
sys.stdout.write('\n')
sys.stdout.write(on if i in figure else off)
sys.stdout.write('\n')
def print_figures():
for figure_name, subfigures in figures.items():
for subfigure_name, figure in subfigures.items():
print_figure(figure)
def combine_figures(figures):
if len(figures) == 1:
return figures[0]
expanded = [
[len(set([i]) & set(figures[0])) for i in range(12)],
[len(set([i]) & set(combine_figures(figures[1:]))) for i in range(12)]
]
figure = []
for i in range(4):
if (sum(expanded[0][3*i:3*i+3]) +
sum(expanded[1][3*i:3*i+3])) % 2 == 0:
figure += [3*i, 3*i+2]
else:
figure += [3*i+1]
return figure
FIGURES = {
'solis': {
'greater_fortune': [0,2,3,5,7,10],
'lesser_fortune': [1,4,6,8,9,11]
},
'luna': {
'via': [1,4,7,10],
'populus': [0,2,3,5,6,8,9,11]
},
'jovis': {
'acquisitio': [0,2,4,6,8,10],
'laetitia': [0,2,4,6,8,10]
},
'veneris': {
'puella': [1,3,5,6,8,9,11],
'amissio':[1,3,5,7,10]
},
'mercurii': {
'conjunctio': [1,4,6,8,10],
'albus': [0,2,4,6,7,9,11]
},
'martis': {
'puer': [1,4,6,8,10],
'rubeus': [0,2,3,5,6,8,10]
},
'saturni': {
'carcer': [1,3,5,6,8,10],
'tristitia': [0,2,3,5,6,8,10]
},
'dragon': {
'head': [0,2,4,7,10],
'tail': [1,4,7,9,11]
}
}
def main():
if len(sys.argv) == 1 or sys.argv[1] == '--help':
for figure_name, subfigure_name in FIGURES.items():
print("{}: {}".format(figure_name,
', '.join(subfigure_name.keys())))
sys.exit(1)
names = [fsf.split(':') for fsf in sys.argv[1:]]
figures = [FIGURES.get(f, {}).get(sf) for f, sf in names]
if not None in figures:
combined = combine_figures(figures)
print(combined)
print_figure(combined)
else:
for figure_name, subfigure_name in FIGURES.items():
print("{}: {}".format(figure_name,
', '.join(subfigure_name.keys())))
sys.exit(1)
sys.exit(0)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment