<commit_before>import argparse
import os.path
import random

import subjunctive
from subjunctive.grid import Grid, left, right, up, down

subjunctive.resource.add_path(os.path.dirname(__file__))

class Block(subjunctive.entity.Entity):
    pass

class Player(subjunctive.entity.Entity):
    image = subjunctive.resource.image('images/tile-current.png')

class Tile(subjunctive.entity.Entity):
    image_active = subjunctive.resource.image('images/tile-active.png')
    image_inactive = subjunctive.resource.image('images/tile-inactive.png')

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.active = False

    @property
    def image(self):
        return self.image_active if self.active else self.image_inactive

    def push(self, direction, pusher=None):
        if not self.active:
            self.world.swap(self, pusher)
            self.active = True
            check_win(world)

class World(subjunctive.world.World):
    grid = subjunctive.grid.Grid(25, 25)
    tile_size = (16, 16)
    window_title = "Floorpaint"

def check_win(world):
    if all(e.active for e in world.entities if isinstance(e, Tile)):
        print ('YOU WON')

def generate_level(width, height):
    spaces = {(x, y): False for x in range(width) for y in range(height)}
    x, y = 0, 0
    spaces[x, y] = True
    keepgoing = True
    num_steps = 0
    s = set()
    while keepgoing:
        choice_dir = random.choice(['down', 'up', 'right', 'left'])
        old_num_steps = num_steps
        s.add(choice_dir)
        if choice_dir == 'down':
            for i in range(random.randint(1, height / 2)):
                if y + 1 < height and spaces[x, y + 1] == False:
                    num_steps += 1
                    y += 1
                    spaces[x, y] = True
        elif choice_dir == 'up':
            for i in range(random.randint(1, height / 2)):
                if y - 1 > 0 and spaces[x, y - 1] == False:
                    num_steps += 1<commit_msg>Floorpaint World now has property "complete"<commit_after>import argparse
import os.path
import random

import subjunctive
from subjunctive.grid import Grid, left, right, up, down

subjunctive.resource.add_path(os.path.dirname(__file__))

class Block(subjunctive.entity.Entity):
    pass

class Player(subjunctive.entity.Entity):
    image = subjunctive.resource.image('images/tile-current.png')

class Tile(subjunctive.entity.Entity):
    image_active = subjunctive.resource.image('images/tile-active.png')
    image_inactive = subjunctive.resource.image('images/tile-inactive.png')

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.active = False

    @property
    def image(self):
        return self.image_active if self.active else self.image_inactive

    def push(self, direction, pusher=None):
        if not self.active:
            self.world.swap(self, pusher)
            self.active = True
            if world.complete:
                print ("YOU WON")

class World(subjunctive.world.World):
    grid = subjunctive.grid.Grid(25, 25)
    tile_size = (16, 16)
    window_title = "Floorpaint"

    @property
    def complete(self):
        if all(e.active for e in world.entities if isinstance(e, Tile)):
            return True
        else:
            return False

def generate_level(width, height):
    spaces = {(x, y): False for x in range(width) for y in range(height)}
    x, y = 0, 0
    spaces[x, y] = True
    keepgoing = True
    num_steps = 0
    s = set()
    while keepgoing:
        choice_dir = random.choice(['down', 'up', 'right', 'left'])
        old_num_steps = num_steps
        s.add(choice_dir)
        if choice_dir == 'down':
            for i in range(random.randint(1, height / 2)):
                if y + 1 < height and spaces[x, y + 1] == False:
                    num_steps += 1
                    y += 1
                    spaces[x, y] = True
        elif choice_dir == 'up':
            for i in range(random.randint(1, height / 2)):
                if y - 1 > 0 and spaces[x, y - 1] == False:
                    num_steps += 1
{'fraction_non_alphanumeric': 0.11778962675714978, 'fraction_numerical': 0.011148812409112942, 'mean_word_length': 2.3336025848142166, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2110541', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1271, 'n_words': 343}