Last active
April 27, 2017 08:03
-
-
Save SuperSpyTX/5d05454aad079790963ccd3f44d128fc to your computer and use it in GitHub Desktop.
BSQ Trainer BETA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "BSQ Trainer v0.1 - by jkrause" | |
rm -f t1 t2 test2 | |
echo "" > t1 | |
echo "" > t2 | |
CMD="" | |
while [[ ! $(diff t1 t2) ]]; | |
do | |
python trainer.py $1 > test2 | |
./bsq_ref test2 > t1 | |
../bsq test2 > t2 | |
done | |
echo "Edge case failed!\n" | |
cat test2 | head -n 1 | |
diff t1 t2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import string | |
import random | |
import sys | |
import os | |
def eprint(args): | |
print(args, file=sys.stderr) | |
vars = os.environ | |
def random_char_letters(y): | |
return ''.join(random.choice(string.ascii_letters) for x in range(y)) | |
def random_char_numbers(y): | |
return ''.join(random.choice(string.digits) for x in range(y)) | |
def random_char_symbols(y): | |
return ''.join(random.choice(string.printable) for x in range(y)) | |
def make_bsq(rows, columns, empty, obstacle, match): | |
# This is because it would then be an invalid map. | |
if (rows == 0): | |
rows = 1 | |
elif (rows == -1): | |
rows += 1 | |
if (columns == 0): | |
columns = 1 | |
elif (columns == -1): | |
columns += 1 | |
map = "" | |
map += str(rows) + str(empty) + str(obstacle) + str(match) | |
map += '\n' | |
for i in range(0, rows): | |
for j in range(0, columns): | |
if (random.randint(1, 10) % 2): | |
map += obstacle | |
else: | |
map += empty | |
map += '\n' | |
map = map[:-1] | |
return map | |
if len(sys.argv) > 1: | |
if (sys.argv[1] == "0"): | |
print (make_bsq(random.randint(-1, 0), random.randint(-1, 0), '.', 'o', 'x')) | |
if (sys.argv[1] == "1"): | |
print(make_bsq(int(random_char_numbers(1)), int(random_char_numbers(1)), '.', 'o', 'x')) | |
if (sys.argv[1] == "2"): | |
print(make_bsq(int(random_char_numbers(1)), int(random_char_numbers(1)), random_char_letters(1), random_char_letters(1), random_char_letters(1))) | |
if (sys.argv[1] == "3"): | |
print(make_bsq(int(random_char_numbers(2)), int(random_char_numbers(2)), random_char_letters(1), random_char_letters(1), random_char_letters(1))) | |
if (sys.argv[1] == "4"): | |
print(make_bsq(int(random_char_numbers(2)), int(random_char_numbers(2)), random_char_symbols(1), random_char_symbols(1), random_char_symbols(1))) | |
if (sys.argv[1] == "5"): | |
print(make_bsq(int(random_char_numbers(3)), int(random_char_numbers(3)), random_char_symbols(1), random_char_symbols(1), random_char_symbols(1))) | |
if (sys.argv[1] == "6"): | |
print(make_bsq(int(random_char_numbers(4)), int(random_char_numbers(4)), random_char_symbols(1), random_char_symbols(1), random_char_symbols(1))) | |
else: | |
print("BSQ Trainer v0.1 - Usage: " + sys.argv[0] + " <level>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment