Lamapi commited on
Commit
394a40d
·
verified ·
1 Parent(s): 2a4514e

Release Next-Reward with checkpoint and illustrated evaluation

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/five-routing-tests.png filter=lfs diff=lfs merge=lfs -text
10_Next_Reward.ipynb ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 5,
4
+ "metadata": {
5
+ "kernelspec": {
6
+ "name": "python3",
7
+ "display_name": "Python 3",
8
+ "language": "python"
9
+ }
10
+ },
11
+ "cells": [
12
+ {
13
+ "cell_type": "markdown",
14
+ "metadata": {},
15
+ "id": "c949dc6e",
16
+ "source": [
17
+ "# Next Reward · Eğitim, test ve Hugging Face yayını\n",
18
+ "CPU oturumu yeterli. Son hücreyi çalıştırınca model ve değerlendirme dosyaları özel depoya yüklenir."
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "code",
23
+ "metadata": {},
24
+ "id": "73b262f4",
25
+ "source": [
26
+ "from pathlib import Path\n",
27
+ "import tempfile, subprocess, sys\n",
28
+ "folder=Path(tempfile.mkdtemp(prefix='next-reward-'))\n",
29
+ "assets={'experiment.py': '\"\"\"Train a model of grid transitions and evaluate policies on disjoint layouts.\"\"\"\\nimport argparse\\nimport hashlib\\nimport json\\nimport random\\nfrom collections import deque\\nfrom pathlib import Path\\nimport numpy as np\\nfrom next_reward import MOVES, NextReward\\n\\nORIGINAL=(\".....\",\".X...\",\".X...\",\"...X.\",\"....G\")\\n\\ndef key(board):\\n return hashlib.sha256(\"\\\\n\".join(board).encode()).hexdigest()\\n\\ndef generate(rng,n,wall=.20):\\n cells=rng.choices(\".#X\",weights=[1-wall-.1,wall,.1],k=n*n)\\n cells[rng.randrange(n*n)]=\"G\"\\n return tuple(\"\".join(cells[i:i+n]) for i in range(0,n*n,n))\\n\\ndef advance(b,pos,a):\\n y,x=pos\\n r,c=y+MOVES[a][0],x+MOVES[a][1]\\n if not (0<=r<len(b) and 0<=c<len(b[0])) or b[r][c]==\"#\": return pos\\n return r,c\\n\\ndef starts(b):\\n return [(i,j) for i,row in enumerate(b) for j,ch in enumerate(row) if ch==\".\"]\\n\\ndef train(seed):\\n rng=random.Random(seed)\\n counts=np.zeros((16,4,5),int)\\n sums=np.zeros(3); freq=np.zeros(3,int)\\n layouts=set()\\n for _ in range(650):\\n b=generate(rng,rng.choice([5,6,7]),rng.uniform(.10,.45))\\n if key(b)==key(ORIGINAL) or key(b) in layouts:continue\\n layouts.add(key(b))\\n places=starts(b)\\n if not places: continue\\n for _ in range(100):\\n p=rng.choice(places)\\n mask=sum(1<<i for i in range(4) if advance(b,p,i)==p)\\n a=rng.randrange(4)\\n q=advance(b,p,a)\\n counts[mask,a,MOVES.index((q[0]-p[0],q[1]-p[1]))]+=1\\n event=\".GX\".index(b[q[0]][q[1]])\\n sums[event]+=(-.02,1.,-1.)[event]\\n freq[event]+=1\\n return NextReward(counts,sums/freq),layouts\\n\\ndef distances(b):\\n goal=next((i,row.index(\"G\")) for i,row in enumerate(b) if \"G\" in row)\\n d={goal:0}; queue=deque([goal])\\n while queue:\\n p=queue.popleft()\\n for a in range(4):\\n q=advance(b,p,a)\\n if q not in d and b[q[0]][q[1]]==\\'.\\':\\n d[q]=d[p]+1\\n queue.append(q)\\n return goal,d\\n\\ndef play(b,p,policy):\\n seen=set()\\n while p not in seen:\\n seen.add(p)\\n q=advance(b,p,int(policy[p]))\\n if b[q[0]][q[1]]==\"G\":return len(seen)\\n if b[q[0]][q[1]]==\"X\":return None\\n p=q\\n return None\\n\\ndef evaluate(model,boards):\\n totals=dict(maps=len(boards),reachable=0,unreachable=0,success=0,shortest=0,greedy_success=0)\\n for b in boards:\\n goal,d=distances(b)\\n pi=model.policy(b); greedy=np.zeros(pi.shape,int)\\n for p in starts(b):\\n # One-step Manhattan baseline with access to visible pits and walls.\\n def score(a):\\n q=advance(b,p,a)\\n if q==p or b[q[0]][q[1]]==\"X\":return float(\"inf\")\\n return abs(q[0]-goal[0])+abs(q[1]-goal[1])\\n greedy[p]=min(range(4),key=score)\\n for p in starts(b):\\n if p not in d:\\n totals[\"unreachable\"]+=1;continue\\n totals[\"reachable\"]+=1\\n steps=play(b,p,pi)\\n totals[\"success\"]+=steps is not None\\n totals[\"shortest\"]+=steps==d[p]\\n totals[\"greedy_success\"]+=play(b,p,greedy) is not None\\n return totals\\n\\ndef main(out):\\n out.mkdir(parents=True,exist_ok=True)\\n results=[]\\n trained=[train(seed) for seed in (73,101,149)]\\n seen=set.union(*(layouts for _,layouts in trained))\\n seen.add(key(ORIGINAL))\\n suites={\"original\":[ORIGINAL]}\\n rng=random.Random(8901)\\n for n in (5,8,12):\\n boards=[]\\n while len(boards)<40:\\n board=generate(rng,n)\\n if key(board) not in seen:\\n seen.add(key(board));boards.append(board)\\n suites[str(n)]=boards\\n for seed,(model,layouts) in zip((73,101,149),trained):\\n if seed==73:\\n model.save(out/\\'model.json\\')\\n restored=NextReward.load(out/\\'model.json\\')\\n for boards in suites.values():\\n for b in boards: np.testing.assert_array_equal(model.policy(b),restored.policy(b))\\n model=restored\\n result=dict(seed=seed,train_maps=len(layouts),transitions=int(model.counts.sum()),\\n suites={k:evaluate(model,v) for k,v in suites.items()})\\n results.append(result)\\n print(seed,result[\"suites\"],flush=True)\\n (out/\\'evaluation.json\\').write_text(json.dumps(results,indent=2))\\n (out/\\'test_maps.json\\').write_text(json.dumps(suites,indent=1))\\nif __name__==\"__main__\":\\n parser=argparse.ArgumentParser()\\n parser.add_argument(\"--output\",type=Path,default=Path(\".\"))\\n main(parser.parse_args().output)\\n\\n', 'next_reward.py': '\"\"\"Inference for Next Reward. Boards use . (floor), # (wall), X (pit), G (goal).\"\"\"\\nimport json\\nfrom pathlib import Path\\nimport numpy as np\\n\\nMOVES = ((1,0),(0,1),(-1,0),(0,-1),(0,0))\\nACTIONS = (\"down\",\"right\",\"up\",\"left\")\\n\\ndef geometry(board):\\n if not board or not board[0] or any(len(row)!=len(board[0]) for row in board):\\n raise ValueError(\"Expected a nonempty rectangular board\")\\n if sum(row.count(\"G\") for row in board)!=1 or any(set(row)-set(\".X#G\") for row in board):\\n raise ValueError(\"Use exactly one G and symbols . # X\")\\n grid=np.array([list(row) for row in board])\\n h,w=grid.shape\\n y,x=np.indices((h,w))\\n dest=[]\\n mask=np.zeros((h,w),dtype=int)\\n for i,(dy,dx) in enumerate(MOVES):\\n ny,nx=y+dy,x+dx\\n blocked=(ny<0)|(ny>=h)|(nx<0)|(nx>=w)|(grid[ny.clip(0,h-1),nx.clip(0,w-1)]==\"#\")\\n if i<4: mask |= blocked.astype(int)<<i\\n dest.append(np.where(blocked,y*w+x,ny*w+nx))\\n return grid,mask,np.stack(dest,axis=-1)\\n\\nclass NextReward:\\n def __init__(self,counts,rewards):\\n counts=np.asarray(counts,dtype=float)\\n self.rewards=np.asarray(rewards,dtype=float)\\n if counts.shape!=(16,4,5) or not np.isfinite(counts).all() or np.any(counts<0) or np.any(counts.sum(-1)==0):\\n raise ValueError(\"Missing or invalid transition counts\")\\n if self.rewards.shape!=(3,) or not np.isfinite(self.rewards).all():\\n raise ValueError(\"Invalid learned rewards\")\\n self.counts=counts\\n self.prob=counts/counts.sum(-1,keepdims=True)\\n\\n @classmethod\\n def load(cls,path):\\n d=json.loads(Path(path).read_text())\\n if d[\"format\"]!=\"next-reward-v1\": raise ValueError(\"Unsupported model format\")\\n return cls(d[\"counts\"],d[\"rewards\"])\\n\\n def save(self,path):\\n Path(path).write_text(json.dumps(dict(format=\"next-reward-v1\",counts=self.counts.astype(int).tolist(),\\n rewards=self.rewards.tolist()),indent=1))\\n\\n def policy(self,board):\\n grid,mask,dest=geometry(board)\\n reward=np.where(grid==\"G\",self.rewards[1],np.where(grid==\"X\",self.rewards[2],self.rewards[0]))\\n value=np.zeros(grid.shape)\\n for _ in range(grid.size+1):\\n outcomes=(reward+0.98*value).ravel()[dest]\\n q=np.einsum(\"ijak,ijk->ija\",self.prob[mask],outcomes)\\n updated=np.where(grid==\".\",q.max(-1),0.)\\n if np.max(np.abs(updated-value))<1e-12: break\\n value=updated\\n return np.where(grid==\".\",q.argmax(-1),-1)\\n\\n', 'README.md': '---\\ntags:\\n- reinforcement-learning\\n- model-based-rl\\n- gridworld\\n- numpy\\nlanguage:\\n- en\\n---\\n\\n# Next Reward\\n\\nNext Reward learns a transition table and reward values from simulated grid moves. Given a visible map, it computes a new policy by value iteration. One JSON checkpoint runs on CPU with NumPy.\\n\\n## Try the checkpoint\\n\\nDownload the repository files into one directory and run this Python snippet there.\\n\\n~~~python\\nfrom next_reward import NextReward, ACTIONS\\n\\nboard = (\".....\", \".X...\", \".X...\", \"...X.\", \"....G\")\\nagent = NextReward.load(\"model.json\")\\npolicy = agent.policy(board)\\nprint(ACTIONS[policy[0, 0]])\\n~~~\\n\\nCoordinates are (row, column). Each dot is a valid starting cell. A wall (#) blocks movement. Entering a pit (X) or the goal (G) ends the episode. Policy entries for terminal cells and walls are -1.\\n\\n## What it learns\\n\\nTraining samples random state-action transitions on 5×5, 6×6 and 7×7 procedural maps. The model estimates displacement frequencies for four actions under sixteen neighboring wall patterns and mean rewards for three destination types. Inference uses the map geometry, known terminal types, those learned estimates, and a discount of 0.98. The exported checkpoint uses the prespecified training seed 73.\\n\\n## Held-out evaluation\\n\\nAll three training seeds (73, 101, 149) were evaluated on the same 120 new layouts. Test maps were excluded from all three training sets by content hash. Every reachable floor cell was used as a start. BFS supplied the shortest-path reference during scoring. The greedy baseline picks the safe neighboring cell closest to the goal by Manhattan distance, breaking ties by action order.\\n\\n| Map size | Maps | Reachable starts | Agent reached goal on a shortest path | Greedy reached goal |\\n|---|---:|---:|---:|---:|\\n| 5×5 | 40 | 569 | 569 | 474 |\\n| 8×8 | 40 | 1,417 | 1,417 | 927 |\\n| 12×12 | 40 | 3,373 | 3,373 | 1,555 |\\n\\nCounts are per training seed. All three produced the same scores. Another 1,122 floor cells had no path to the goal and were counted separately. The original demo layout was scored separately at 21/21 for both methods.\\n\\nThis task assumes a fully visible static grid and deterministic motion. The evaluation covers rearranged layouts under the same movement rules. Real-world navigation, changing obstacles, partial observations and stochastic actuators are outside the measured scope.\\n\\n## Reproduce\\n\\nRun `python experiment.py --output run` to train and score three seeds. The command writes a reloadable checkpoint, per-seed metrics and the exact test layouts. It checks that serialization preserves the exported policy on every evaluation board. The Colab notebook includes training, inference and an optional Hugging Face upload cell.\\n\\n', 'requirements.txt': 'numpy>=1.24\\n'}\n",
30
+ "for name,content in assets.items():\n",
31
+ " (folder/name).write_text(content,encoding='utf8')\n",
32
+ "subprocess.run([sys.executable,'experiment.py','--output','.'],cwd=folder,check=True)\n",
33
+ "print(folder)"
34
+ ],
35
+ "outputs": [],
36
+ "execution_count": null
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "metadata": {},
41
+ "id": "b6eeb3d8",
42
+ "source": [
43
+ "import json\n",
44
+ "sys.path.insert(0,str(folder))\n",
45
+ "from next_reward import NextReward,ACTIONS\n",
46
+ "agent=NextReward.load(folder/'model.json')\n",
47
+ "board=('.....','.X...','.X...','...X.','....G')\n",
48
+ "print(ACTIONS[agent.policy(board)[0,0]])\n",
49
+ "print(json.loads((folder/'evaluation.json').read_text())[0]['suites'])"
50
+ ],
51
+ "outputs": [],
52
+ "execution_count": null
53
+ },
54
+ {
55
+ "cell_type": "markdown",
56
+ "metadata": {},
57
+ "id": "360879ee",
58
+ "source": [
59
+ "## İsteğe bağlı yayın\n",
60
+ "Aşağıdaki hücre thelamapi/Next-Lab-Reward deposuna yükler. Yeni depo varsayılan olarak özeldir."
61
+ ]
62
+ },
63
+ {
64
+ "cell_type": "code",
65
+ "metadata": {},
66
+ "id": "16ba8331",
67
+ "source": [
68
+ "from getpass import getpass\n",
69
+ "import os\n",
70
+ "from huggingface_hub import HfApi\n",
71
+ "token=os.getenv('HF_TOKEN')\n",
72
+ "if not token:\n",
73
+ " try:\n",
74
+ " from google.colab import userdata\n",
75
+ " token=userdata.get('HF_TOKEN')\n",
76
+ " except Exception:\n",
77
+ " pass\n",
78
+ "api=HfApi(token=token or getpass('HF write token: ').strip())\n",
79
+ "repo='thelamapi/Next-Lab-Reward'\n",
80
+ "api.create_repo(repo_id=repo,private=True,exist_ok=True)\n",
81
+ "commit=api.upload_folder(repo_id=repo,folder_path=str(folder),allow_patterns=list(assets)+['model.json','evaluation.json','test_maps.json'],commit_message='Release Next Reward gridworld model and evaluation')\n",
82
+ "print(commit.commit_url)"
83
+ ],
84
+ "outputs": [],
85
+ "execution_count": null
86
+ }
87
+ ]
88
+ }
README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - reinforcement-learning
6
+ - model-based-rl
7
+ - gridworld
8
+ - path-planning
9
+ - numpy
10
+ ---
11
+
12
+ # Next-Reward
13
+
14
+ A warehouse picker has three shelves to visit and a dock to return to. The nearest-looking aisle can end at a wall, and a closure can invalidate a route halfway through delivery.
15
+
16
+ Next-Reward learns how moves change an agent’s position and what rewards follow. Given a floor plan and a goal, it uses value iteration to choose a move from each reachable cell. The checkpoint runs on CPU with NumPy.
17
+
18
+ ![Three shelf visits and the return to the dock](assets/warehouse-route.png)
19
+
20
+ ## One order, four shortest paths
21
+
22
+ On the seed-2026 simulated warehouse, Next-Reward visited three shelves in a prescribed order and returned to the dock in **316 steps**. Every leg matched the shortest distance computed independently by breadth-first search (BFS).
23
+
24
+ | Leg | Next-Reward | BFS |
25
+ |---|---:|---:|
26
+ | Dock → Pick 1 | 87 | 87 |
27
+ | Pick 1 → Pick 2 | 58 | 58 |
28
+ | Pick 2 → Pick 3 | 68 | 68 |
29
+ | Pick 3 → Dock | 103 | 103 |
30
+ | **Total** | **316** | **316** |
31
+
32
+ ![Measured route length against the BFS reference for each leg](assets/route-efficiency.png)
33
+
34
+ ## Five ways a shortcut can fail
35
+
36
+ A closed loading bay forces a bypass. A dead-end aisle points straight toward the goal. A third layout requires the first move to go west even though the goal lies east. The final two layouts add an unsafe crossing and a sequence of switchbacks.
37
+
38
+ Next-Reward found a shortest route on **5 of 5** layouts. The greedy baseline reached the goal on **0 of 5**. These layouts were selected to illustrate specific failure modes. The held-out evaluation below gives a broader comparison.
39
+
40
+ ![Five warehouse layouts with Next-Reward and greedy trajectories](assets/five-routing-tests.png)
41
+
42
+ ## Long-haul dispatch
43
+
44
+ A **51 × 51** warehouse contains **1,284 reachable cells**. The green trajectory connects dispatch to the goal in **306 steps**, matching the shortest route on this layout.
45
+
46
+ ![A 306-step dispatch route](assets/long-haul.png)
47
+
48
+ ## An aisle closes mid-delivery
49
+
50
+ At the marked closure, the original route becomes unusable. With the updated map, the shortest remaining journey grows from **44 to 64 steps**. Gray shows the completed portion, dashed blue shows the canceled plan, and green traces the new route from the decision point.
51
+
52
+ ![Replanning after an aisle closure](assets/mid-delivery-closure.png)
53
+
54
+ ## Held-out evaluation
55
+
56
+ Three training seeds (73, 101 and 149) were evaluated on the same 120 held-out layouts. Every reachable floor cell served as a start. Counts are per seed, and all three seeds produced the same scores.
57
+
58
+ | Grid | Layouts | Reachable starts | Next-Reward shortest routes | Greedy arrivals |
59
+ |---|---:|---:|---:|---:|
60
+ | 5 × 5 | 40 | 569 | 569 | 474 |
61
+ | 8 × 8 | 40 | 1,417 | 1,417 | 927 |
62
+ | 12 × 12 | 40 | 3,373 | 3,373 | 1,555 |
63
+ | **Total** | **120** | **5,359** | **5,359** | **2,956** |
64
+
65
+ Another 1,122 floor cells had no path to the goal and were counted separately. The greedy baseline chooses the safe neighboring cell closest to the goal by Manhattan distance. BFS supplies the shortest-path reference.
66
+
67
+ ## Try the checkpoint
68
+
69
+ Download `model.json` and `next_reward.py` into the same directory, install NumPy, and run:
70
+
71
+ ```python
72
+ from next_reward import NextReward, ACTIONS
73
+
74
+ board = (".....", ".X...", ".X...", "...X.", "....G")
75
+ agent = NextReward.load("model.json")
76
+ policy = agent.policy(board)
77
+ print(ACTIONS[policy[0, 0]])
78
+ ```
79
+
80
+ Coordinates use `(row, column)`. A dot denotes floor, `#` a wall, `X` a terminal pit, and `G` the goal.
81
+
82
+ ## Training and reproduction
83
+
84
+ Training samples transitions on procedural 5 × 5, 6 × 6 and 7 × 7 grids. The checkpoint stores action displacement estimates for sixteen neighboring wall patterns and learned rewards for three destination types. Planning uses a discount factor of 0.98. The exported checkpoint uses seed 73.
85
+
86
+ Run `python experiment.py --output run` to train and score all three seeds. The release includes the training notebook, `evaluation.json`, and the exact held-out layouts in `test_maps.json`.
87
+
88
+ ## Scope
89
+
90
+ The experiments cover fully visible simulated grids with deterministic movement. The closure experiment supplies the changed floor plan to the agent. Physical robot control, obstacle sensing, traffic between multiple agents, and optimization of the shelf visit order remain untested.
assets/five-routing-tests.png ADDED

Git LFS Details

  • SHA256: d7164fbac2d8de7e0a02ad9e0d1b71f82f0e14fe15e929371a8aee041b575440
  • Pointer size: 131 Bytes
  • Size of remote file: 192 kB
assets/long-haul.png ADDED
assets/mid-delivery-closure.png ADDED
assets/route-efficiency.png ADDED
assets/warehouse-route.png ADDED
evaluation.json ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "seed": 73,
4
+ "train_maps": 650,
5
+ "transitions": 65000,
6
+ "suites": {
7
+ "original": {
8
+ "maps": 1,
9
+ "reachable": 21,
10
+ "unreachable": 0,
11
+ "success": 21,
12
+ "shortest": 21,
13
+ "greedy_success": 21
14
+ },
15
+ "5": {
16
+ "maps": 40,
17
+ "reachable": 569,
18
+ "unreachable": 96,
19
+ "success": 569,
20
+ "shortest": 569,
21
+ "greedy_success": 474
22
+ },
23
+ "8": {
24
+ "maps": 40,
25
+ "reachable": 1417,
26
+ "unreachable": 374,
27
+ "success": 1417,
28
+ "shortest": 1417,
29
+ "greedy_success": 927
30
+ },
31
+ "12": {
32
+ "maps": 40,
33
+ "reachable": 3373,
34
+ "unreachable": 652,
35
+ "success": 3373,
36
+ "shortest": 3373,
37
+ "greedy_success": 1555
38
+ }
39
+ }
40
+ },
41
+ {
42
+ "seed": 101,
43
+ "train_maps": 650,
44
+ "transitions": 65000,
45
+ "suites": {
46
+ "original": {
47
+ "maps": 1,
48
+ "reachable": 21,
49
+ "unreachable": 0,
50
+ "success": 21,
51
+ "shortest": 21,
52
+ "greedy_success": 21
53
+ },
54
+ "5": {
55
+ "maps": 40,
56
+ "reachable": 569,
57
+ "unreachable": 96,
58
+ "success": 569,
59
+ "shortest": 569,
60
+ "greedy_success": 474
61
+ },
62
+ "8": {
63
+ "maps": 40,
64
+ "reachable": 1417,
65
+ "unreachable": 374,
66
+ "success": 1417,
67
+ "shortest": 1417,
68
+ "greedy_success": 927
69
+ },
70
+ "12": {
71
+ "maps": 40,
72
+ "reachable": 3373,
73
+ "unreachable": 652,
74
+ "success": 3373,
75
+ "shortest": 3373,
76
+ "greedy_success": 1555
77
+ }
78
+ }
79
+ },
80
+ {
81
+ "seed": 149,
82
+ "train_maps": 650,
83
+ "transitions": 65000,
84
+ "suites": {
85
+ "original": {
86
+ "maps": 1,
87
+ "reachable": 21,
88
+ "unreachable": 0,
89
+ "success": 21,
90
+ "shortest": 21,
91
+ "greedy_success": 21
92
+ },
93
+ "5": {
94
+ "maps": 40,
95
+ "reachable": 569,
96
+ "unreachable": 96,
97
+ "success": 569,
98
+ "shortest": 569,
99
+ "greedy_success": 474
100
+ },
101
+ "8": {
102
+ "maps": 40,
103
+ "reachable": 1417,
104
+ "unreachable": 374,
105
+ "success": 1417,
106
+ "shortest": 1417,
107
+ "greedy_success": 927
108
+ },
109
+ "12": {
110
+ "maps": 40,
111
+ "reachable": 3373,
112
+ "unreachable": 652,
113
+ "success": 3373,
114
+ "shortest": 3373,
115
+ "greedy_success": 1555
116
+ }
117
+ }
118
+ }
119
+ ]
experiment.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Train a model of grid transitions and evaluate policies on disjoint layouts."""
2
+ import argparse
3
+ import hashlib
4
+ import json
5
+ import random
6
+ from collections import deque
7
+ from pathlib import Path
8
+ import numpy as np
9
+ from next_reward import MOVES, NextReward
10
+
11
+ ORIGINAL=(".....",".X...",".X...","...X.","....G")
12
+
13
+ def key(board):
14
+ return hashlib.sha256("\n".join(board).encode()).hexdigest()
15
+
16
+ def generate(rng,n,wall=.20):
17
+ cells=rng.choices(".#X",weights=[1-wall-.1,wall,.1],k=n*n)
18
+ cells[rng.randrange(n*n)]="G"
19
+ return tuple("".join(cells[i:i+n]) for i in range(0,n*n,n))
20
+
21
+ def advance(b,pos,a):
22
+ y,x=pos
23
+ r,c=y+MOVES[a][0],x+MOVES[a][1]
24
+ if not (0<=r<len(b) and 0<=c<len(b[0])) or b[r][c]=="#": return pos
25
+ return r,c
26
+
27
+ def starts(b):
28
+ return [(i,j) for i,row in enumerate(b) for j,ch in enumerate(row) if ch=="."]
29
+
30
+ def train(seed):
31
+ rng=random.Random(seed)
32
+ counts=np.zeros((16,4,5),int)
33
+ sums=np.zeros(3); freq=np.zeros(3,int)
34
+ layouts=set()
35
+ for _ in range(650):
36
+ b=generate(rng,rng.choice([5,6,7]),rng.uniform(.10,.45))
37
+ if key(b)==key(ORIGINAL) or key(b) in layouts:continue
38
+ layouts.add(key(b))
39
+ places=starts(b)
40
+ if not places: continue
41
+ for _ in range(100):
42
+ p=rng.choice(places)
43
+ mask=sum(1<<i for i in range(4) if advance(b,p,i)==p)
44
+ a=rng.randrange(4)
45
+ q=advance(b,p,a)
46
+ counts[mask,a,MOVES.index((q[0]-p[0],q[1]-p[1]))]+=1
47
+ event=".GX".index(b[q[0]][q[1]])
48
+ sums[event]+=(-.02,1.,-1.)[event]
49
+ freq[event]+=1
50
+ return NextReward(counts,sums/freq),layouts
51
+
52
+ def distances(b):
53
+ goal=next((i,row.index("G")) for i,row in enumerate(b) if "G" in row)
54
+ d={goal:0}; queue=deque([goal])
55
+ while queue:
56
+ p=queue.popleft()
57
+ for a in range(4):
58
+ q=advance(b,p,a)
59
+ if q not in d and b[q[0]][q[1]]=='.':
60
+ d[q]=d[p]+1
61
+ queue.append(q)
62
+ return goal,d
63
+
64
+ def play(b,p,policy):
65
+ seen=set()
66
+ while p not in seen:
67
+ seen.add(p)
68
+ q=advance(b,p,int(policy[p]))
69
+ if b[q[0]][q[1]]=="G":return len(seen)
70
+ if b[q[0]][q[1]]=="X":return None
71
+ p=q
72
+ return None
73
+
74
+ def evaluate(model,boards):
75
+ totals=dict(maps=len(boards),reachable=0,unreachable=0,success=0,shortest=0,greedy_success=0)
76
+ for b in boards:
77
+ goal,d=distances(b)
78
+ pi=model.policy(b); greedy=np.zeros(pi.shape,int)
79
+ for p in starts(b):
80
+ # One-step Manhattan baseline with access to visible pits and walls.
81
+ def score(a):
82
+ q=advance(b,p,a)
83
+ if q==p or b[q[0]][q[1]]=="X":return float("inf")
84
+ return abs(q[0]-goal[0])+abs(q[1]-goal[1])
85
+ greedy[p]=min(range(4),key=score)
86
+ for p in starts(b):
87
+ if p not in d:
88
+ totals["unreachable"]+=1;continue
89
+ totals["reachable"]+=1
90
+ steps=play(b,p,pi)
91
+ totals["success"]+=steps is not None
92
+ totals["shortest"]+=steps==d[p]
93
+ totals["greedy_success"]+=play(b,p,greedy) is not None
94
+ return totals
95
+
96
+ def main(out):
97
+ out.mkdir(parents=True,exist_ok=True)
98
+ results=[]
99
+ trained=[train(seed) for seed in (73,101,149)]
100
+ seen=set.union(*(layouts for _,layouts in trained))
101
+ seen.add(key(ORIGINAL))
102
+ suites={"original":[ORIGINAL]}
103
+ rng=random.Random(8901)
104
+ for n in (5,8,12):
105
+ boards=[]
106
+ while len(boards)<40:
107
+ board=generate(rng,n)
108
+ if key(board) not in seen:
109
+ seen.add(key(board));boards.append(board)
110
+ suites[str(n)]=boards
111
+ for seed,(model,layouts) in zip((73,101,149),trained):
112
+ if seed==73:
113
+ model.save(out/'model.json')
114
+ restored=NextReward.load(out/'model.json')
115
+ for boards in suites.values():
116
+ for b in boards: np.testing.assert_array_equal(model.policy(b),restored.policy(b))
117
+ model=restored
118
+ result=dict(seed=seed,train_maps=len(layouts),transitions=int(model.counts.sum()),
119
+ suites={k:evaluate(model,v) for k,v in suites.items()})
120
+ results.append(result)
121
+ print(seed,result["suites"],flush=True)
122
+ (out/'evaluation.json').write_text(json.dumps(results,indent=2))
123
+ (out/'test_maps.json').write_text(json.dumps(suites,indent=1))
124
+ if __name__=="__main__":
125
+ parser=argparse.ArgumentParser()
126
+ parser.add_argument("--output",type=Path,default=Path("."))
127
+ main(parser.parse_args().output)
128
+
model.json ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "next-reward-v1",
3
+ "counts": [
4
+ [
5
+ [
6
+ 1932,
7
+ 0,
8
+ 0,
9
+ 0,
10
+ 0
11
+ ],
12
+ [
13
+ 0,
14
+ 2028,
15
+ 0,
16
+ 0,
17
+ 0
18
+ ],
19
+ [
20
+ 0,
21
+ 0,
22
+ 2085,
23
+ 0,
24
+ 0
25
+ ],
26
+ [
27
+ 0,
28
+ 0,
29
+ 0,
30
+ 2031,
31
+ 0
32
+ ]
33
+ ],
34
+ [
35
+ [
36
+ 0,
37
+ 0,
38
+ 0,
39
+ 0,
40
+ 1435
41
+ ],
42
+ [
43
+ 0,
44
+ 1399,
45
+ 0,
46
+ 0,
47
+ 0
48
+ ],
49
+ [
50
+ 0,
51
+ 0,
52
+ 1331,
53
+ 0,
54
+ 0
55
+ ],
56
+ [
57
+ 0,
58
+ 0,
59
+ 0,
60
+ 1460,
61
+ 0
62
+ ]
63
+ ],
64
+ [
65
+ [
66
+ 1308,
67
+ 0,
68
+ 0,
69
+ 0,
70
+ 0
71
+ ],
72
+ [
73
+ 0,
74
+ 0,
75
+ 0,
76
+ 0,
77
+ 1336
78
+ ],
79
+ [
80
+ 0,
81
+ 0,
82
+ 1356,
83
+ 0,
84
+ 0
85
+ ],
86
+ [
87
+ 0,
88
+ 0,
89
+ 0,
90
+ 1312,
91
+ 0
92
+ ]
93
+ ],
94
+ [
95
+ [
96
+ 0,
97
+ 0,
98
+ 0,
99
+ 0,
100
+ 928
101
+ ],
102
+ [
103
+ 0,
104
+ 0,
105
+ 0,
106
+ 0,
107
+ 976
108
+ ],
109
+ [
110
+ 0,
111
+ 0,
112
+ 1023,
113
+ 0,
114
+ 0
115
+ ],
116
+ [
117
+ 0,
118
+ 0,
119
+ 0,
120
+ 942,
121
+ 0
122
+ ]
123
+ ],
124
+ [
125
+ [
126
+ 1375,
127
+ 0,
128
+ 0,
129
+ 0,
130
+ 0
131
+ ],
132
+ [
133
+ 0,
134
+ 1349,
135
+ 0,
136
+ 0,
137
+ 0
138
+ ],
139
+ [
140
+ 0,
141
+ 0,
142
+ 0,
143
+ 0,
144
+ 1399
145
+ ],
146
+ [
147
+ 0,
148
+ 0,
149
+ 0,
150
+ 1278,
151
+ 0
152
+ ]
153
+ ],
154
+ [
155
+ [
156
+ 0,
157
+ 0,
158
+ 0,
159
+ 0,
160
+ 834
161
+ ],
162
+ [
163
+ 0,
164
+ 831,
165
+ 0,
166
+ 0,
167
+ 0
168
+ ],
169
+ [
170
+ 0,
171
+ 0,
172
+ 0,
173
+ 0,
174
+ 836
175
+ ],
176
+ [
177
+ 0,
178
+ 0,
179
+ 0,
180
+ 806,
181
+ 0
182
+ ]
183
+ ],
184
+ [
185
+ [
186
+ 1066,
187
+ 0,
188
+ 0,
189
+ 0,
190
+ 0
191
+ ],
192
+ [
193
+ 0,
194
+ 0,
195
+ 0,
196
+ 0,
197
+ 1037
198
+ ],
199
+ [
200
+ 0,
201
+ 0,
202
+ 0,
203
+ 0,
204
+ 989
205
+ ],
206
+ [
207
+ 0,
208
+ 0,
209
+ 0,
210
+ 1069,
211
+ 0
212
+ ]
213
+ ],
214
+ [
215
+ [
216
+ 0,
217
+ 0,
218
+ 0,
219
+ 0,
220
+ 634
221
+ ],
222
+ [
223
+ 0,
224
+ 0,
225
+ 0,
226
+ 0,
227
+ 675
228
+ ],
229
+ [
230
+ 0,
231
+ 0,
232
+ 0,
233
+ 0,
234
+ 687
235
+ ],
236
+ [
237
+ 0,
238
+ 0,
239
+ 0,
240
+ 649,
241
+ 0
242
+ ]
243
+ ],
244
+ [
245
+ [
246
+ 1256,
247
+ 0,
248
+ 0,
249
+ 0,
250
+ 0
251
+ ],
252
+ [
253
+ 0,
254
+ 1280,
255
+ 0,
256
+ 0,
257
+ 0
258
+ ],
259
+ [
260
+ 0,
261
+ 0,
262
+ 1326,
263
+ 0,
264
+ 0
265
+ ],
266
+ [
267
+ 0,
268
+ 0,
269
+ 0,
270
+ 0,
271
+ 1262
272
+ ]
273
+ ],
274
+ [
275
+ [
276
+ 0,
277
+ 0,
278
+ 0,
279
+ 0,
280
+ 1000
281
+ ],
282
+ [
283
+ 0,
284
+ 1053,
285
+ 0,
286
+ 0,
287
+ 0
288
+ ],
289
+ [
290
+ 0,
291
+ 0,
292
+ 972,
293
+ 0,
294
+ 0
295
+ ],
296
+ [
297
+ 0,
298
+ 0,
299
+ 0,
300
+ 0,
301
+ 1003
302
+ ]
303
+ ],
304
+ [
305
+ [
306
+ 752,
307
+ 0,
308
+ 0,
309
+ 0,
310
+ 0
311
+ ],
312
+ [
313
+ 0,
314
+ 0,
315
+ 0,
316
+ 0,
317
+ 775
318
+ ],
319
+ [
320
+ 0,
321
+ 0,
322
+ 752,
323
+ 0,
324
+ 0
325
+ ],
326
+ [
327
+ 0,
328
+ 0,
329
+ 0,
330
+ 0,
331
+ 804
332
+ ]
333
+ ],
334
+ [
335
+ [
336
+ 0,
337
+ 0,
338
+ 0,
339
+ 0,
340
+ 660
341
+ ],
342
+ [
343
+ 0,
344
+ 0,
345
+ 0,
346
+ 0,
347
+ 645
348
+ ],
349
+ [
350
+ 0,
351
+ 0,
352
+ 657,
353
+ 0,
354
+ 0
355
+ ],
356
+ [
357
+ 0,
358
+ 0,
359
+ 0,
360
+ 0,
361
+ 663
362
+ ]
363
+ ],
364
+ [
365
+ [
366
+ 1098,
367
+ 0,
368
+ 0,
369
+ 0,
370
+ 0
371
+ ],
372
+ [
373
+ 0,
374
+ 1052,
375
+ 0,
376
+ 0,
377
+ 0
378
+ ],
379
+ [
380
+ 0,
381
+ 0,
382
+ 0,
383
+ 0,
384
+ 1036
385
+ ],
386
+ [
387
+ 0,
388
+ 0,
389
+ 0,
390
+ 0,
391
+ 1065
392
+ ]
393
+ ],
394
+ [
395
+ [
396
+ 0,
397
+ 0,
398
+ 0,
399
+ 0,
400
+ 643
401
+ ],
402
+ [
403
+ 0,
404
+ 646,
405
+ 0,
406
+ 0,
407
+ 0
408
+ ],
409
+ [
410
+ 0,
411
+ 0,
412
+ 0,
413
+ 0,
414
+ 668
415
+ ],
416
+ [
417
+ 0,
418
+ 0,
419
+ 0,
420
+ 0,
421
+ 648
422
+ ]
423
+ ],
424
+ [
425
+ [
426
+ 627,
427
+ 0,
428
+ 0,
429
+ 0,
430
+ 0
431
+ ],
432
+ [
433
+ 0,
434
+ 0,
435
+ 0,
436
+ 0,
437
+ 666
438
+ ],
439
+ [
440
+ 0,
441
+ 0,
442
+ 0,
443
+ 0,
444
+ 683
445
+ ],
446
+ [
447
+ 0,
448
+ 0,
449
+ 0,
450
+ 0,
451
+ 680
452
+ ]
453
+ ],
454
+ [
455
+ [
456
+ 0,
457
+ 0,
458
+ 0,
459
+ 0,
460
+ 525
461
+ ],
462
+ [
463
+ 0,
464
+ 0,
465
+ 0,
466
+ 0,
467
+ 578
468
+ ],
469
+ [
470
+ 0,
471
+ 0,
472
+ 0,
473
+ 0,
474
+ 584
475
+ ],
476
+ [
477
+ 0,
478
+ 0,
479
+ 0,
480
+ 0,
481
+ 545
482
+ ]
483
+ ]
484
+ ],
485
+ "rewards": [
486
+ -0.019999999999986806,
487
+ 1.0,
488
+ -1.0
489
+ ]
490
+ }
next_reward.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Inference for Next Reward. Boards use . (floor), # (wall), X (pit), G (goal)."""
2
+ import json
3
+ from pathlib import Path
4
+ import numpy as np
5
+
6
+ MOVES = ((1,0),(0,1),(-1,0),(0,-1),(0,0))
7
+ ACTIONS = ("down","right","up","left")
8
+
9
+ def geometry(board):
10
+ if not board or not board[0] or any(len(row)!=len(board[0]) for row in board):
11
+ raise ValueError("Expected a nonempty rectangular board")
12
+ if sum(row.count("G") for row in board)!=1 or any(set(row)-set(".X#G") for row in board):
13
+ raise ValueError("Use exactly one G and symbols . # X")
14
+ grid=np.array([list(row) for row in board])
15
+ h,w=grid.shape
16
+ y,x=np.indices((h,w))
17
+ dest=[]
18
+ mask=np.zeros((h,w),dtype=int)
19
+ for i,(dy,dx) in enumerate(MOVES):
20
+ ny,nx=y+dy,x+dx
21
+ blocked=(ny<0)|(ny>=h)|(nx<0)|(nx>=w)|(grid[ny.clip(0,h-1),nx.clip(0,w-1)]=="#")
22
+ if i<4: mask |= blocked.astype(int)<<i
23
+ dest.append(np.where(blocked,y*w+x,ny*w+nx))
24
+ return grid,mask,np.stack(dest,axis=-1)
25
+
26
+ class NextReward:
27
+ def __init__(self,counts,rewards):
28
+ counts=np.asarray(counts,dtype=float)
29
+ self.rewards=np.asarray(rewards,dtype=float)
30
+ if counts.shape!=(16,4,5) or not np.isfinite(counts).all() or np.any(counts<0) or np.any(counts.sum(-1)==0):
31
+ raise ValueError("Missing or invalid transition counts")
32
+ if self.rewards.shape!=(3,) or not np.isfinite(self.rewards).all():
33
+ raise ValueError("Invalid learned rewards")
34
+ self.counts=counts
35
+ self.prob=counts/counts.sum(-1,keepdims=True)
36
+
37
+ @classmethod
38
+ def load(cls,path):
39
+ d=json.loads(Path(path).read_text())
40
+ if d["format"]!="next-reward-v1": raise ValueError("Unsupported model format")
41
+ return cls(d["counts"],d["rewards"])
42
+
43
+ def save(self,path):
44
+ Path(path).write_text(json.dumps(dict(format="next-reward-v1",counts=self.counts.astype(int).tolist(),
45
+ rewards=self.rewards.tolist()),indent=1))
46
+
47
+ def policy(self,board):
48
+ grid,mask,dest=geometry(board)
49
+ reward=np.where(grid=="G",self.rewards[1],np.where(grid=="X",self.rewards[2],self.rewards[0]))
50
+ value=np.zeros(grid.shape)
51
+ for _ in range(grid.size+1):
52
+ outcomes=(reward+0.98*value).ravel()[dest]
53
+ q=np.einsum("ijak,ijk->ija",self.prob[mask],outcomes)
54
+ updated=np.where(grid==".",q.max(-1),0.)
55
+ if np.max(np.abs(updated-value))<1e-12: break
56
+ value=updated
57
+ return np.where(grid==".",q.argmax(-1),-1)
58
+
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ numpy>=1.24
test_maps.json ADDED
@@ -0,0 +1,1257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "original": [
3
+ [
4
+ ".....",
5
+ ".X...",
6
+ ".X...",
7
+ "...X.",
8
+ "....G"
9
+ ]
10
+ ],
11
+ "5": [
12
+ [
13
+ "#.#..",
14
+ "..#X.",
15
+ "G...#",
16
+ "..#..",
17
+ ".X..."
18
+ ],
19
+ [
20
+ "##X..",
21
+ "#....",
22
+ ".G...",
23
+ "....X",
24
+ "#...."
25
+ ],
26
+ [
27
+ "....#",
28
+ "..##.",
29
+ ".....",
30
+ "G##..",
31
+ "##.#."
32
+ ],
33
+ [
34
+ "G.#X.",
35
+ ".#X..",
36
+ "....#",
37
+ "#..#.",
38
+ "#...."
39
+ ],
40
+ [
41
+ "#X.X#",
42
+ "X....",
43
+ "..X.#",
44
+ "#.#G#",
45
+ "#...X"
46
+ ],
47
+ [
48
+ ".#..X",
49
+ ".#.X.",
50
+ "....#",
51
+ ".G...",
52
+ ".X.#."
53
+ ],
54
+ [
55
+ ".#...",
56
+ "...#.",
57
+ ".#...",
58
+ ".....",
59
+ "...G."
60
+ ],
61
+ [
62
+ "...X#",
63
+ "#....",
64
+ "....G",
65
+ "...##",
66
+ ".#..."
67
+ ],
68
+ [
69
+ "...#.",
70
+ "X....",
71
+ "X....",
72
+ "#.#.G",
73
+ "X...."
74
+ ],
75
+ [
76
+ ".#...",
77
+ ".X...",
78
+ "...G#",
79
+ ".....",
80
+ ".X.#."
81
+ ],
82
+ [
83
+ "G#..X",
84
+ "..X#X",
85
+ ".X.#.",
86
+ ".....",
87
+ "..#.#"
88
+ ],
89
+ [
90
+ "..#..",
91
+ "X.GX.",
92
+ "#...#",
93
+ ".#.#.",
94
+ ".X.##"
95
+ ],
96
+ [
97
+ ".X#..",
98
+ "...#.",
99
+ ".....",
100
+ ".##..",
101
+ ".G#.#"
102
+ ],
103
+ [
104
+ "..#..",
105
+ "..##.",
106
+ ".#.#.",
107
+ ".#.#.",
108
+ "..G.X"
109
+ ],
110
+ [
111
+ ".....",
112
+ "..##.",
113
+ "###.X",
114
+ "#.G..",
115
+ ".#..."
116
+ ],
117
+ [
118
+ "G....",
119
+ "X..#.",
120
+ "X....",
121
+ "X.X..",
122
+ "##.X."
123
+ ],
124
+ [
125
+ "....G",
126
+ ".....",
127
+ "X.#X.",
128
+ "...#.",
129
+ ".#.#."
130
+ ],
131
+ [
132
+ ".XX#.",
133
+ ".....",
134
+ "...#G",
135
+ ".....",
136
+ ".#XX."
137
+ ],
138
+ [
139
+ "..#.G",
140
+ ".###.",
141
+ "...#X",
142
+ ".#.X#",
143
+ ".#.#."
144
+ ],
145
+ [
146
+ "#....",
147
+ "G.###",
148
+ "X....",
149
+ "XX...",
150
+ "....."
151
+ ],
152
+ [
153
+ ".#.XX",
154
+ "....G",
155
+ "..###",
156
+ ".X..X",
157
+ "..X#."
158
+ ],
159
+ [
160
+ "X..##",
161
+ "..G..",
162
+ "..##.",
163
+ ".#X.#",
164
+ ".#..."
165
+ ],
166
+ [
167
+ ".##..",
168
+ "..#..",
169
+ "...#X",
170
+ "...#.",
171
+ "X..G."
172
+ ],
173
+ [
174
+ "....#",
175
+ ".....",
176
+ "..X#.",
177
+ "#..X#",
178
+ ".GX.."
179
+ ],
180
+ [
181
+ ".#X..",
182
+ "...##",
183
+ "..##G",
184
+ "..#.X",
185
+ ".#..."
186
+ ],
187
+ [
188
+ "#....",
189
+ "#X##.",
190
+ ".X...",
191
+ "#....",
192
+ ".X.GX"
193
+ ],
194
+ [
195
+ "##...",
196
+ "...#X",
197
+ ".....",
198
+ "..#..",
199
+ "..#G."
200
+ ],
201
+ [
202
+ "#...X",
203
+ ".#...",
204
+ "XX...",
205
+ ".....",
206
+ "G..#."
207
+ ],
208
+ [
209
+ "X..X.",
210
+ ".....",
211
+ ".##..",
212
+ "....#",
213
+ "GX#.."
214
+ ],
215
+ [
216
+ "X....",
217
+ "#...#",
218
+ "..#..",
219
+ ".....",
220
+ ".G.X."
221
+ ],
222
+ [
223
+ "#....",
224
+ ".#...",
225
+ "#X..X",
226
+ "X.G..",
227
+ ".X..."
228
+ ],
229
+ [
230
+ "...GX",
231
+ "..X.#",
232
+ "X...#",
233
+ "....#",
234
+ "..X##"
235
+ ],
236
+ [
237
+ "..#.#",
238
+ "..G#.",
239
+ "..#X#",
240
+ "..#..",
241
+ "..#.."
242
+ ],
243
+ [
244
+ "X#.X#",
245
+ ".##..",
246
+ ".X...",
247
+ ".GX..",
248
+ "..#X."
249
+ ],
250
+ [
251
+ ".....",
252
+ ".##..",
253
+ "..###",
254
+ ".....",
255
+ "G.#X."
256
+ ],
257
+ [
258
+ "..G.#",
259
+ ".....",
260
+ "#....",
261
+ "..#..",
262
+ "#...X"
263
+ ],
264
+ [
265
+ "...##",
266
+ "....#",
267
+ "..#.#",
268
+ "....#",
269
+ "..#G."
270
+ ],
271
+ [
272
+ "..#..",
273
+ ".#.X.",
274
+ "..G..",
275
+ ".....",
276
+ "..#.."
277
+ ],
278
+ [
279
+ ".#.##",
280
+ "G.#.#",
281
+ "#.##.",
282
+ ".....",
283
+ "#...."
284
+ ],
285
+ [
286
+ "..G#.",
287
+ "...X.",
288
+ "..X..",
289
+ "...X.",
290
+ "..X.."
291
+ ]
292
+ ],
293
+ "8": [
294
+ [
295
+ "........",
296
+ "#.X.....",
297
+ "#.#.....",
298
+ "......#.",
299
+ "GX......",
300
+ "#..#....",
301
+ "XX.X...#",
302
+ "#X..#..."
303
+ ],
304
+ [
305
+ ".#..X...",
306
+ "...##...",
307
+ "##.#...G",
308
+ "....X..#",
309
+ "..X....#",
310
+ ".....X..",
311
+ "...X....",
312
+ "X.##...X"
313
+ ],
314
+ [
315
+ "..#.#...",
316
+ ".......#",
317
+ ".#..##X.",
318
+ "#.......",
319
+ ".##.#..#",
320
+ "#..#..##",
321
+ ".##..X..",
322
+ "....#G.#"
323
+ ],
324
+ [
325
+ "....#..#",
326
+ ".......#",
327
+ ".#.XX...",
328
+ "....#..X",
329
+ "......#.",
330
+ ".....XX#",
331
+ "....##..",
332
+ "#.XGX#.."
333
+ ],
334
+ [
335
+ "#.#..G..",
336
+ "#.....#.",
337
+ ".......X",
338
+ ".X.....X",
339
+ "...##...",
340
+ "........",
341
+ ".#.X..##",
342
+ "..#....."
343
+ ],
344
+ [
345
+ ".X......",
346
+ "..##.X#.",
347
+ "X....X#.",
348
+ "........",
349
+ "#....G..",
350
+ "........",
351
+ "...#...#",
352
+ "..#.#..#"
353
+ ],
354
+ [
355
+ ".......X",
356
+ "##.....#",
357
+ ".....#..",
358
+ "..#.##.#",
359
+ ".#.#...#",
360
+ ".#X...X.",
361
+ "#.......",
362
+ "..G....."
363
+ ],
364
+ [
365
+ "..###.X.",
366
+ "X.......",
367
+ ".X......",
368
+ "......#X",
369
+ "..X..X.X",
370
+ "#X...X..",
371
+ "......G.",
372
+ ".#..#..."
373
+ ],
374
+ [
375
+ "..X.#...",
376
+ "G#.#....",
377
+ ".#...###",
378
+ "#.#..#.#",
379
+ "#.....#.",
380
+ "........",
381
+ "..X.....",
382
+ "..#.#.#."
383
+ ],
384
+ [
385
+ "#....X#X",
386
+ "..#.....",
387
+ ".X.##XX.",
388
+ "...#.X..",
389
+ "...X.#.#",
390
+ "#.....G.",
391
+ "....X..#",
392
+ ".....##X"
393
+ ],
394
+ [
395
+ "X..#XX.#",
396
+ "....#...",
397
+ "#....X..",
398
+ "......##",
399
+ ".#.....#",
400
+ "..##X...",
401
+ "G#.#..X.",
402
+ "..X.X#.."
403
+ ],
404
+ [
405
+ "..#...#.",
406
+ "X.#..##G",
407
+ "..#..X.X",
408
+ "......X#",
409
+ ".#X.#.X#",
410
+ "#.X.....",
411
+ "....##..",
412
+ "......#X"
413
+ ],
414
+ [
415
+ "#G..#...",
416
+ ".X#X..#X",
417
+ "....#X..",
418
+ "........",
419
+ "......#.",
420
+ "#.......",
421
+ ".###..X.",
422
+ "..#....."
423
+ ],
424
+ [
425
+ "#..#....",
426
+ "G.#.....",
427
+ ".X.X....",
428
+ "..X.X#.#",
429
+ "#.##..X.",
430
+ ".....##.",
431
+ "......#.",
432
+ "...#X#.."
433
+ ],
434
+ [
435
+ ".#...#X.",
436
+ ".#......",
437
+ "...G..#.",
438
+ ".#......",
439
+ ".X.X##..",
440
+ "......X.",
441
+ "#.X...#.",
442
+ ".......X"
443
+ ],
444
+ [
445
+ "X.X.....",
446
+ "...#...#",
447
+ "....#...",
448
+ ".....#..",
449
+ ".##...#.",
450
+ "..X...#.",
451
+ "X....X##",
452
+ ".......G"
453
+ ],
454
+ [
455
+ ".#.X...#",
456
+ "...X..#.",
457
+ "#.##X..X",
458
+ "XX.##...",
459
+ ".##..#..",
460
+ ".G......",
461
+ "......#.",
462
+ "#XX#.#X#"
463
+ ],
464
+ [
465
+ "#...#.#.",
466
+ "...#....",
467
+ "##X#..#G",
468
+ "...#X...",
469
+ ".XX.....",
470
+ "..#..X.#",
471
+ "......X.",
472
+ ".#.....#"
473
+ ],
474
+ [
475
+ "#.....#.",
476
+ "......#X",
477
+ ".#....#X",
478
+ ".#.#.G##",
479
+ "..X.#...",
480
+ ".......#",
481
+ ".#.##...",
482
+ "........"
483
+ ],
484
+ [
485
+ ".##.....",
486
+ ".X#X..#.",
487
+ "..#...X.",
488
+ "#.....##",
489
+ "....GX..",
490
+ "#..#....",
491
+ ".#.#.#..",
492
+ ".X...X.X"
493
+ ],
494
+ [
495
+ "..X...##",
496
+ "....X.X.",
497
+ "..G..#..",
498
+ ".#..X#X.",
499
+ "..X..#.X",
500
+ "X#....#.",
501
+ "....#.##",
502
+ "...##X.."
503
+ ],
504
+ [
505
+ "..#..X..",
506
+ "...#.#.#",
507
+ "........",
508
+ "XX#.###.",
509
+ ".X...#..",
510
+ "..#X....",
511
+ ".#.##X..",
512
+ ".GX....."
513
+ ],
514
+ [
515
+ "....X##.",
516
+ ".#X..#..",
517
+ "#.#.....",
518
+ "#...#...",
519
+ ".X..XXX.",
520
+ "X.GX.##.",
521
+ "..##.X..",
522
+ "#....X.."
523
+ ],
524
+ [
525
+ "#.X....#",
526
+ "....#.G.",
527
+ "...#....",
528
+ "X...#...",
529
+ "#....#.#",
530
+ "..#.X..#",
531
+ "X.#...#.",
532
+ "....#..."
533
+ ],
534
+ [
535
+ ".X.##...",
536
+ "......#X",
537
+ "#...#...",
538
+ "........",
539
+ ".#X.....",
540
+ "..#G..#X",
541
+ "#X..#.#.",
542
+ "....#..."
543
+ ],
544
+ [
545
+ "#.#....#",
546
+ "#......#",
547
+ ".#.....X",
548
+ "...##...",
549
+ "..#.#...",
550
+ ".#.G.#..",
551
+ "..#.....",
552
+ "...#.X#."
553
+ ],
554
+ [
555
+ "...X.##X",
556
+ "........",
557
+ "........",
558
+ "...##X..",
559
+ "#X.###..",
560
+ ".G.###..",
561
+ "...#....",
562
+ "........"
563
+ ],
564
+ [
565
+ "......X.",
566
+ ".#.XG...",
567
+ "###...#.",
568
+ "#.....##",
569
+ "........",
570
+ ".#....#.",
571
+ "X..#.#.#",
572
+ "..X....."
573
+ ],
574
+ [
575
+ "G....#.#",
576
+ ".####X.#",
577
+ "..X....#",
578
+ ".....X.#",
579
+ ".#..#..X",
580
+ "XX..XX..",
581
+ "....##..",
582
+ ".#....#."
583
+ ],
584
+ [
585
+ "..XX.X.X",
586
+ "XX...X..",
587
+ "X....#..",
588
+ ".#.#..X.",
589
+ "X.X#.#..",
590
+ "..G..X..",
591
+ "#..#....",
592
+ "#..#...."
593
+ ],
594
+ [
595
+ ".#GXX..X",
596
+ "X.X.....",
597
+ "X..#.X..",
598
+ "#.......",
599
+ ".#....##",
600
+ "..#.#..#",
601
+ "#....XX#",
602
+ "#......."
603
+ ],
604
+ [
605
+ "......##",
606
+ "#..#.X..",
607
+ "..#.....",
608
+ "XX.#.#..",
609
+ "..##..X.",
610
+ "#..X..#.",
611
+ ".....#.X",
612
+ "......G."
613
+ ],
614
+ [
615
+ "...#.#..",
616
+ "........",
617
+ "........",
618
+ ".......#",
619
+ ".##X..G#",
620
+ "...##.#.",
621
+ ".......#",
622
+ ".#...X.."
623
+ ],
624
+ [
625
+ "#....#..",
626
+ "........",
627
+ ".X..#...",
628
+ "...#...#",
629
+ ".....#..",
630
+ "X.....G.",
631
+ "...#....",
632
+ ".#.X...."
633
+ ],
634
+ [
635
+ ".....X..",
636
+ "..X#..#.",
637
+ ".X.X....",
638
+ "X#..X...",
639
+ "....X...",
640
+ "#....#..",
641
+ "#...X.#.",
642
+ ".#G....#"
643
+ ],
644
+ [
645
+ ".X.X....",
646
+ "X.......",
647
+ ".X.G..#X",
648
+ "#.......",
649
+ "..#.....",
650
+ "XX...##.",
651
+ "....#.#.",
652
+ "X.X.X#.."
653
+ ],
654
+ [
655
+ ".....X..",
656
+ "..X.#.#.",
657
+ ".#......",
658
+ "X..####.",
659
+ "#.##...#",
660
+ ".....XX#",
661
+ "....G...",
662
+ ".XX....X"
663
+ ],
664
+ [
665
+ "X##X....",
666
+ ".##..X..",
667
+ "..X....X",
668
+ "####.#G.",
669
+ "....X##.",
670
+ "...#.#..",
671
+ "#.......",
672
+ "......##"
673
+ ],
674
+ [
675
+ "......#.",
676
+ "..XX....",
677
+ "X###..##",
678
+ "##.G....",
679
+ "#.XX....",
680
+ "#..#...#",
681
+ ".#..#...",
682
+ ".....##."
683
+ ],
684
+ [
685
+ "......#.",
686
+ "........",
687
+ ".#......",
688
+ "#..X#...",
689
+ "..#.#..#",
690
+ "#..##X.#",
691
+ "#.......",
692
+ ".G..XX.."
693
+ ]
694
+ ],
695
+ "12": [
696
+ [
697
+ "....#...X.##",
698
+ ".#.#..#.....",
699
+ ".#..X...#...",
700
+ "..#..#.#...#",
701
+ "....X.#.#...",
702
+ "XX..##.....#",
703
+ "...#.......X",
704
+ "##..#......G",
705
+ "....X.....#.",
706
+ "#..#......##",
707
+ "..........#.",
708
+ ".#.X#....#.."
709
+ ],
710
+ [
711
+ ".....X..##X.",
712
+ "..#.X...X..X",
713
+ "#....#....X.",
714
+ "#..#.......X",
715
+ ".#...#..#X..",
716
+ "...#.....G..",
717
+ "..#....#....",
718
+ "..X#........",
719
+ ".#.....#....",
720
+ "##.....##...",
721
+ "...X...#X...",
722
+ ".....X...#.."
723
+ ],
724
+ [
725
+ "......##.X..",
726
+ "..X.##.XG#.#",
727
+ "..##...X...X",
728
+ "#..XX..X..X.",
729
+ "..........#.",
730
+ ".....##.X.#X",
731
+ "..X.#.......",
732
+ "...#..X.....",
733
+ "......X##..#",
734
+ "..X...#..#..",
735
+ ".##...X.#..#",
736
+ "..#..#......"
737
+ ],
738
+ [
739
+ "..X.X.##...X",
740
+ "#.......X.#.",
741
+ "#.XX....#...",
742
+ "#.X#.X...##.",
743
+ ".X....#G....",
744
+ "X...X.#....X",
745
+ ".X..#....#..",
746
+ "X.#...#..X..",
747
+ "....#..#...#",
748
+ "..X........X",
749
+ "##X..X#...##",
750
+ "..#........#"
751
+ ],
752
+ [
753
+ "..#.#....#.#",
754
+ "....#.##.X..",
755
+ ".X.#.#......",
756
+ ".#XX#.....X.",
757
+ "......X.....",
758
+ ".#.#.G.X...#",
759
+ "XX...X.X#...",
760
+ "............",
761
+ "..X.....X##X",
762
+ ".#...X.X.#X.",
763
+ "...#X.......",
764
+ "##..###....."
765
+ ],
766
+ [
767
+ "..#..#.X...#",
768
+ "#.##..X#.##X",
769
+ ".X..X#......",
770
+ "...........X",
771
+ "X..X.#....#.",
772
+ "..X##.......",
773
+ "#.X.#.X#....",
774
+ "............",
775
+ "XX#.#G##.XX.",
776
+ "...##....XX.",
777
+ ".#.##.##....",
778
+ "..##....#..."
779
+ ],
780
+ [
781
+ "##.....#...#",
782
+ "..X...X.#.X.",
783
+ "X..#....##.X",
784
+ "...#X.#XX#..",
785
+ "#.X#.X...X#.",
786
+ "#XX.....X.#.",
787
+ "......#G.###",
788
+ "..XX.#...X..",
789
+ ".....##..X..",
790
+ "..#..X...#..",
791
+ "...X...#..##",
792
+ "...##....##."
793
+ ],
794
+ [
795
+ "......#.X..#",
796
+ "##..#..X...#",
797
+ "#.X.........",
798
+ "#.XX......#.",
799
+ "..X.#X...X#X",
800
+ ".X.......##.",
801
+ "#......#X#..",
802
+ ".......##.X.",
803
+ "...#...#....",
804
+ "##..........",
805
+ "...........G",
806
+ "...#.##..#.."
807
+ ],
808
+ [
809
+ "#....X#X..X#",
810
+ "#..##.......",
811
+ ".X.#...X.X.#",
812
+ "G..X..#.#.##",
813
+ "X#........X.",
814
+ ".......#....",
815
+ ".X..X....#.#",
816
+ "X#..###.....",
817
+ "...X##.X....",
818
+ "XX.X..#.....",
819
+ "...#..#..X##",
820
+ "...#.#.X...."
821
+ ],
822
+ [
823
+ "#X........X#",
824
+ "##...XX.....",
825
+ ".X#...#..#..",
826
+ "..X...X.#..X",
827
+ "X......#.#..",
828
+ ".....#G.#...",
829
+ ".#X........#",
830
+ ".##....X.#..",
831
+ ".X....#.X.#.",
832
+ ".#.X..#.....",
833
+ ".#.#.......#",
834
+ ".X..##X.##.#"
835
+ ],
836
+ [
837
+ ".......G....",
838
+ ".......X..X.",
839
+ "X#..X.#....#",
840
+ "#..X........",
841
+ "....#....#..",
842
+ "..X....#...X",
843
+ "..#...X.....",
844
+ "#...X......X",
845
+ ".#.....#....",
846
+ "#..........#",
847
+ ".#...#......",
848
+ ".......##.#."
849
+ ],
850
+ [
851
+ "....X..#.##.",
852
+ "..#.........",
853
+ ".......X...#",
854
+ "..##.#...G#X",
855
+ ".#X..#......",
856
+ "X....##..X..",
857
+ "#X#..#......",
858
+ "#XX.XX#.....",
859
+ "..#.....X...",
860
+ ".#.#.....#X.",
861
+ "..#...#..X..",
862
+ "...X..#..#.#"
863
+ ],
864
+ [
865
+ ".#.....XX.#.",
866
+ "X.#..X.G.#.X",
867
+ ".#..#..X##..",
868
+ "#..#.X..#...",
869
+ "X###......#X",
870
+ "#....#......",
871
+ "#..#...#....",
872
+ "...#....#...",
873
+ "#.....X....#",
874
+ ".#........#.",
875
+ ".....#.#...#",
876
+ "#......#...."
877
+ ],
878
+ [
879
+ ".X.##.#.....",
880
+ "....X.......",
881
+ "........X.G#",
882
+ "..#..#...X..",
883
+ "##..###...X#",
884
+ ".##.X.#.#...",
885
+ "X......##.#.",
886
+ "......#.#..#",
887
+ "X.##.#.#.X..",
888
+ "..#.#.X#....",
889
+ "X..........#",
890
+ "..#..#...#.."
891
+ ],
892
+ [
893
+ "...#..#.....",
894
+ ".#..###.....",
895
+ "#....X.XX.X.",
896
+ "##.....#.X.X",
897
+ "...#..X.....",
898
+ "....#.#X..X.",
899
+ ".....G...#..",
900
+ ".....X......",
901
+ "X...#.......",
902
+ "#..#..#.X...",
903
+ "..X.......#.",
904
+ "X#.......X.#"
905
+ ],
906
+ [
907
+ "#..###X#..#.",
908
+ "......G#.X#.",
909
+ "X.#X....X.X.",
910
+ "............",
911
+ "...........#",
912
+ "#..##..X#..X",
913
+ "..X#X...#.#.",
914
+ ".#........X.",
915
+ "....###.....",
916
+ "#X..#.....#.",
917
+ ".#.#X..#X.X.",
918
+ "....X......#"
919
+ ],
920
+ [
921
+ "#X..X....#XX",
922
+ "..X.........",
923
+ ".#....#..X..",
924
+ "...#..##X.#X",
925
+ "...#.#..X...",
926
+ "....#......#",
927
+ "#....X..X...",
928
+ ".X..X##.XXX.",
929
+ ".......#..#X",
930
+ "..X.....X..X",
931
+ ".G.........#",
932
+ "...#....#X.."
933
+ ],
934
+ [
935
+ "X.X..#......",
936
+ "....##X.#.##",
937
+ "X..........#",
938
+ "#.#....X.X#.",
939
+ "..#..#....#X",
940
+ ".##..X.....#",
941
+ "##......#.#X",
942
+ ".#....#...X.",
943
+ "X##.....X...",
944
+ "..X..X......",
945
+ ".......X.#X.",
946
+ "......#G...."
947
+ ],
948
+ [
949
+ "..#X........",
950
+ ".X.#......X.",
951
+ "...X#......#",
952
+ "..X..X#.#.#.",
953
+ "...........#",
954
+ "#...#..#X...",
955
+ "..##..X.#..#",
956
+ ".........##.",
957
+ "#.#.....#...",
958
+ "..#..X....#.",
959
+ "#...#GX....X",
960
+ "#..........."
961
+ ],
962
+ [
963
+ ".#..X.......",
964
+ "..X.##.....X",
965
+ ".#..XG...X..",
966
+ "............",
967
+ "#..##.#....#",
968
+ "......#..X#.",
969
+ "XX.#...X#...",
970
+ "........X...",
971
+ "..#......#..",
972
+ "X...##......",
973
+ "##X...##X..#",
974
+ "..#...##.#.."
975
+ ],
976
+ [
977
+ "#.#.#.#.#.#.",
978
+ "..X.#.#.....",
979
+ "#..#....X.X.",
980
+ ".#...#X...#.",
981
+ "....#.#.#.X.",
982
+ "....X##X#...",
983
+ ".X.#..X#....",
984
+ "..##.X#..XX.",
985
+ "...X........",
986
+ "..#...X..##.",
987
+ "..##.XG.....",
988
+ ".#..##....#."
989
+ ],
990
+ [
991
+ ".#.##...#...",
992
+ "....#......X",
993
+ "......XX....",
994
+ ".X.#.X#.....",
995
+ "...X.X.#.#..",
996
+ "#.....X#....",
997
+ "#.#.X..X..#.",
998
+ ".#...X..X#.X",
999
+ "....XXX.X.#.",
1000
+ ".#......XXG.",
1001
+ "......X...#.",
1002
+ ".......X.#.#"
1003
+ ],
1004
+ [
1005
+ "...XX#..X..#",
1006
+ "....X#..#...",
1007
+ ".#.#.#..X#.#",
1008
+ "...X#...#.#.",
1009
+ "...#.#.....#",
1010
+ "....X..X..##",
1011
+ "...X..#.#...",
1012
+ "#...#...X...",
1013
+ "....X.....X.",
1014
+ "#X.#..#.G...",
1015
+ "..#...X#....",
1016
+ "..#...#....."
1017
+ ],
1018
+ [
1019
+ "........#.X.",
1020
+ ".X.#.X..#...",
1021
+ "#.X.#....##X",
1022
+ "............",
1023
+ ".#..X.#...X.",
1024
+ ".........X..",
1025
+ "#.XX.#......",
1026
+ ".X#.....#X#.",
1027
+ ".##.X..#X#..",
1028
+ "#....#..X...",
1029
+ ".....XG.#...",
1030
+ "..#...X....."
1031
+ ],
1032
+ [
1033
+ "........##.X",
1034
+ "...##.X.....",
1035
+ ".#..##......",
1036
+ "...X..##X#.#",
1037
+ ".X..X.##....",
1038
+ "....#.X.X.#.",
1039
+ "X.#..#......",
1040
+ "#.....X.X.##",
1041
+ ".#...#..###X",
1042
+ "............",
1043
+ "...G##...X..",
1044
+ "...##...X#.X"
1045
+ ],
1046
+ [
1047
+ "..G#......#.",
1048
+ ".#..#.#.#...",
1049
+ "X.X##...##.X",
1050
+ "X..#..#.....",
1051
+ ".....X.#....",
1052
+ "...X#X#....X",
1053
+ "....#....#..",
1054
+ "..##.#...#X.",
1055
+ "#...........",
1056
+ ".....X..#.#.",
1057
+ "#.#.#XX.X##.",
1058
+ "X.....X....."
1059
+ ],
1060
+ [
1061
+ "...X..X..##.",
1062
+ "..X..XX...#.",
1063
+ "#...........",
1064
+ ".#......##.#",
1065
+ "#......X..#X",
1066
+ "......X.....",
1067
+ "....#X.#.#..",
1068
+ "............",
1069
+ "#.#.#.....#.",
1070
+ ".....X..#...",
1071
+ ".....X.GX...",
1072
+ "..#...#...X."
1073
+ ],
1074
+ [
1075
+ "...#X#..X...",
1076
+ "#..##...#...",
1077
+ ".##X.#.....X",
1078
+ "....X..#....",
1079
+ "#.#....#X#.X",
1080
+ ".#..........",
1081
+ "..#.X.X..##.",
1082
+ "X...G....#..",
1083
+ ".#...X..X.X#",
1084
+ "..X......##X",
1085
+ ".X..........",
1086
+ "#X.....X...."
1087
+ ],
1088
+ [
1089
+ ".#XX..#..#.#",
1090
+ "#....X#..#..",
1091
+ "...#......G.",
1092
+ "...##..XX.#.",
1093
+ ".#......#.X.",
1094
+ "X.#..##X.X.X",
1095
+ "...#...X....",
1096
+ ".....#.#....",
1097
+ ".X....#..#X.",
1098
+ ".#..........",
1099
+ ".##......#..",
1100
+ "...X.#..#..#"
1101
+ ],
1102
+ [
1103
+ "#.X..X......",
1104
+ "#XX.XX.X####",
1105
+ ".##.......X.",
1106
+ "...#.#..#...",
1107
+ "........##..",
1108
+ "....X...X.XX",
1109
+ ".X#X###.XX..",
1110
+ ".......X...#",
1111
+ "X#..........",
1112
+ "#...#.X#X.X#",
1113
+ "X....X......",
1114
+ "....#X#...G."
1115
+ ],
1116
+ [
1117
+ "...##..#.#..",
1118
+ "..##X...X...",
1119
+ "......X.X#..",
1120
+ ".#........#X",
1121
+ "X.#.##......",
1122
+ ".#...#X...#G",
1123
+ ".X..........",
1124
+ "X#......X.#.",
1125
+ "..........##",
1126
+ "...#.......#",
1127
+ ".#..#..##..#",
1128
+ "....#......."
1129
+ ],
1130
+ [
1131
+ "....X.#X....",
1132
+ ".XX...#.#X..",
1133
+ "......##X...",
1134
+ ".........X.#",
1135
+ ".....#XX.X#.",
1136
+ ".##.#..#..X.",
1137
+ "...#..#.###.",
1138
+ "#.#....G.##.",
1139
+ "....X#.#....",
1140
+ "#.#...X.....",
1141
+ "..##.#.#...X",
1142
+ "...XX....X.#"
1143
+ ],
1144
+ [
1145
+ "...........X",
1146
+ ".#.#..#..##.",
1147
+ ".XX#....#.##",
1148
+ "#..G#..##X..",
1149
+ "..#.#..X..XX",
1150
+ "X#.X##......",
1151
+ "..#....##..X",
1152
+ "X........#..",
1153
+ "X..X........",
1154
+ "#.......X...",
1155
+ "............",
1156
+ ".#....#....."
1157
+ ],
1158
+ [
1159
+ "#.#.XX.X#...",
1160
+ "..#....#...X",
1161
+ "#........#.#",
1162
+ ".X.#.#.#....",
1163
+ ".#X....#....",
1164
+ "G#..#.#...X#",
1165
+ "....#....#..",
1166
+ ".X.#.#...#.#",
1167
+ "....#...#...",
1168
+ "..#.X..#.#..",
1169
+ "X..##...#.#.",
1170
+ "X#..#.#.#.X#"
1171
+ ],
1172
+ [
1173
+ "..##.##.X..#",
1174
+ "X#...##.....",
1175
+ "..G.......X.",
1176
+ "XX....#..X#X",
1177
+ "....#..XX.#.",
1178
+ "..#...X#..#.",
1179
+ ".#.#......X.",
1180
+ "#X......X#.#",
1181
+ "..X........X",
1182
+ "......X##..#",
1183
+ "..#...X.X...",
1184
+ "....##......"
1185
+ ],
1186
+ [
1187
+ ".....#......",
1188
+ "#.......#..X",
1189
+ "#X#......X..",
1190
+ ".#.....XX##.",
1191
+ ".X..#....#XX",
1192
+ ".X.###.#..##",
1193
+ ".X#.....#...",
1194
+ "..#..#..#...",
1195
+ ".G#...#XX...",
1196
+ ".X..X.....##",
1197
+ "#..#..X...X.",
1198
+ "##.###.#..#."
1199
+ ],
1200
+ [
1201
+ "..###...X#..",
1202
+ "#....#..X#..",
1203
+ ".#.......#X.",
1204
+ "..X.....#...",
1205
+ "....##...X.#",
1206
+ ".#.X#..G....",
1207
+ "....#..X.#.#",
1208
+ "#.X..##.###.",
1209
+ "XX.....#....",
1210
+ ".....X......",
1211
+ "X#X...X.##..",
1212
+ "....#....#.."
1213
+ ],
1214
+ [
1215
+ "..#X.#XXX#..",
1216
+ "X#.X...###X.",
1217
+ ".....#......",
1218
+ "X.#....X.#..",
1219
+ "..#...X#X...",
1220
+ "XX.X#.#...#.",
1221
+ "..#....#..#.",
1222
+ "##.##...#...",
1223
+ ".....#.....#",
1224
+ ".......#...X",
1225
+ "...#..#..##.",
1226
+ "...#...X.G.X"
1227
+ ],
1228
+ [
1229
+ "............",
1230
+ ".##.....#X.#",
1231
+ "X......X..#.",
1232
+ "....X.......",
1233
+ "....X...X.X.",
1234
+ "..#....#..#.",
1235
+ ".#X.#X#X###.",
1236
+ ".X.#.#......",
1237
+ ".#...###.X..",
1238
+ "...G......#.",
1239
+ "....#.#.#...",
1240
+ "X.#.....XX.X"
1241
+ ],
1242
+ [
1243
+ "......####.#",
1244
+ "...#X.#.X...",
1245
+ "##GX.....#..",
1246
+ "....#.#...#.",
1247
+ "......X.#X.X",
1248
+ ".......X..#.",
1249
+ ".#...#.X....",
1250
+ "#.......##..",
1251
+ ".##...#.X...",
1252
+ ".#.#.......#",
1253
+ ".XX..#..#..#",
1254
+ "....#..#.#X."
1255
+ ]
1256
+ ]
1257
+ }