def run_water(zone, alias, minutes): with SessionLocal() as db: start_time = datetime.now() b = Board( ) # init a new board since tasks dont seem to have GPIO setup... b.register_flow() temperature = b.get_temp() db.add(Temperature(temperature)) db.commit() # moisture0 = board.read_analog_sensor(analog0) # moisture1 = board.read_analog_sensor(analog1) # moisture2 = board.read_analog_sensor(analog2) # moisture3 = board.read_analog_sensor(analog3) # sql_helper.insert_moistures(moisture0, moisture1, moisture2, moisture3) b.set_high(pins[zone]) time.sleep(minutes * 60) # sleep for our duration with the solenoid open b.set_low(pins[zone]) water_used = b.read_water_flow() db.add(Water(zone, alias, start_time, water_used)) db.commit() b.deregister_flow()
def job_download_board_from_config(self, config, reconfigure=False): self.configure(base_config, reconfigure) board = Board() board.configure(config) board.dispatch() self.links = board.get_links() self.download()
def __init__(self, data, dna, traits): self.game_id = data['game']['id'] self.turn = data['turn'] self.board = Board(data['board']) self.me = Snake(data['you']) # If no DNA is passed in, use the default values self.dna = [ int(dna or DEFAULT_DNA[i]) for i, dna in enumerate(dna.split('-')) ] if dna else DEFAULT_DNA self.traits = traits.split('-')
def __init__(self, input_data): """ Create the board. Make sure the initial_position is a valid move Add the initial_position to the path_history and set coins to 0 """ self.board = Board(*input_data.board_dimension, input_data.walls) if self.board.is_valid_move(*input_data.initial_position): self.the_pacman = ThePacman(*input_data.initial_position) else: raise PositionException( "The pacman can not be placed at the location: {}".format( input_data.initial_position)) self.movements = input_data.movements self.path_history = {input_data.initial_position} self.coins = 0
async def start(self): if not self.can_start(): await self.print_group( f"Игра отменена. Требуется минимум {Game.MIN_PLAYERS} игроков") self.app["events"].unsubscribe_callback(self.group_chat_id) for p in self.channels: self.app["events"].unsubscribe_callback(p.user_id, self) return await self.print_group(game_info["description"] + game_info["on_start_tip"]) if self.app["cfg"].DEBUG: self.channels = [{ "group_chat_id": self.group_chat_id, "user_id": 435627225, "user_fullname": "Дмитрий Калекин", "user_alert": "@herr_horror Дмитрий" }, { "group_chat_id": self.group_chat_id, "user_id": 435627225, "user_fullname": "Dmitriy Zaytsev", "user_alert": "@1" }, { "group_chat_id": self.group_chat_id, "user_id": 435627225, "user_fullname": "Zag", "user_alert": "@2" }, { "group_chat_id": self.group_chat_id, "user_id": 435627225, "user_fullname": "Александр Грицай", "user_alert": "@3" }] self.board = Board(self.channels) for p in self.board.players: assert type(p) == Player self.app["events"].subscribe_callback(p.user_id, self) await self.run()
def __init__(self): self.player1 = Player() self.player2 = Player() self.board_control = Board() self.game_board = self.board_control.game_board()
def test_data(rows=3, columns=3, row=2, column=6, start="4.5"): tour = Tour(rows, columns, start, verbosity=0) board = Board(rows, columns, tour.verbosity.verbose_int) position = Position(row, column, board, tour.verbosity.verbose_int) knight = Knight(position, tour.verbosity.verbose_int) return tour, board, position, knight
from app.board import Board print("""Welcome to Plinko! This tool was made as an analyzer to determine which slot on the Plinko board will yield the highest return. Basic instructions are simple: Drop a chip into a slot at the top of the Plinko board, and see where it lands. At each row down through the board, the chip will either go to the left of the peg or to the right. Here is an example of a Plinko board """) print() b = Board() b.print_board() print() print("""As you can see at the bottom of the board, there are five different options for what payout you can receive. They are: Small: $100 Medium: $500 Large: $1000 Grand Prize: $10000 Blank Space: $0 Get started! Find out which slot will be your best bet.""")
from flask import Flask, _app_ctx_stack from app.config import Config from flask_wtf.csrf import CSRFProtect from flask_bootstrap import Bootstrap from celery import Celery from app.board import Board from sqlalchemy.orm import scoped_session from .database import SessionLocal, engine app = Flask(__name__) app.config.from_object(Config) app.session = scoped_session(SessionLocal, scopefunc=_app_ctx_stack.__ident_func__) csrf = CSRFProtect(app) bootstrap = Bootstrap(app) celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL']) celery.conf.update(app.config) board = Board() from app import routes
def setUp(self): self.board = Board()