I figured I'd throw some Python together to generate levels for you to test your RR solver with and so here it is! Frankly it's a bit lame but does use the same pattern that the existing challenges use to give the grid dimension and minimum+maximum moves so might be of interest if you wanted to use the same method for whatever sadistic reason.
Code: Select all
# resulting levels will have over 2^30 tiles by level 2,147,483,642
def methodA(n):
dimension = (n//2) + 3
minimum = n//6 + 2
maximum = n//24*7 + (1,1,2,2,2,2,3,3,3,3,4,4,5,5,5,5,5,5,7,7,7,7,7,7)[n%24]+1
return (dimension,minimum,maximum)
# resulting levels will have over 2^30 tiles by level 1067
def methodB(n):
dimension = 253 + int(30.5*n)
minimum = 65 + int(61*(n+2)/6)
maximum = 165 + (n-1)//11*196 + (0,18,36,54,72,90,107,125,142,161,179)[(n-1)%11]
return (dimension,minimum,maximum)
methodA is employed on levels 1 to 500 and
methodB works for 501-514 (n at 501 = 1) and maybe beyond but there isn't much to go on. As the comments show; methodB gets unmanageable rather quickly when compared to methodA.
The following code generates a random matrix then clears a path through it:
Code: Select all
from random import *
def generate(info):
dim,min,max = info
matrix = [[ choice(('.','X')) for tile in range(dim)] for row in range(dim)]
path = ''.join([ choice(('R','D')) for step in range(randint(min,max))])
x = y = pos = 0
while x < dim and y < dim:
matrix[y][x] = '.'
if path[pos % len(path)] == 'R': x +=1
else: y += 1
pos += 1
return ''.join([''.join(row) for row in matrix])
Finally this last bit uses the above code generate levels that resemble the online level, these levels are then passed to a solver but you'd probably want to change it a bit if you were to ever use it (aside from
Solver.exe to your program name):
Code: Select all
from os import system
def useFVString(s):
system("Solver.exe %s"%(s))
level = 1
while level <= 500:
info = methodA(level)
FVString = "FVterrainString=%s&FVinsMax=%i&FVinsMin=%i&FVboardX=%i&FVboardY=%i&FVlevel=%i"%(generate(info),info[2],info[1],info[0],info[0],level)
useFVString(s)
level += 1
while True:
info = methodB(level-500)
FVString = "FVterrainString=%s&FVinsMax=%i&FVinsMin=%i&FVboardX=%i&FVboardY=%i&FVlevel=%i"%(generate(info),info[2],info[1],info[0],info[0],level)
useFVString(s)
level += 1
All work and no play makes Ollie a dull boy.