--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+our $TileGroups =
+[
+ [1001, 1002], # forest gras
+ [1005, 1006], # forest stones top
+ [1008, 1012], # forest stones left
+ [1009, 1013, 1014], # forest stones fill
+ [1011, 1015], # forest stones right
+ [1017, 1018], # forest stones bottom
+ [2058, 2060, 2061, 2065, 2066, 2070], # ice tiles
+ [2179, 2180, 2181, 2187, 2188, 2189, 2195, 2196, 2197], # snow bg
+ [2171, 2172, 2175, 2176] # those other snow thingies
+];
+our $TileMap = {};
+
+sub init
+{
+ for (@$TileGroups)
+ {
+ my $group = $_;
+
+ for (@$group)
+ {
+ my $id = $_;
+
+ $TileMap->{$id} = $group;
+ }
+ }
+} # init
+
+sub get_random
+{
+ my $id = shift;
+ my $group;
+ my $group_size;
+
+ if (!$TileMap->{$id})
+ {
+ return ($id);
+ }
+
+ $group = $TileMap->{$id};
+ $group_size = 0 + @$group;
+
+ return ($group->[int (rand ($group_size))]);
+}
+
+if (-t STDIN)
+{
+ print STDERR "Usage: ./tile_randomizer.px <in_file >out_file\n";
+ exit (1);
+}
+
+init ();
+
+while (<>)
+{
+ my $line = $_;
+ chomp ($line);
+
+ if ($line =~ m/[^\s\d]/)
+ {
+ print "$line\n";
+ next;
+ }
+
+ $line =~ s/\b([1-9][0-9]{0,3})\b/get_random ($1)/ge;
+
+ print "$line\n";
+}
+
+exit (0);