Getting stuck with Pelmanism
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Getting stuck with Pelmanism
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]:
link removed as superseded by link in later post.
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.
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]:
link removed as superseded by link in later post.
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.
Re: Getting stuck with Pelmanism
Hi Richmond,
check my "simple_memory1" stack here: http://www.major-k.de/xtalk.html (scroll down a bit) and tear it apart
Best
Klaus
check my "simple_memory1" stack here: http://www.major-k.de/xtalk.html (scroll down a bit) and tear it apart

Best
Klaus
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Getting stuck with Pelmanism
Thanks, Klaus . . .check my "simple_memory1" stack here: http://www.major-k.de/xtalk.html (scroll down a bit) and tear it apart
I "love" it when you point out that I'm reinventing the wheel.
I'm downloading the stack right now.
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Getting stuck with Pelmanism
"Holiday Memory" from Professor Sanke, here: http://www.sanke.org/MetaMedia/index.html
Looks worth a look as well.
Looks worth a look as well.
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Getting stuck with Pelmanism
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.
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.
- Attachments
-
- Pseudo-Random Order.livecode.zip
- Here's the stack.
- (957 Bytes) Downloaded 241 times
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Getting stuck with Pelmanism
So, I integrated my pseudo-random routine with my Pelmanism stack:
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.
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.
Re: Getting stuck with Pelmanism
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).
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
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Getting stuck with Pelmanism
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.
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.
Re: Getting stuck with Pelmanism
So, usefull it is not... Fine!
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Getting stuck with Pelmanism
Not at all; your code is very useful.