Beispiel #1
0
def main():

    con, panel, mouse, key = Initializer.init_game()

    newgame = Menu.main_menu(con, key, mouse)

    if not newgame:
        sys.exit(0)

    race, prof = Menu.starting_menu(con, key, mouse)

    world = World(race, prof)

    # world.debug = True

    mapmaker = MapMaker()

    mapmaker.new_dungeon(world)

    world.fov_map = Initializer.init_fov_map(world.tilemap)

    DeathFunctions.world = world

    while not libtcod.console_is_window_closed():

        RenderFunctions.render_all(con, panel, world)
        libtcod.console_flush()

        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        action = Controls.handle_keys(key, world)

        world.update(action)
Beispiel #2
0
 def __init__(self):
     self.world = World(GLOBAL_X, GLOBAL_Y)
     self.init_population()
     self.start_population = sum(list(self.count_humans().values()))
     self.humans_on_grid_vec = np.vectorize(self._update_humans_on_grid)
     self.update_human_vec = np.vectorize(self._update_human)
     self.day_counter = 0
Beispiel #3
0
 def __init__(self):
     """
     Resets the Game
     """
     # variables
     self.world = World()
     self.n_players = 0
     self.start_troops = 0
     self.players = []
     self.owned_territories = []
Beispiel #4
0
        def wrapper(app, msg):
            user = msg.from_user
            username = user.first_name
            user_id = user.id
            if user_id not in db:
                db[user_id] = World(username)
            world = db[user_id]

            my_func(app, msg, world)

            db[user_id] = world
            db.sync()
            msg.continue_propagation()
Beispiel #5
0
def main():
    #world = World("vegetation_map_with_key.png", "elevation_map.png")

    st.title("CivSim")
    st.subheader("Simulation utilizing cellular automata")

    #slider for the number of steps
    st.sidebar.text(
        "In this simulation, the cells on the \nedges of civilizations have a chance to \ncolonize neighbors or go extinct based \nupon the vegatation, elevation, and a \nrandomized percent colonization. "
    )
    teams = st.sidebar.slider("Number of players",
                              min_value=5,
                              max_value=15,
                              step=1,
                              value=10)
    steps = st.sidebar.slider("Number of decade-long time steps",
                              min_value=100,
                              max_value=2200,
                              step=100,
                              value=800)
    image = Image.open("afroeurasia.png")
    st_image = st.image(image, use_column_width=True)
    age_text = st.sidebar.text("Current Time: 20000 BC")
    progress_bar = st.sidebar.progress(0)

    world = World(VEG_IM, ELV_IM, teams)
    ensemble = Ensemble(world, AFROEURASIA)
    age = -20000
    if st.sidebar.button("Run Simulation"):
        running = True
        while running:
            counter = 0
            while counter < steps:
                age = ensemble.run(age, counter, st_image, age_text,
                                   progress_bar, steps)
                counter += 1
            running = False
Beispiel #6
0
from classes.world import World, EnemyTile
from classes.player import Player
from collections import OrderedDict

import os
import pickle
world = World()


class Game:
    def __init__(self):
        self.name = "Player"
        self.game_active = False
        self.player_coordinates = -1, -1

    def New_Game(self):
        """
        Initialize a new game.
        - Chadwick
        """
        self.name = input("What is your characters name: ")
        self.Start_Game("level1")

        # Create a user file with information
        # instantiate inventory class

    def Start_Game(self, map_name):
        """
        Starts a playable game
        - Chadwick
        """
Beispiel #7
0
import numpy as np
import random as rnd
import matplotlib.pyplot as plt
import seaborn as sns
import time
import pandas as pd
from typing import List

from utils.globals import *
from utils.randomizer import create_chance
from classes.human import Human
from classes.world import World


world = World(GLOBAL_X, GLOBAL_Y)
grid = world.world_grid


def _get_random_humans(human_positions: List[List[str]]):
    positions = np.transpose((human_positions).nonzero()).tolist()
    random_humans = [rnd.choice(positions) for p in range(HUMAN_MOVEMENT)]

    return random_humans


def update_human(val, TIME_RANGE: int):
    if val:
        if val.is_sick:
            if val.sick_days >= TIME_UNTIL_CURED:
                if create_chance(CHANCE_CURE):
                    val.cure()