awk - big
#awk - big ThisThis didn't turn out as short as I had hoped, but I took a slightly different approach to dealing with the graph, so I'm posting the ungolfed version anyway.
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack Internal#awk - big ThisThis didn't turn out as short as I had hoped, but I took a slightly different approach to dealing with the graph, so I'm posting the ungolfed version anyway.
#awk - big This didn't turn out as short as I had hoped, but I took a slightly different approach to dealing with the graph, so I'm posting the ungolfed version anyway.
This didn't turn out as short as I had hoped, but I took a slightly different approach to dealing with the graph, so I'm posting the ungolfed version anyway.
#awk - big This didn't turn out as short as I had hoped, but I took a slightly different approach to dealing with the graph, so I'm posting the ungolfed version anyway.
I took advantage of the fact that an icosahedron (20 sided polyhedron) under rotations preserving orientation is isomorphic to the alternating group of degree 5 (5 element permutations having an even number of even length cycles). I then choose two permutations with cycle length 5 as "left" and "right", and I choose one permutation with cycle length 2 as "back". Using these, I build up the graph from one room by walking the Hamiltonian path (2xRRRLLLRLRL, using 3xRB in each room to capture the 3 possible directions).
function meta(z,a,b,c,d) { if(z==COMPOSE) { split(a,c,""); split(b,d,""); return c[d[1]]c[d[2]]c[d[3]]c[d[4]]c[d[5]]; } if(z==WALK) { split(R" "R" "R" "L" "L" "L" "R" "L" "R" "L,c); for(b = 1; b <= 20; b++) { map[a] = b; a = meta(COMPOSE,meta(COMPOSE,a,R),B); map[a] = b; a = meta(COMPOSE,meta(COMPOSE,a,R),B); map[a] = b; a = meta(COMPOSE,meta(COMPOSE,a,R),B); a = meta(COMPOSE, a, c[b % 10 + 1]); } } if(z==TEST) { a = map[meta(COMPOSE,U,L)]; b = map[meta(COMPOSE,U,R)]; c = map[meta(COMPOSE,U,B)]; if(a==W||b==W||c==W) print "You smell the wumpus"; if(a==P||b==P||c==P) print "You feel a breeze"; if(map[U]==W) { print "You have been eaten by the wumpus"; exit; } if(map[U]==P) { print "You have fallen into a bottomless pit"; exit; } } if(z==ARROWTEST) { if(A==W) { print "You have slain the wumpus!"; exit; } else { for(a in p) if(map[a]==W) break; W=map[meta(COMPOSE,a,v[int(rand()*3)+1])]; } } } BEGIN { COMPOSE = 0; WALK = 1; TEST = 2; ARROWTEST = 3; L = 35214; R = 35421; B = 35142; split(R" "L" "B,V); meta(WALK,L); W = int(rand()*19)+2; P = int(rand()*19)+2; U = L; meta(TEST); } { d=int($0/10); m=$0%10; if(m==5) U = meta(COMPOSE,U,V[d]); else if(m==4) { A = map[meta(COMPOSE,U,V[d])]; meta(ARROWTEST); } meta(TEST); }