Beispiel #1
0
    parser.add_argument("num_empires",
                        help="number of empires to have in the simulation",
                        type=int)
    parser.add_argument("size", help="height of the square map", type=int)

    args = parser.parse_args()

    root = Tk()

    grid = Map(args.size)

    app = App(root, grid)

    Empire.APP = app

    names = None
    script_dir = os.path.dirname(__file__)  # <-- absolute dir the script is in
    rel_path = "empire_names.txt"
    abs_file_path = os.path.join(script_dir, rel_path)
    with open(abs_file_path) as f_name:
        names = f_name.read().split("\n")

    num_empires = args.num_empires
    for _ in range(num_empires):
        app.add_empire(Empire(random.choice(names), grid.rand_select()))

    while True:
        app.turn()
        root.update()
    root.destroy()
from empire import Empire
from map import Map
from tkinter import *

if __name__ == '__main__':

    root = Tk()
    size = 30
    grid = Map(size)

    app = App(root, grid)
    Empire.APP = app

    a = Empire("Good Morning", grid[29, 15])
    a.color = "#00ff00"
    app.add_empire(a)

    b = Empire("NaNaNaNaNaNaN", grid[0, 15])
    b.color = "#0000FF"
    app.add_empire(b)
    # radi = grid.getAdjacentLocs([(size/2, size/2), (16, 15), (17, 16)])
    # for loc in radi:
    #     app[loc] = "#00FF00"

    root.update()
    while True:
        for loc in b.getBeyondBorders():
            app[loc.properties["Location"]] = "#00FF00"
        root.update()

    root.destroy()