예제 #1
0
def set_castles(my_side, screen):
    if my_side == 'left':
        my_castle = Castle(-150, 580, 'left', screen, 21)
        enemy_castle = Castle(1300, 50, 'right', screen, 24)
    else:
        my_castle = Castle(1300, 50, 'right', screen, 24)
        enemy_castle = Castle(-150, 580, 'left', screen, 21)
    return my_castle, enemy_castle
예제 #2
0
def main():
    client_socket = sys.argv[0]
    music_battle()
    my_side = sys.argv[1]
    screen = build_screen(1440, 819)
    turn = 0
    my_creachers = []
    enemy_creachers = []
    my_castle, enemy_castle = set_castles(my_side, screen)
    castle_for_good_graphics = Castle(1300, -1000000, 'right', screen, 24)
    characters_names = characters_names_list()
    character_to_append = ''
    mana = 3
    run = True
    while run:
        turn += 1
        ready = select.select([client_socket], [], [], 0.016)
        if ready[0]:
            data = client_socket.recv(1024)
            if data != 'finish':
                my_creachers, enemy_creachers = return_character_by_string(
                    data, screen, my_side, my_creachers, enemy_creachers)
            else:
                run = False
        if run:
            mana = update_mana(mana, turn)
            build_areana(screen)
            show_mana(mana, screen)
            show_side(screen, my_side, turn)
            my_castle.show()
            enemy_castle.show()
            show_toolbar(characters_names, screen)
            show_creachers(my_creachers)
            show_creachers(enemy_creachers)
            pygame.display.flip()
            castle_for_good_graphics.show()
            my_creachers_new = run_creachers(my_creachers, enemy_creachers,
                                             enemy_castle)
            enemy_creachers_new = run_creachers(enemy_creachers, my_creachers,
                                                my_castle)
            my_creachers = my_creachers_new
            enemy_creachers = enemy_creachers_new
            mouse_x, mouse_y = mouse()
            character_to_append, mana = handel_charachter_to_append(
                mouse_x, mouse_y, characters_names, character_to_append,
                client_socket, mana, my_side)
            run = run and (not quit_pressed(
            )) and my_castle.health is not 0 and enemy_castle.health is not 0
    sys.argv = [my_castle]
예제 #3
0
    def mainPane(self):
        locations = ["Tavern", "Shop", "Forest", "Inn", "Castle"]
        character_approval = False
        while character_approval != True:
            hero = Hero(Weapon().generate_weapon())
            print("Your character is " + hero.char.name +
                  "\nEquipped with a " + hero.get_weapon().name +
                  " that does " + str(hero.get_weapon().low_damage) + "-" +
                  str(hero.get_weapon().high_damage) + " damage.")
            char_generation = input("Do you approve of this character: ")
            if "Y" in char_generation.upper():
                character_approval = True

        while True:
            print("\nLocations: ")
            counter = 1
            for i in locations:
                print(str(counter) + ". " + i)
                counter += 1
            location_choice = input("Where would you like to go: ")
            if int(location_choice) is 1:
                Tavern(hero)
            if int(location_choice) is 2:
                Shop(hero)
            if int(location_choice) is 3:
                forest = Forest()
                forest.entry(hero)
            if int(location_choice) is 4:
                hotel = Inn(hero)
            if int(location_choice) is 5:
                Castle(hero)
            input()
예제 #4
0
def create_world():
    global boy,castle,select,boy2,boy3,bom,can

    pX2=None
    pY2=None
    pX3=None
    pY3=None
    boy=[]
    boy2=[]
    boy3=[]
    castle=Castle()
    select=Select()
    bom=bomb()
    can=cannon()
예제 #5
0
def create_world():
    global boy,castle,select,boy2,boy3,Ecastle
    global daepo
    global User
    global backimage

    boy=[]
    boy2=[]
    boy3=[]
    castle=Castle()
    Ecastle=ECastle()
    select=Select()
    daepo=cannon()
    User=user()
    backimage=background()
예제 #6
0
    def nextState(self, action):
        response = self.scenario.nextState(action)
        if self.game_state == "Mountain":
            if "Forest" == response:
                self.game_state = "Forest"
                self.scenario = Forest()
            else:
                self.game_state = "Castle"
                self.scenario = Castle()

        elif self.game_state == "Forest":
            if "Town" == response:
                self.game_state = "Town"
                self.scenario = Town()

        elif self.game_state == "Castle":
            if "Town" == response:
                self.game_state = "Town"
                self.scenario = Town()
        else:
            #game_state is "town"
            pass
예제 #7
0
 def add_castle(self, x, y, is_big):
     self.castle = Castle(x, y, is_big)
예제 #8
0
    while projectile.pos[1] >= castle.pos[1]:
        physics.timestep(projectile)

        rel_pos.append(physics.distance(projectile, castle))

    scores = (2 - np.array(rel_pos)) / 2

    return max(scores) if len(rel_pos) > 0 else 0.0


ball = Projectile(2.0)

impulse = np.array([0.08, 0.05])

castle = Castle()

physics = Physics(0.001)

cannons = generateInitialPopulation(100)

for i in range(100):
    scores = []
    for cannon in cannons:
        scores.append(score(cannon))

    if i % 10 == 0:
        a = Visualiser(np.random.choice(cannons), ball.copy(), castle, physics)

        a.run()
def city(size=0, layout="castle", farms=False, buildings=False, streets=True, castle=True):
    # Testing location numbers
    mid_point = V3(30, 0, 120)

    if size > 0:
        mid1 = V3(mid_point.x - size, mid_point.y, mid_point.z - size)
        mid2 = V3(mid_point.x + size, mid_point.y, mid_point.z + size)
    else:
        mid1, mid2 = V3(0, 0, 60), V3(50, 0, 110)
        size = 25

    helpers.prep(size+20)

    print("Building zone and street-map using layout:", layout)
    if layout == "castle":
        all_zones = build_castle_streetmap(mid1, mid2, Map(min_x=20, min_z=20))
    else:
        all_zones = vg.partition(mid1, mid2, Map(minx=20, minz=20))
    print("-", len(all_zones), "zones identified")

    farm_zones = []
    building_zones = []
    castle_zone = False

    # Sort zones
    for zone in all_zones:
        if zone.width < 8 or zone.depth < 8:
            farm_zones.append(zone)
        else:
            building_zones.append(zone)

    print("-", len(farm_zones), " farm zones identified")

    # Make the largest zone a castle
    if not castle_zone:
        largest = 0
        largest_index = -1
        for i, zone in enumerate(building_zones):
            size = (zone.width * zone.depth) + min(zone.width, zone.depth) ** 2
            if size > largest:
                largest = size
                largest_index = i
                castle_zone = zone
        building_zones.pop(largest_index)

    print("-", len(building_zones), " building zones identified")
    print("- Castle size", castle_zone.width, "width by", castle_zone.depth, "depth by", castle_zone.height, "height")

    # Turn zones into creations
    s = Streets(all_zones, Map(style="blacktop"))
    f = Farmzones(farm_zones)
    n = Neighborhoods(building_zones)
    c = Castle(options=castle_zone)

    z = [all_zones, farm_zones, building_zones, castle_zone]

    # Build the creations
    if streets: s.build()
    if farms: f.build()
    if buildings: n.build()
    if castle: c.build()

    class Temp:
        def __init__(self, s, f, n, c, z):
            self.s = s
            self.f = f
            self.n = n
            self.c = c
            self.zones = z

        def clear(self):
            self.s.clear()
            self.f.clear()
            self.n.clear()
            self.c.clear()

    return Temp(s=s, f=f, n=n, c=c, z=z)
def test_c(size=0):
    # c = Castle(False, Map(p1=V3(0-size, -1, 90-size), p2=V3(60+size, -1, 150+size)))
    c = Castle(False, Map(p1=V3(0-size, -1, 90-size), p2=V3(60+size, -1, 150+size), window_style="open_slit_and_above"))
    print("Building Castle")
    c.build()
    return c
예제 #11
0
 def __init__(self, c, px, py):
     self.color = c
     self.posX = px
     self.posY = py
     self.first_move = True
     self.bishop = Bishop(self.color, px, py)
     self.castle = Castle(self.color, px, py)
     self.table = None
     self.material = 800
     if self.color == "W":
         self.string_rep = "QW"
     else:
         self.string_rep = "QB"
     self.available_moves = None
     self.attacking = None
     self.refresh_on_change_squares = None
     self.table = [
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
         0,
     ]
예제 #12
0
class Queen(Piece.Piece):
    def __init__(self, c, px, py):
        self.color = c
        self.posX = px
        self.posY = py
        self.first_move = True
        self.bishop = Bishop(self.color, px, py)
        self.castle = Castle(self.color, px, py)
        self.table = None
        self.material = 800
        if self.color == "W":
            self.string_rep = "QW"
        else:
            self.string_rep = "QB"
        self.available_moves = None
        self.attacking = None
        self.refresh_on_change_squares = None
        self.table = [
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
        ]

    def refresh_state(self, board):
        self.bishop.posX = self.posX
        self.castle.posX = self.posX
        self.bishop.posY = self.posY
        self.castle.posY = self.posY
        self.bishop.refresh_state(board)
        self.castle.refresh_state(board)
        self.available_moves = self.bishop.available_moves + self.castle.available_moves
        self.attacking = self.bishop.attacking + self.castle.attacking
        self.refresh_on_change_squares = self.bishop.refresh_on_change_squares + self.castle.refresh_on_change_squares