OZONE Asylum
Forums
Server-Side Scripting - Oh my!
Sudoku WarJ style
This page's ID:
33127
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Here is some hard coding for base3 done lazy baboon style. This code uses the first transform that I use. At such a small size, only one interation of the first transform is all that is needed. In this case, less chaos is way much better by a way lot. I've made lots of progress for bigger bases, but for later. Until then, this code should keep you busy. [code] #!/usr/bin/env python import random # My code fu is lazy baboon, and it is the best! # the data structure is 4d instead of 2d # state[block_y][block_x][cell_y][cell_x] # mask[block_y}[block_x][cell_y][cell_x] def scanf1x(bx): pairs=[] for cy in range(3): for p in lpairs: fbit=1 for by in range(3): f0=mask[by][bx][cy][p[0]] f1=mask[by][bx][cy][p[1]] fbit=fbit&f0&f1 if fbit: pairs.append([bx,cy,p[0],p[1]]) return pairs def scanf1y(by): pairs=[] for cx in range(3): for p in lpairs: fbit=1 for bx in range(3): f0=mask[by][bx][p[0]][cx] f1=mask[by][bx][p[1]][cx] fbit=fbit&f0&f1 if fbit: pairs.append([by,cx,p[0],p[1]]) return pairs def swapf1x(bx,cy,p0x,p1x): for by in range(3): temp0=state[by][bx][cy][p0x] temp1=state[by][bx][cy][p1x] state[by][bx][cy][p0x]=temp1 state[by][bx][cy][p1x]=temp0 mask[by][bx][cy][p0x]=0 mask[by][bx][cy][p1x]=0 return def swapf1y(by,cx,p0y,p1y): for bx in range(3): temp0=state[by][bx][p0y][cx] temp1=state[by][bx][p1y][cx] state[by][bx][p0y][cx]=temp1 state[by][bx][p1y][cx]=temp0 mask[by][bx][p0y][cx]=0 mask[by][bx][p1y][cx]=0 return # lazy baboon main # globals, some are constants and some are not state=[[[[0,1,2],[3,4,5],[6,7,8]],[[6,7,8],[0,1,2],[3,4,5]],[[3,4,5],[6,7,8],[0,1,2]]], [[[2,0,1],[5,3,4],[8,6,7]],[[8,6,7],[2,0,1],[5,3,4]],[[5,3,4],[8,6,7],[2,0,1]]], [[[1,2,0],[4,5,3],[7,8,6]],[[7,8,6],[1,2,0],[4,5,3]],[[4,5,3],[7,8,6],[1,2,0]]]] mask=[[[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]]], [[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]]], [[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]]]] lpairs=[[0,1],[0,2],[1,2]] remap=['1','2','3','4','5','6','7','8','9'] random.shuffle(remap) # seed the chaos # vertical and horizontal # once each is all that is needed for i in range(3): rlist=scanf1x(i) random.shuffle(rlist) swapf1x(rlist[0][0],rlist[0][1],rlist[0][2],rlist[0][3]) rlist=scanf1y(i) random.shuffle(rlist) swapf1y(rlist[0][0],rlist[0][1],rlist[0][2],rlist[0][3]) # output nested a bit deep, but it sure is pretty cout='' print('') for d in range(3): for c in range(3): for b in range(3): for a in range(3): cout=cout+' '+remap[state[d][b][c][a]] cout=cout+' ' cout=cout+'\n' cout=cout+'\n' print(cout) [/code]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »
Maximum Security
OZONE
DHTML/Javascript
Server-Side Scripting - Oh my!
CSS - DOM - XHTML - XML - XSL - XSLT
Stupid Basic HTML
Visual Therapy
Photoshop
Photoshop Pong, Anyone?
***WARNING*** BIG SIG APPROACHING
Photography
3D Modelling & Rendering
Multimedia/Animation
Print Graphics
Holding Pens
Philosophy and other Silliness
Outpatient Counseling
Site reviews!
Mad Scientists' Laboratory
Getting to know the Grail