Skip to Content
 

Hex perms

4 replies [Last post]
JustActCasual
JustActCasual's picture
Offline
Joined: 11/20/2012

I'm working on a game right now with hex tiles, where each tile has 3 link sides. Trying to find all the different distributions of the 3 linking sides, I got 20 different permutations (clockwise from type 1 link):

123000 120300 120030 120003
102300 102030 102003
100230 100203
100023
132000 130200 130020 130002
103200 103020 103002
100320 100302
100032

Am I missing any? I'm thinking for 4 links there would be 60 perms, for 5 or 6 there would be 120, and for 2 there would be 5 (obviously with 1 link there is only 1 permutation).

I'm thinking for a tile with x sides and n links there are ((x-1)!)/((x-n)!) permutations when n is less than or equal to x.

Am I right on this? It's been a while since I did this math.

PS. What's the math doing this with a polyhedral die? It seems like it's just ((x-2)!)/((x-n)!).

pelle
pelle's picture
Offline
Joined: 08/11/2008
looks good to me

Too lazy/tired to do the maths myself, but it looks good:

user=> (count (clojure.math.combinatorics/combinations [1 2 3 4 5 6] 3))
20
* 3! = 120

EDIT: Checking the all numbers just in case:
1 -> 6 * 1! = 6
2 -> 15 * 2! = 30
3 -> 20 * 3! = 120
4 -> 15 * 4! = 360
5 -> 6 * 5! = 720
6 -> 1 * 6! = 720

EDIT2: Duh, permutations you wanted, so taking the number of possible subsets of size n and multiplying by n! then. Didn't think about them as 3 different types of links, only picking 3 sides to link... Added above.

pelle
pelle's picture
Offline
Joined: 08/11/2008
I think you have forgot about

Heh. OK, I forgot about them being rotationally symmetric. Dividing all my numbers by 6 I think we get all the same results. :)

nand
nand's picture
Offline
Joined: 07/27/2008
JustActCasual wrote:I'm

JustActCasual wrote:
I'm working on a game right now with hex tiles, where each tile has 3 link sides. Trying to find all the different distributions of the 3 linking sides, I got 20 different permutations (clockwise from type 1 link):

I confirm 20 permutations, I've got them with this line for nanDECK:

PX[list]6=1|2|3|0|0|0

The P flag stands for Permutations, and the X flag removes rotations (the un-rotated list is composed of 720 elements).

Note: nanDECK can also draws the 20 tiles, for example:

PX[list]6=1|2|3|0|0|0
[all]="1-{(list)}"
[list1]=[list:1,1]
[list2]=[list:2,1]
[list3]=[list:3,1]
[list4]=[list:4,1]
[list5]=[list:5,1]
[list6]=[list:6,1]
macro=hexside,(color),(side)
polygon=[all],10%,10%,80%,80%,6,0,(color),empty,0.5,(side),(side)
end
macro=choice,(seq),(side)
if=[(seq)]=0
hexside=#000000,(side)
elseif=[(seq)]=1
hexside=#0000FF,(side)
elseif=[(seq)]=2
hexside=#00FF00,(side)
elseif=[(seq)]=3
hexside=#FF0000,(side)
endif
end
cardsize=4,4
choice=list1,1
choice=list2,2
choice=list3,3
choice=list4,4
choice=list5,5
choice=list6,6

This is the result:
http://www.bgdf.com/node/7739

JustActCasual
JustActCasual's picture
Offline
Joined: 11/20/2012
Thanks for the help

Thanks for the help guys!

NanDeck, your program looks awesome, looking forward to trying it.

Syndicate content


forum | by Dr. Radut