Getting stuck with Pelmanism

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Getting stuck with Pelmanism

Post by richmond62 »

I was having a look over here: https://www.mackiev.com/hsa/index.html

and thought I'd have a go at "ripping off" their Demo stuff which Matthias Rebbe very kindly posted here: http://shoutsoftware.eu/hsa-demo

As a way of qualifying what I mean by "ripping off" I should explain that I find it quite stimulating to try to make functionally identical copies
of other people's software without having any access to their code. Obviously, not wishing to tread on their copyright, I have no intention of
releasing the end result as anything but a learning exercise in coding.

I started with "Find-the-Pair" [a.k.a. Pelmanism]:
Kiev.gif
link removed as superseded by link in later post.
cardz.gif
Which is all very fine as far as it goes.
I have used 12 rectangular graphic objects as my "cards", and set their backPatterns to various card images
as required.

HOWEVER; where I got a bit stumped was how to ensure that the game did not have the same card layout each time
(the stack here has the same layout each time), and thought about random but couldn't quite work out how to make
sure I didn't end up with 7 green cows.
Last edited by richmond62 on Wed Jun 22, 2016 8:12 pm, edited 2 times in total.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Getting stuck with Pelmanism

Post by Klaus »

Hi Richmond,

check my "simple_memory1" stack here: http://www.major-k.de/xtalk.html (scroll down a bit) and tear it apart :D


Best

Klaus
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Re: Getting stuck with Pelmanism

Post by richmond62 »

check my "simple_memory1" stack here: http://www.major-k.de/xtalk.html (scroll down a bit) and tear it apart
Thanks, Klaus . . .

I "love" it when you point out that I'm reinventing the wheel.
I'm downloading the stack right now.
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Re: Getting stuck with Pelmanism

Post by richmond62 »

"Holiday Memory" from Professor Sanke, here: http://www.sanke.org/MetaMedia/index.html

Looks worth a look as well.
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Re: Getting stuck with Pelmanism

Post by richmond62 »

Looking at both Klaus's and Prof. Sanke's stacks I decided to do things differently because:

1. I'm bloody minded.

2. I forgot.

So, here is a simple script that I thought up during a walk in the park today
(trying to keep my mind off the 38 C temperature coupled with 40% humidity).

I will use this in my Pelmanism game. Anybody who wants can use it wherever they find it useful.
pseudoR.png
Attachments
Pseudo-Random Order.livecode.zip
Here's the stack.
(957 Bytes) Downloaded 331 times
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Re: Getting stuck with Pelmanism

Post by richmond62 »

So, I integrated my pseudo-random routine with my Pelmanism stack:
Pelmanism.jpg
Click on the red triangle to see the "gory details".

https://www.dropbox.com/s/jbud7elz5grx4 ... e.zip?dl=0

I am well aware that purists will tell me that the thing can be done a whole lot more efficiently using string variables.
The reason I have used fields is so that everything is visible, and therefore somewhat easier to understand.

The thing still needs a spot of work to prevent all sorts of funny things happening if an end-user clicks on a disclosed card.
Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm

Re: Getting stuck with Pelmanism

Post by Ormente »

A shuffle function, if that can be useful. It works by swapping chars.
You can also set the randomSeed to an integer on stack or card opening to have a better randomness (with the milliseconds for example) or a controlled one (with a fixed integer).

Code: Select all

on mouseUp
    put shuffle(field "fABC") into fld "fXYZ"
end mouseUp

function shuffle aString
    put length(aString) into tSize
    repeat with tCharPos1 = 1 to tSize
        put random(tSize) into tCharPos2
        if tCharPos2 is not tCharPos1 then
            put char tCharPos2 of aString into tChar
            put char tCharPos1 of aString into char tCharPos2 of aString
            put tChar into char tCharPos1 of aString
        end if
    end repeat
    return aString
end shuffle
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Re: Getting stuck with Pelmanism

Post by richmond62 »

From a coding point of view your coding shuffle may be more elegant, faster and efficient.

However, I'm a bit like the farmer with a broken hay bailer: well, we could use this piece of wire
in the boot of my car, or we could order a spare part, and wait for 3 weeks for its delivery.

Having spent a lot of summers on an island where ordering and waiting for something is
both impractical and a long-standing joke, I'll always reach for the wire, string, Granny's tights,
or whatever is to hand and will do the job.
P_Dirty_Bit.gif
Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm

Re: Getting stuck with Pelmanism

Post by Ormente »

So, usefull it is not... Fine!
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Re: Getting stuck with Pelmanism

Post by richmond62 »

Not at all; your code is very useful.
Post Reply