It is currently April 19th, 2024, 7:18 am

Sudoku generator in Lua

Discuss the use of Lua in Script measures.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Sudoku generator in Lua

Post by balala »

I'm working on a Sudoku skin. The skin itself works well, but I need a grid generator. For this I found a lua script on internet, I downloaded it and modified a bit to match my needs. The script should generate a random numbers, but if I run it, it always generates the same grid. After a few days of work, now I found something very strange: the described situation occurs on my computer, but when I tried it onto another computer, the numbers had been generated randomly. If I refresh the skin on my computer, always get the same numbers, if I refresh it onto the other computer, always get different numbers. I thought that the differences between Rainmeter versions cause it: I had a 3.1 and on the other computer has a 3.0. To try it I've downgraded my Rainmeter to the same version as on the other computer. But no change about the result: my computer generates the same result always. We have the same Windows version: Win7 Ultimate SP1. The only difference is the mine is a 32 bit and the other is a 64 bit version.
Anyone have an idea about what is the cause of this strange difference and how can it be avoided?
Thank you
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Sudoku generator in Lua

Post by jsmorley »

Since you don't provide a single thing like any code or links or anything else that might help us to do any research, my answer is pretty simple.

"It apparently doesn't work on 32bit the same way it does on 64bit Windows."

Hope this helps, let us know if we can solve any other issues...
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sudoku generator in Lua

Post by balala »

Ok, here is the skin. The skin isn't finished, I still have to work a lot onto it, but on refresh the content of Numbers.inc should be updated and it isn't on the 32bit Windows, but it is on the 64bit. Can I ask who has a 32bit system to make a try, load the skin and see the generated numbers after a refresh: here the numbers are: Num11=1, Num12=5, Num13=8, Num14=2 and so on. After every refresh the same numbers are generated. If I change them manually, these values are regenerated. But on the 64bit system, after every refresh comes new values. I'm asking those people who can help me, to provide me if you have a 32 or 64bit system and the result (if the values are updated on every refresh or not).
Thanks.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sudoku generator in Lua

Post by balala »

It seems that I found the solution: in the lua script the math.randomseed(os.time()*1000) line should be modified to math.randomseed(os.time()). I don't know why the initial script works on a 64bit system and don't work onto a 32bit, but this was the solution. After this modification, now the numbers are indeed generated randomly.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sudoku generator in Lua

Post by balala »

In the meantime I finished the skin, it is available here:
http://balazslaci.deviantart.com/art/Sudoku-1-442079548
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Sudoku generator in Lua

Post by eclectic-tech »

balala wrote:In the meantime I finished the skin, it is available here:
http://balazslaci.deviantart.com/art/Sudoku-1-442079548
Nice work! (And a lot of it!) :thumbup: