コード例 #1
0
ファイル: __init__.py プロジェクト: fiedlr/golex
def run(dimensions, turns, terminal=1):
    """ Run a game with the chosen config - accessible through terminal """

    # Run the game
    game = Game(dimensions, turns, terminal)  # debug flag = 1
    strategy1 = Castle(game)
    strategy2 = Ship(game, "~")

    # Opposing strategies
    game.add_strategy(strategy1).add_strategy(strategy2)

    # Choose the board
    print("Welcome to Game of Life Extended (codename golex) v.", game.VERSION)
    print(
        "This game takes GoL to the next level by bringing 2 players (strategies) together and making them fight each other.\n"
    )

    # Start line
    print("Initial configuration with the chosen strategies (", strategy1.SIGN,
          ",", strategy2.SIGN, "):")

    # Set up the initial configuration
    game.build()

    # Make user see what's happening
    if terminal:
        input("Press Enter to continue")

    print("\nProceeding with the simulation...")

    # Iterate through the GoL algorithm
    game.run()

    winner = game.get_winner()

    print("Resulting board:")

    game.print_state()

    print()

    # Show the winner
    print("The winning strategy is '", winner, "'")

    # End line
    print()

    return winner
コード例 #2
0
ファイル: H_shooter.py プロジェクト: Pixdigit/h
from options import shooter as Options
from main import Game


Main = Game(Options, 'start')
Main.run()
コード例 #3
0
ファイル: osmos.py プロジェクト: MikeHibbert/Osmos-Clone
from main import Game

g = Game()

g.run()
コード例 #4
0
ファイル: osmos.py プロジェクト: MikeHibbert/Osmos-Clone
from main import Game

g = Game()

g.run()
コード例 #5
0
ファイル: stats.py プロジェクト: fiedlr/golex
""" golex v0.7 <github.com/fiedlr/golex> | (c) 2016 Adam Fiedler | <opensource.org/licenses/MIT> """

from main import Game
from strategies import *

# Winner container
winners = []

# Make 100 games
for i in range(100):
	game = Game([10, 20], 100, 0)
	strategies = [Ship(game), Castle(game)]
	# Opposing strategies
	game.add_strategy(strategies[0]).add_strategy(strategies[1])
	# Build
	game.build()
	# Run
	game.run()
	# Winner
	if game.get_winner() != None:
		winners.append(strategies.index(game.get_winner()))
	else:
		winners.append(-1)

print("Ship#1 wins:", winners.count(0), "Castle wins:", winners.count(1), "Draws:", winners.count(-1))
print("Ship chance of winning against castle: ", winners.count(0) / len(winners))
コード例 #6
0
ファイル: menu.py プロジェクト: hong718/pygameSnake
easy_button = Button(button_img, easy)
medium_button = Button(button_img, medium)
difficult_button = Button(button_img, difficult)
menu = True

while menu:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        pos = pygame.mouse.get_pos()
        if event.type == pygame.MOUSEBUTTONDOWN:
            # run the game with corresponding level when a button is clicked
            if easy_button.click(pos[0], pos[1], 240, 170, 1):
                g = Game(screen)
                g.run(1)
            elif medium_button.click(pos[0], pos[1], 240, 170, 2):
                g = Game(screen)
                g.run(2)
            elif difficult_button.click(pos[0], pos[1], 240, 170, 3):
                g = Game(screen)
                g.run(3)

    # draw the background
    screen.fill((0,0,0))
    screen.blit(screen, (0,0))

    # draw button
    easy_button.draw(screen,240, 170, 1)
    medium_button.draw(screen ,240, 170, 2)
    difficult_button.draw(screen, 240, 170, 3)