try:
    import bext
except ImportError:
    print("""This program requires the bext module, which you can install by
opening a Terminal window (on macOS & Linux) and running:

    python3 -m pip install --user bext

or a Command Prompt window (on Windows) and running:

    python -m pip install --user bext""")
    sys.exit()

bext.clear()
WIDTH, HEIGHT = bext.size()
WIDTH -= 1  # Reduce width by 1 because of a weird Windows behavior.
NUMBER_OF_POINTS = 4
COLORS = ('red', 'green', 'yellow', 'blue', 'purple', 'cyan', 'white')
DIRECTIONS = ('upright', 'upleft', 'downright', 'downleft')
LINE_CHAR = '#'


def main():
    # Generate some points.
    points = []
    for i in range(NUMBER_OF_POINTS):
        points.append({
            'x': random.randint(1, WIDTH - 2),
            'y': random.randint(1, HEIGHT - 2),
            'direction': random.choice(DIRECTIONS)
Example #2
0
import bext
import random

MIN_X_INCREASE = 6
MAX_X_INCREASE = 16
MIN_Y_INCREASE = 3
MAX_Y_INCREASE = 6
WHITE = 'white'
BLACK = 'black'
RED = 'red'
YELLOW = 'yellow'
BLUE = 'blue'

# Setup the screen:
width, height = bext.size()
width -= 1  # TODO Windows bug
height -= 2

# Pre-populate the board with blank spaces:
board = {}
for x in range(width):
    for y in range(height):
        board[(x, y)] = WHITE

# Generate vertical lines:
numberOfSegmentsToDelete = 0
x = random.randint(MIN_X_INCREASE, MAX_X_INCREASE)
while x < width - MIN_X_INCREASE:
    numberOfSegmentsToDelete += 1
    for y in range(height):