def main(): _, settings, _, _, _ = pycraft.setup() save = pycraft.saves.new_save({'name': 'test', 'seed': 'This is a test!'}) try: pycraft.game(pycraft.server_interface.LocalInterface('tester', save, 0), settings) finally: pycraft.setdown()
def main(): _, settings, _, _, benchmarks, _, _ = pycraft.setup() pycraft.render_interface.setup_render_module(settings) save = pycraft.saves.new_save({'name': 'test', 'seed': 'This is a test!'}) server_obj = pycraft.server_interface.LocalInterface('tester', save, 0, settings) try: pycraft.game(server_obj, settings, benchmarks) finally: pycraft.setdown()
def main(): _, settings, _, _, benchmarks, _, _ = pycraft.setup() pycraft.render_interface.setup_render_module(settings) save = pycraft.saves.new_save({'name': 'test', 'seed': 'This is a test!'}) server_obj = pycraft.server_interface.LocalInterface( 'tester', save, 0, settings) try: pycraft.game(server_obj, settings, benchmarks) finally: pycraft.setdown()
def web_send(): if request.args.get('submit_button') == "ROLL": first_value, second_value, third_value = main.values_generator() first_url, second_url, third_url = main.value_to_url( first_value, second_value, third_value) info = main.get_info() # получаем информацию из файла credit, bet = int(info["credit"]), int( request.args.get('bet')) # определяем переменные Баланса и Ставки bonus = main.bonus(first_value, second_value, third_value) # расчитываем бонус win = main.game(bet, bonus) # определяем размер выигрыша info["credit"] = str( (credit - bet) + win) # расчитываем новое значение Баланса info["bet"] = str(bet) main.write_info(info) # записываем информацию в файл image_1 = url_for('static', filename=first_url) image_2 = url_for('static', filename=second_url) image_3 = url_for('static', filename=third_url) return render_template(INDEX_PATH, image_1=image_1, image_2=image_2, image_3=image_3, credit=info["credit"], bet=bet, win=win)
def new_game_app(): text = '''Cubes. The Game. -------------------- New Game -------------------- [1] Start [0] Back -------------------- *use numerals for select context menu*''' print(text) statement = int(input()) if statement == 0: menu_app() else: main.game() menu_app()
def __init__(self, handle): activity.Activity.__init__(self, handle) self.max_participants = 1 self.actividad = main.game() self.build_toolbar() self._pygamecanvas = sugargame.canvas.PygameCanvas(self) self.set_canvas(self._pygamecanvas) self._pygamecanvas.grab_focus() self._pygamecanvas.run_pygame(self.actividad.make)
def __init__(self, handle): activity.Activity.__init__(self, handle) self.max_participants = 1 self.sound = True self.game = main.game() self.game.canvas = sugargame.canvas.PygameCanvas(self, main=self.game.make, modules=[pygame.display, pygame.font]) self.set_canvas(self.game.canvas) self.game.canvas.grab_focus() self.build_toolbar()
def test_game(self): """tests on the main.game() function""" self.assertIsNone(game(nb_plays=100, nb_bandits=10)) # Example for tests test_data = Result("Test data") test_data[0] = greedy test_data[0.1] = egreedy_0_1 drawMock = Mock(draw) drawMock(test_data) self.assertTrue(drawMock.called)
def __init__(self, handle): activity.Activity.__init__(self, handle) self.max_participants = 1 self.sound = True self.game = main.game() self.game.canvas = sugargame.canvas.PygameCanvas( self, main=self.game.make, modules=[pygame.display, pygame.font]) self.set_canvas(self.game.canvas) self.game.canvas.grab_focus() self.build_toolbar()
def test_game(team, team2): main.game(team, team2) assert team.home_games == 1 assert team2.away_games == 1 assert team.away_games == 0 assert team2.home_games == 0 assert team.schedule_opponents == ['Test2'] assert team2.schedule_opponents == ['Test'] assert team.wins + team2.wins == 1 assert team.losses + team2.losses == 1 main.game(team2, team) assert team.home_games == 1 assert team2.home_games == 1 assert team.away_games == 1 assert team2.away_games == 1 assert team.schedule_opponents == ['Test2', 'Test2'] assert team2.schedule_opponents == ['Test', 'Test'] assert team.wins + team2.wins == 2 assert team.losses + team2.losses == 2
def controller(): env = game() env.reset() while True: keys = pg.key.get_pressed() action = [0, 0, 0, 0] if keys[pg.K_LEFT]: action[0] = 1 if keys[pg.K_RIGHT]: action[1] = 1 if keys[pg.K_UP]: action[2] = 1 if keys[pg.K_SPACE]: action[3] = 1 observation, reward, done, score = env.run(action) env.draw() if done: break
import random import numpy as np import tensorflow as tf from main import Game as game from tensorflow import keras env = game() env.reset() goal_steps = 1000 prev_observation = [] model = keras.models.load_model('models/model_gen_8') for _ in range(goal_steps): action = [0, 0, 0, 0] if len(prev_observation) == 0: for a in range(0, len(action)): action[a] = random.choice([0, 1]) else: pred = np.argmax(model.predict(prev_observation)) action[pred] = 1 new_observation, reward, done, info = env.run(action) prev_observation = np.array([new_observation]) env.draw() if done: break
def test_game_raise_ValueError(self, nt, input): m.I.time_left = 0 self.assertRaises(ValueError, m.game())
def ttest_standard_game(self): #-- When we create and standard game should be 10 frames -- new_game = main.game() assert len(new_game)==10
def ttest_5_balls_per_frame(self): new_game = main.game(3,5) for frame in range(len(new_game)): assert len(new_game[frame]) >= 5
def ttest_balls_per_frame(self): #-- Test every frame has 2 played balls -- new_game = main.game(3,2) for frame in range(len(new_game)): assert len(new_game[frame]) >= 2
def __init__(): game(0)
RED_RECEIVE_ADDR = (RED_RECEIVE, RED_RECEIVE_PORT) red_connect = socket.socket(socket.AF_INET, socket.SOCK_STREAM) red_send = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def Handle_Requests(conn, adr): while True: message = conn.recv(100).decode() if len(message) == 1: col = int(message) red.board[col][red.row[col]] = 2 red.row[col] -= 1 red.turn = True def establish_connection(): global red_connect, red_send print("Wating for player") red_connect.bind(RED_RECEIVE_ADDR) red_connect.listen() (conn, addr) = red_connect.accept() red_send.connect(RED_SEND_ADDR) t = threading.Thread(target=Handle_Requests, args=(conn, addr)) t.start() establish_connection() print("CONNECTED") red.turn = True red.game(0, red_send)
import numpy as np import matplotlib.pyplot as plt from main import game H = np.array(game(30, 2**15, 15)) fig = plt.figure(figsize=(13, 6.2)) ax = fig.add_subplot(111) ax.matshow(H, cmap=plt.cm.Blues) plt.show()
def test_game_correct(self, nt, input): m.game() self.assertEqual(m.I.points, 1)
from main import game from player import Player if __name__ == "__main__": print("run.py is being run directly") else: print("run.py is being imported into another module") #instantiating another objects to save the money human_money = Player([], 30, 0) bot_money = Player([], 30, 0) while human_money.credits > 0 and bot_money.credits > 0: bid = int(input("\n\nDigit your bid:")) if game(): #if human wins print('\n------------Credits------------------') human_money.credits += bid bot_money.credits -= bid print('Human credits {}'.format(human_money.credits)) print('PC credits {}'.format(bot_money.credits)) print('--------------------------------------') wait = input( "-------------PRESS ENTER TO CONTINUE TO NEXT ROUND------------------------." ) print( '\n\n\n\n\n----------------------STARTING A NEW ROUND---------------------' ) else: #if pc wins
import pygame,sys from pygame.locals import* import main from board import * pygame.init() displaysurf.fill(white) all_items.draw(displaysurf) main.game()
YELLOW_SEND_ADDR = (YELLOW_SEND, YELLOW_SENT_PORT) YELLOW_RECEIVE_ADDR = (YELLOW_RECEIVE, YELLOW_RECEIVE_PORT) yellow_send = socket.socket(socket.AF_INET, socket.SOCK_STREAM) yellow_connect = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def Handle_Requests(conn, addr): while True: message = conn.recv(100).decode() if len(message) == 1: col = int(message) yellow.board[col][yellow.row[col]] = 1 yellow.row[col] -= 1 yellow.turn = True def establish_connection(): global yellow_send, yellow_connect yellow_send.connect(YELLOW_SEND_ADDR) yellow_connect.bind(YELLOW_RECEIVE_ADDR) yellow_connect.listen() (conn, addr) = yellow_connect.accept() t = threading.Thread(target=Handle_Requests, args=(conn, addr)) t.start() establish_connection() print("CONNECTED") yellow.turn = False yellow.game(1, yellow_send)
from main import game if __name__ == "__main__": game()
def test_creation_frames_per_game(self): #-- Test creation of frames per game -- new_game = main.game(5) assert len(new_game)==5