## Simplicity

Game development specific discussions.
3622
Posts: 16
Joined: Mar 14, 2015 23:53

### Simplicity

Simplicity is a 2D sliding block puzzle, my small and simple lockdown offering.
Just get the red block to the top left corner.
Tested on Linux 64 but should work on 32 bit and Windows.
It may amuse someone for 2 minutes.

Code: Select all

`'      simplicity.basscreenres 400,400width , 400 / 16const as ulong mask = 4167140895const as double pi = 3.1415926535897932dim as integer i, j, movetype board    bb as ulong    colour as integerend type   dim as board piece(3)data 8320, 49data 1572864, 55data 4192, 40data 17170432, 44for i = 0 to 3    read piece(i).bb    read piece(i).colournext''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''sub display(piece() as board, move as integer)dim as integer i, j, k, r, cwindowtitle "Simplicity Move : " +str(move)screenlock()clsprint "Get The Red" print " One here !" for i = 0 to 3    k = -1    for j = 5 to 26        if bit(mask, j) = 0 then            k += 1                     if bit(piece(i).bb, j) = -1 then                 r = ( 3 - (k mod 4)) * 100                c = ( 3 - int(k / 4)) * 100                line (r, c) - (r + 100, c + 100), piece(i).colour, bf            end if            end if    nextnext            screenunlock()    end sub''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''function getmove( piece() as board) as integerdim as integer x, y, buttons, res, i ,j, oldx, oldy, r, c, target, z, dumdim as ulong all,temp for i = 0 to 3    all or= piece(i).bbnextdo     res=getmouse(x,y,,buttons)    if inkey = chr(255,107) then end    if res = 0 then          oldx = x        oldy = y        end if    res=getmouse(x,y,,buttons)    if res = 0 then                    if (buttons and 1) then            z=1            dum = point(x, y)        end if    end if          loop while z = 0 do    getmouse(x,y,,buttons)loop while (buttons and 1)r=x-oldxc=y-oldyselect case dum    case 49        target = 0    case 55        target = 1    case 40        target = 2    case 44        target = 3    case else        return 0                        end selecttemp = 0if r<> 0 or c<> 0 then                if abs(r) > abs(c) then        if r > 0 then temp = (piece(target).bb  shr 1)        if r < 0 then temp = (piece(target).bb  shl 1)    end if            if abs(r) < abs(c) then        if c > 0 then temp = (piece(target).bb  shr 6) or (piece(target).bb shl(26))        if c < 0 then temp = (piece(target).bb  shl 6) or (piece(target).bb shr(26))    end if                if (temp and mask) = 0 then        if ((all xor piece(target).bb) and temp) = 0 then            piece(target).bb = temp            return 1        end if    else        return 0        end if    end ifreturn 0end function''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''function wincheck(piece() as board) as integerdim as integer jif piece(2).bb = 68681728 then    circle (150,50),25,14, , , , f    circle (140,45),5,0, , , , f    circle (160,45),5,0, , , , f    for j = 1 to 30 step 2        circle (150,55),15,0,pi , 2 * pi, 0.54 + (j * .005)    next               sleep 2000    circle (160,45),5,14, , , , f            circle (160,45),5,0, pi, 2 * pi, .75, f    sleep 500    circle (160,45),5,0, , , , f            return 1end if    return 0end function'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''    maindisplay(piece(), move)do    while getmove(piece()) = 0    wend    move += 1    display(piece(), move)    sleep 50loop while wincheck(piece()) = 0sleep`
Last edited by 3622 on Aug 19, 2020 21:12, edited 1 time in total.
Posts: 2123
Joined: May 24, 2007 22:10
Location: The Netherlands

### Re: Simplicity

Nice, I did need more than 2 minutes.
grindstone
Posts: 744
Joined: May 05, 2015 5:35
Location: Germany

### Re: Simplicity

In principle it works here with WinXP 32, but mostly it takes 2 or 3 attempts of dragging before the piece really moves.
Posts: 2123
Joined: May 24, 2007 22:10
Location: The Netherlands

### Re: Simplicity

I changed the sleep 50 to sleep 1. Then better response.
xlucas
Posts: 287
Joined: May 09, 2014 21:19
Location: Argentina

### Re: Simplicity

Nice game! Reminds me of a physical board game I had as a child called "Trabado". It's this one:

It surely exists outside the Spanish speaking world with a different name.

By the way, I solved Simplicity in over 2 minutes.... maybe over 5. At a point, I started to think it was going to take a lot longer, but it's interesting how you change your mind after making another move. I love this kind of games :)

I am using GNU/Linux 64 bit and did get the difficulty for dragging the pieces, but it does work well.

PS: I found it! The traditional form of this game is called Klotski
D.J.Peters
Posts: 8132
Joined: May 28, 2005 3:28
Contact:

### Re: Simplicity

Really nice well done it's fun to play.

Joshy
3622
Posts: 16
Joined: Mar 14, 2015 23:53

### Re: Simplicity

Thanks to you all for trying Simplicity and for your replies.

Badidea, I tried changing Sleep to 1, and on my setup, PCLinuxos KDE 5Plasma, it made no noticeable difference but rebooting to same OS
under XFCE there was a definite improvement. However, my mouse setup in XFCE is very sensitive ( the mouse cursor flys around the screen
with barely any mouse movement) so that may be of some significance.

Anyhow, I have made a very small change to the original code and this seems to make the responsiveness better, on my setup at least.

I downloaded a small PDF about 10 years ago which was my inspiration for this. Here is a link to the same info : http://www.mathpuzzle.com/MAA/31-Sliding%20Block%20Puzzles/mathgames_12_13_04.html

My best score is 31 moves. I hope this can be bettered.
Tourist Trap
Posts: 2901
Joined: Jun 02, 2015 16:24

### Re: Simplicity

3622 wrote:My best score is 31 moves. I hope this can be bettered.

How damn, 205 moves before I could see the smiling face. Good game anyway :)