Note that there are some explanatory texts on larger screens.

plurals
  1. POSearch 3d points to find if any are in a row
    text
    copied!<p>I'm just doing this to try improve my skills a little, I'm trying to recreate a game I thought of years ago when I was bored in school.</p> <p>Basically it's kinda like a 3d connect 4, also supposed to flip over so it'll screw up your ideas if your spacial awareness isn't great. I've tried making a very basic display in python (I know how to build things in maya, not in python, so for now I'll stick with a rubbish looking design until I get it working), and it can also lookup the points and place them in.</p> <p>However, I'm stuck on actually reading these points to find any rows of 4. I know I could physically type it all out, but I'm sure there would be a much better way.For example, each corner point could go either x, y, z, xy, xz, yz, or xyz, I don't expect anyone to do the code for me, but it'd be appreciated if you could tell me a way of calculating this without typing out each possible combination (I think there's 76 in total unless I missed any)</p> <p>I would have done a loop if not for the diagonals, but I have no idea how I'd go about checking these</p> <p>Cheers</p> <p>The code so far is here -</p> <pre><code>#x(width),z(depth),y(height),playernum points=[1,4,1,1],[2,1,3,1],[4,4,1,2],[3,4,1,2],[2,4,1,2],[1,1,2,1] for j in range(1,5): #set indent spaces=" " #draw top print spaces + "________________" #search points on certain level validPointsY=[] for point in points: if point[2]==5-j: validPointsY.append( point ) #draw middle for i in range(1,5): #search points on certain row validPointsZ=[] for point in validPointsY: if point[1]==5-i: validPointsZ.append( point ) #place points in correct box point1=" " point2=" " point3=" " point4=" " for point in validPointsZ: if point[0]==1: point1=str(point[3]) if point[0]==2: point2=str(point[3]) if point[0]==3: point3=str(point[3]) if point[0]==4: point4=str(point[3]) #remove one from space spaces = spaces[:-1] print spaces + "/ "+point1+" / "+point2+" / "+point3+" / "+point4+" /" spaces = spaces[:-1] print spaces + "/___/___/___/___/" </code></pre> <p>Just for the record, the game is quite fun if you have nothing to do, obviously it's not gonna look great at all from this though haha</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload