X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=snake.py;h=8a16f9f6bef6228def574f05730a19f1210dd875;hb=0cba1df2952a9f9b88b6e7aacfcddc17fbc35186;hp=7c3494167f9ff04450e13c178f6fec2dc01206a0;hpb=c951702f59f869c58d59b59f60a4931d890a13dc;p=picoclvr.git diff --git a/snake.py b/snake.py index 7c34941..8a16f9f 100755 --- a/snake.py +++ b/snake.py @@ -111,45 +111,22 @@ def solver(input, ar_mask): # print(f'@2 {i=} {j=}') +def seq2str(seq): + return "".join(["NESW123456789"[i] for i in seq]) + + ###################################################################### if __name__ == "__main__": - import cairo, numpy, math - - color_name2rgb = { - "red": [255, 0, 0], - "green": [0, 128, 0], - "blue": [0, 0, 255], - "yellow": [255, 255, 0], - "orange": [255, 128, 0], - "maroon": [128, 0, 0], - "dark_red": [139, 0, 0], - "brown": [165, 42, 42], - "firebrick": [178, 34, 34], - "crimson": [220, 20, 60], - "tomato": [255, 99, 71], - "coral": [255, 127, 80], - "indian_red": [205, 92, 92], - "light_coral": [240, 128, 128], - "dark_salmon": [233, 150, 122], - "salmon": [250, 128, 114], - } - - sequences, sequences_prior_visits, worlds, world_prior_visits = generate_sequences( - 8, 6, 8, 5, 20, 10 + train_input, train_prior_visits, _, _ = generate_sequences( + nb=20, + height=9, + width=12, + nb_colors=5, + length=50, + prompt_length=100, ) - delta = 16 - height, width = sequences.size(0) * 16, sequences.size(1) * 16 - pixel_map = torch.ByteTensor(width, height, 4).fill_(0).numpy() - surface = cairo.ImageSurface.create_for_data( - pixel_map, cairo.FORMAT_ARGB32, width, height - ) - ctx = cairo.Context(surface) - ctx.set_line_width(1.0) - - ctx.set_fill_rule(cairo.FILL_RULE_EVEN_ODD) - - ctx.fill() + print([seq2str(s) for s in train_input]) ######################################################################