5 Cents for today..

Started by newdep, October 10, 2005, 06:07:05 AM

Previous topic - Next topic

newdep

I posted some scripts again at http://nodep.nl/newlisp/index.html">http://nodep.nl/newlisp/index.html



If you like to see your PC work?! use the Latin Square script ;-)



Enjoy, Norman.
-- (define? (Cornflakes))

Lutz

#1
Beautiful the latin square, even the fan in my Mac Mini came on trying a 9-square ;), playing with this thing is addictive.



Lutz

newdep

#2
hehe..Its a load indeed... And im still running a Square 15..dont think that will finish today tough ;-)
-- (define? (Cornflakes))

Fanda

#3
Nice!  ;-)



There is an interesting case:

Latin Square needs 'randomize' to return ALL possible variants of sequence, which means even the SAME sequence.



This case (and similar ones) will never get solved (infinite loop):
--- Running!

(2 3 1)
(3 1 2)


Lutz - could we get optional parameter in 'randomize'?

=> (randomize '(1 2 3) true)  => '(1 2 3)

=> returns ALL possible variants, INCLUDING the SAME sequence



... I feel kinda stupid now, when I proved that randomize (or shuffle :-) will sometimes return the same sequence, than we repaired it and now I would like to have a parameter to return the same sequence again :-)))



Fanda

Fanda

#4
ps: We could also vote if optional 'true' means ALL or (ALL except the SAME). If it's not too late...



Fanda

Lutz

#5
let's go with 'true' for randomizing with repetition



Lutz

newdep

#6
So that means the current random  functions are unique?



Cant we better change the 'seed behaviour instead?



Regards, Norman.
-- (define? (Cornflakes))

newdep

#7
Mmmm also intresting is that i dont have this (1 2 3) problem on my linux machine but i do have it on my windows XP machine....



???
-- (define? (Cornflakes))

Fanda

#8
Current 'randomize' never returns the same sequence (and you usually want this).



Try this test:
; TEST for randomize
(setq L '(1 2 3))
(setq r '())
(dotimes (x 10000)
  (push (randomize L) r))

(setq r (unique r))

(println r)
(if (find L r)
  (println "ERROR!")
  (println "OK!"))


You shouldn't find '(1 2 3) in the result.



Fanda

newdep

#9
This Unique random issue...Intresting because I have here a program that checks on UniqueNess inside my codebase and i failed so far ( that explains more then my assumption that the total of random occeurenances still had to come ;-)...



So when was this changed? (I like this unique option saves me some work..)



I first thought it was related to the 'Seed ..but its not..not even wehn you place a new 'seed inside the loop...Mmm funny that i did not notice this..



Happy that this was brought up...



By the way..it also fails on linux.. (correction on the above)



Regards, Norman.
-- (define? (Cornflakes))

Fanda

#10
I am not sure, if I understand...



The only thing is: 'randomize' function without that optional 'true' will mix the output list as long as it is the same as the input list - you always get something different than you started with.

If you use optional 'true' (useful only in the next version of newLISP) you get all the cases possible - even the same list you started with.



Fanda

newdep

#11
Ah yes I overlooked this in the manual

-> randomize will always return a sequence different from the previous one.
-- (define? (Cornflakes))

Fanda

#12
Now, just add the 'true' to randomize functions :)



Fanda

Lutz

#13
The 'true' flag in 'randomize' is already there, see the manual ;)



Lutz

Fanda

#14
PS: My favorite game:  http://www.planarity.net/">http://www.planarity.net/