﻿ 15 number tile game thing c3 editition
23 May, 2013, 03:16:14
 OmnomIRC You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

 Pages: [1]   Go Down
 Author Topic: 15 number tile game thing c3 editition -  (Read 1094 times) 0 Members and 1 Guest are viewing this topic.
Geekboy1011
The Oneironaut
Support Staff
LV10 31337 u53r (Next: 2000)

Offline

Gender:
Date Registered: 11 June, 2009, 01:27:44
Location: Buried in cherry flavored source code
Posts: 1502

Topic starter
Total Post Ratings: +88

 « on: 10 April, 2010, 07:23:19 » 0

ok well to learn matrices for crimson i took on a hopefully small side project which is a 15 number slider game
but alas im having a few issues most notably with shuffling the board
 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 :Disp "SIZE?":Input X // Adds a "?" but its your choice:1→C:DelVar ADelVar B{X,X→dim([J]:For(A,1,X:For(B,1,X:C→[J](A,B:C+1→C:End:End:1→B:X+X/10^(1+int(log(X→l   // Make sure 10^( is one token:Pause L:0→[J](X,X:ClrHome:For(θ,B,100:Output(1,1,B:Output(6,6,C:Output(4,4,det(4,0:C→n:0→C:Repeat C≠n:randInt(1,4→C:End:If C=1 and .1≠fPart(L:Then  // Rearranged second term:‾1→M:Goto UD:End:If C=2 and X≠iPart(L:Then:1→M:Goto LR:End:If C=3 and (X/10)≠fPart(L:Then:1→M:Goto UD:End:If C=4 and 1≠iPart(L:Then:‾1→M:Goto LR:End:End:Lbl UD:[J](iPart(L),10fPart(L→A:[J](iPart(L),10fPart(L+M→[J](iPart(L),10fPart(L:A→[J](iPart(L),M+10fPart(L:L+M/10→L:B+1→B:End:End:Lbl LR:[J](iPart(L),10fPart(L→A:[J](iPart(L)+M,10fPart(L→[J](iPart(L),10fPart(L:A→[J](iPart(L)+M,10fPart(L:L+M→L:B+1→B:End:End:Disp [J]
* Geekboy1011 thanks sirCmpwn for optimizations

well my problem with the current code is my shufle routine is  to slow and inaccurate to say the least not always providing a good shuffle

so yeah my question is any one know a better shuffle routine ??

restrictions on the routine

1 cant just be randomly placed as it will be a 50 50 chance of a unsolvable puzzle

i need some help please and thank you
 « Last Edit: 10 April, 2010, 07:26:16 by Geekboy1011 » Logged

Yumé - The Eternal Dreams(tsukasaZX's project): music making working on second piece
PROJECT:TiX - planning stages almost done few more things to think about then i start coding so coding should commence tommorow or the NULL of NULL yay
Project/Mod Cadan: CD  -   My (first?!?) mod of the cadan engine for a not so demoified version of the game : HOLD :Is here
Beta testing: -  Correlation: Wordwrap abuse IF Adventure style
cooliojazz
Support Staff
LV7 Elite (Next: 700)

Offline

Gender:
Date Registered: 23 May, 2009, 19:28:11
Posts: 614

Total Post Ratings: +52

 « Reply #1 on: 10 April, 2010, 08:39:50 » 0

Well, I'm not sure how the heck yours works, and i got lots of syntax errors and stuffs, but after "fixing" it i think this runs faster:
 123456789101112131415161718192021222324252627 :Input "?x? ",θ:{θ,θ→dim([A]:0→C:For(A,1,θ:For(B,1,θ:C→[A](A,B:C+1→C:End:End:Disp [A]:1→X:1→Y:For(A,1,θ2:randInt(1,4→B:X→W:Y→Z:Repeat X≠W or Y≠Z:randInt(1,4→B:X+(B=3)-(B=1→X:Y+(B=4)-(B=2→Y:X+(X=0)-(X=θ+1→X:Y+(Y=0)-(Y=θ+1→Y:End:[A](Z,W→C:[A](Y,X→[A](Z,W:C→[A](Y,X:End:Disp [A]
thats what you want right?  It just shuffles it?  This does it only as many times as there are peices, cause past that it's a bit pointless... and i changed the first tile to "0" to represent the blank tile...
 Logged

Spoiler for Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here
The Rest Should Be Here (Bandcamp)
SirCmpwn
Guest
 « Reply #2 on: 10 April, 2010, 16:37:22 » 0

Here is an example of how to suffle L1 using the Fisher-Yates algorithm:
 1234567 dim(L1→NFor(I,1,NrandInt(I,N→AL1(A→BL1(I→L(AB→L1(IEnd

A faster method would be to do this (stolen from Weregoose):
 12 rand(dim(L1→L2SortA(L2,L1
 « Last Edit: 10 April, 2010, 16:42:15 by SirCmpwn » Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)

Online

Gender:
Date Registered: 25 August, 2008, 07:00:21
Posts: 50224

Total Post Ratings: +2615

 « Reply #3 on: 10 April, 2010, 19:19:14 » 0

Interesting it would remind me of the mini game in Final Fantasy 1.

I wonder if in future versions it could have support for bigger shuffle boards like 5x5 and 6x6?
 Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Builderboy
Physics Guru

Online

Gender:
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642

Total Post Ratings: +589

 « Reply #4 on: 10 April, 2010, 19:56:20 » 0

Here is an example of how to suffle L1 using the Fisher-Yates algorithm:
 1234567 dim(L1→NFor(I,1,NrandInt(I,N→AL1(A→BL1(I→L(AB→L1(IEnd

A faster method would be to do this (stolen from Weregoose):
 12 rand(dim(L1→L2SortA(L2,L1

Remember to Sir, you cant just randomize the tiles around because exactly half of all combinations cannot be solved.
 Logged

SirCmpwn
Guest
 « Reply #5 on: 10 April, 2010, 19:57:51 » 0

Here, take a look at this thread:
http://www.unitedti.org/forum/index.php?showtopic=4685&st=0&p=134765&hl=shuffle&fromsearch=1&#entry134765

They talk about how to shuffle only solvable shuffles.
 Logged
Geekboy1011
The Oneironaut
Support Staff
LV10 31337 u53r (Next: 2000)

Offline

Gender:
Date Registered: 11 June, 2009, 01:27:44
Location: Buried in cherry flavored source code
Posts: 1502

Topic starter
Total Post Ratings: +88

 « Reply #6 on: 10 April, 2010, 22:56:22 » 0

hmm  ty all so much i havent tried coolio's methosd yet stil going to try

@sir im shuffling a matrix not a list X.x so im not sure how those routines would work X.x
 « Last Edit: 10 April, 2010, 22:58:24 by Geekboy1011 » Logged

Yumé - The Eternal Dreams(tsukasaZX's project): music making working on second piece
PROJECT:TiX - planning stages almost done few more things to think about then i start coding so coding should commence tommorow or the NULL of NULL yay
Project/Mod Cadan: CD  -   My (first?!?) mod of the cadan engine for a not so demoified version of the game : HOLD :Is here
Beta testing: -  Correlation: Wordwrap abuse IF Adventure style
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)

Online

Gender:
Date Registered: 25 August, 2008, 07:00:21
Posts: 50224

Total Post Ratings: +2615

 « Reply #7 on: 11 April, 2010, 05:42:33 » 0

Mhmm, what would be the equivalent for matrices? I never actually messed around with shuffling. Else another method would be to switch to lists, but that means some more calculations in the code since a list is in one row
 Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Geekboy1011
The Oneironaut
Support Staff
LV10 31337 u53r (Next: 2000)

Offline

Gender:
Date Registered: 11 June, 2009, 01:27:44
Location: Buried in cherry flavored source code
Posts: 1502

Topic starter
Total Post Ratings: +88

 « Reply #8 on: 11 April, 2010, 05:44:45 » 0

im thinking of fliiping over to a list actually found a nice and by the looks of it fast shuffle routine

http://omnimaga.pastebin.com/BzxgrEMr

although there has to be some kinnd of algoritm to it or if im real lazy just shuffle the list and then make it a matrix
 Logged

Yumé - The Eternal Dreams(tsukasaZX's project): music making working on second piece
PROJECT:TiX - planning stages almost done few more things to think about then i start coding so coding should commence tommorow or the NULL of NULL yay
Project/Mod Cadan: CD  -   My (first?!?) mod of the cadan engine for a not so demoified version of the game : HOLD :Is here
Beta testing: -  Correlation: Wordwrap abuse IF Adventure style
meishe91
Super Ninja
Members
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Last Login: 02 May, 2013, 23:54:14
Date Registered: 05 March, 2010, 05:39:48
Posts: 2965

Total Post Ratings: +102

 « Reply #9 on: 11 April, 2010, 06:02:24 » 0

Well if you need I could make you a list to matrix program.
 Logged

For the 51st time, that is not my card! (Magic Joke)
Geekboy1011
The Oneironaut
Support Staff
LV10 31337 u53r (Next: 2000)

Offline

Gender:
Date Registered: 11 June, 2009, 01:27:44
Location: Buried in cherry flavored source code
Posts: 1502

Topic starter
Total Post Ratings: +88

 « Reply #10 on: 11 April, 2010, 06:20:09 » 0

ty but no thanks a simpleish for loop will suffice ^_^

still need to test that on calc though for speed so yeah
 Logged

Yumé - The Eternal Dreams(tsukasaZX's project): music making working on second piece
PROJECT:TiX - planning stages almost done few more things to think about then i start coding so coding should commence tommorow or the NULL of NULL yay
Project/Mod Cadan: CD  -   My (first?!?) mod of the cadan engine for a not so demoified version of the game : HOLD :Is here
Beta testing: -  Correlation: Wordwrap abuse IF Adventure style
meishe91
Super Ninja
Members
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Last Login: 02 May, 2013, 23:54:14
Date Registered: 05 March, 2010, 05:39:48
Posts: 2965

Total Post Ratings: +102

 « Reply #11 on: 11 April, 2010, 06:48:49 » 0

Well ya I know I just meant I could write code to do it because it'd be similar to my list to string routine.
 Logged

For the 51st time, that is not my card! (Magic Joke)
willrandship
Omnimagus of the Multi-Base.
LV11 Super Veteran (Next: 3000)

Offline

Gender:
Date Registered: 11 April, 2010, 03:08:32
Location: Between Venus and Mars
Posts: 2638

Total Post Ratings: +66

 « Reply #12 on: 13 April, 2010, 05:36:53 » 0

I think solvable algorithms would be a good idea. Otherwise, people would complain.

Eventually, made you could add picture support! If you used XLib or Celtic III I imagine a sprite could fit into each tile quite easily.
 Logged

Geekboy1011
The Oneironaut
Support Staff
LV10 31337 u53r (Next: 2000)

Offline

Gender:
Date Registered: 11 June, 2009, 01:27:44
Location: Buried in cherry flavored source code
Posts: 1502

Topic starter
Total Post Ratings: +88

 « Reply #13 on: 13 April, 2010, 05:39:00 » 0

i am planning to add picture support ^_^

by algorithems i meant a way to check to see if the generated grid is valid at the start than using a shuffle
 Logged

Yumé - The Eternal Dreams(tsukasaZX's project): music making working on second piece
PROJECT:TiX - planning stages almost done few more things to think about then i start coding so coding should commence tommorow or the NULL of NULL yay
Project/Mod Cadan: CD  -   My (first?!?) mod of the cadan engine for a not so demoified version of the game : HOLD :Is here
Beta testing: -  Correlation: Wordwrap abuse IF Adventure style
 Pages: [1]   Go Up