CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: unknownloner on June 11, 2015, 09:41:52 AM

Title: Sudoku CSE [ASM] [CSE]
Post by: unknownloner on June 11, 2015, 09:41:52 AM
There's already sudoku games out there for the CSE, but I felt like making one in assembly for funs, as a quick break from doing stuff with my isometric renderer. (http://i.imgur.com/6g9wxFK.png)

Anyways, I've got some code from an old attempt I might re-use, not sure yet, but right now I'm just generating puzzles.
I wrote a puzzle generator in haskell to see if I could do it, and it works pretty well, so I'm letting that run for a bit.

As much as I'd like to generate puzzles on the CSE, it turns out proper puzzle generation can be a bit processor heavy. Instead, I'm going to focus on making the core of the game small/lightweight, and then (if I have enough puzzles) release a few packs as either different programs, or a collection of appvars. Really it just depends on how compressible the puzzle data ends up being.

Screenshots tomorrow maybe if I get any coding done. And by tomorrow I mean today, I'm going to sleep right now @ 6 A.M.
Title: Re: Sudoku CSE [ASM] [CSE]
Post by: Snektron on June 11, 2015, 10:12:10 AM
Oh cool :) also the isometric renderer looks really cool too :)
Title: Re: Sudoku CSE
Post by: Unicorn on June 11, 2015, 05:41:01 PM
Yay sudoku! I suggest AppVars for storage though.
Title: Re: Sudoku CSE
Post by: unknownloner on June 11, 2015, 06:18:32 PM
Problem with appvars is it makes loading way more complicated, especially if they can be archived.
Title: Re: Sudoku CSE
Post by: alexgt on June 11, 2015, 07:27:54 PM
Cool, :) the CSE or CE is my next calc ;)

Also the Isometric renderer looks awesome :)
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 11, 2015, 08:03:17 PM
You could maybe include some pre-made puzzles if speed is too much of an issue. I would like to see Sudoku on the CSE. That isometric tilemapper also looks nice. :)
Title: Re: Sudoku CSE
Post by: unknownloner on June 11, 2015, 09:16:00 PM
I've generated 6750 puzzles so far and counting :P
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 12, 2015, 04:27:43 AM
Wow, that's nice then. :)
Title: Re: Sudoku CSE
Post by: Unicorn on June 12, 2015, 07:42:41 AM
How does? huh?

Unicorn is not smart enough O.O
Title: Re: Sudoku CSE [ASM] [CSE]
Post by: Snektron on June 12, 2015, 08:05:50 AM
Well, that means there are enough puzzles to solve
Title: Re: Sudoku CSE
Post by: Unicorn on June 12, 2015, 08:07:34 AM
Ha, no kidding. If someone solves them all, they should get a badge :P
Title: Re: Sudoku CSE
Post by: unknownloner on June 12, 2015, 09:03:58 AM
Alright so some math stats

I did some tests on the puzzles I have right now. They're all what I'd classify under "hard" or "very hard" difficulties right now, but don't worry I'll be converting many to easier puzzles.
Anyhow, given my current set of 8321 puzzles:
These puzzles have on average 24-25 starting numbers. The rest are all zeroes.
I can compress them down to, on average, 22.32 bytes per puzzle.
That means that in 4096 bytes I could store about 188 puzzles.
Realistically it will be less because easier puzzles will take more space, but this is pretty good when you consider a full board is 81 numbers. I'll have quite a few puzzles included and I might not need separate puzzle packs for them.

EDIT:
Oh and the way I'm compressing them is I'm storing them as a series of bits.
To store an empty tile, I have a 0 bit.
To store a non-empty tile I have a 1 bit, followed by 4 bits representing the tile's number.
Pretty simple really.
Title: Re: Sudoku CSE [ASM] [CSE]
Post by: Snektron on June 12, 2015, 02:26:03 PM
Thats quite a cool compression algo O.O
Title: Re: Sudoku CSE
Post by: alexgt on June 12, 2015, 02:37:57 PM
Quote from: unknownloner on June 12, 2015, 09:03:58 AM
Alright so some math stats

I did some tests on the puzzles I have right now. They're all what I'd classify under "hard" or "very hard" difficulties right now, but don't worry I'll be converting many to easier puzzles.
Anyhow, given my current set of 8321 puzzles:
These puzzles have on average 24-25 starting numbers. The rest are all zeroes.
I can compress them down to, on average, 22.32 bytes per puzzle.
That means that in 4096 bytes I could store about 188 puzzles.
Realistically it will be less because easier puzzles will take more space, but this is pretty good when you consider a full board is 81 numbers. I'll have quite a few puzzles included and I might not need separate puzzle packs for them.

EDIT:
Oh and the way I'm compressing them is I'm storing them as a series of bits.
To store an empty tile, I have a 0 bit.
To store a non-empty tile I have a 1 bit, followed by 4 bits representing the tile's number.
Pretty simple really.
"hard or "very hard" O.O (I don't even know  how to play Sudoku :P)
Title: Re: Sudoku CSE
Post by: Duke "Tape" Eiyeron on June 14, 2015, 05:27:19 PM
Why not just RLE? If many of the puzzles will be full of zeros, RLE would do a very good work on it.
Title: Re: Sudoku CSE [ASM] [CSE]
Post by: TheMachine02 on June 14, 2015, 05:31:50 PM
RLE could do it, but I guess it will show less gain over this particular algorithm (except if you use bit instead, but it start to be a bit more complicated).
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 14, 2015, 07:18:52 PM
Quote from: unknownloner on June 12, 2015, 09:03:58 AM
Alright so some math stats

I did some tests on the puzzles I have right now. They're all what I'd classify under "hard" or "very hard" difficulties right now, but don't worry I'll be converting many to easier puzzles.
Anyhow, given my current set of 8321 puzzles:
These puzzles have on average 24-25 starting numbers. The rest are all zeroes.
I can compress them down to, on average, 22.32 bytes per puzzle.
That means that in 4096 bytes I could store about 188 puzzles.
Realistically it will be less because easier puzzles will take more space, but this is pretty good when you consider a full board is 81 numbers. I'll have quite a few puzzles included and I might not need separate puzzle packs for them.

EDIT:
Oh and the way I'm compressing them is I'm storing them as a series of bits.
To store an empty tile, I have a 0 bit.
To store a non-empty tile I have a 1 bit, followed by 4 bits representing the tile's number.
Pretty simple really.
Will they be in order of difficulty? Some games often add super hard levels just between two early easy levels.
Title: Re: Sudoku CSE
Post by: unknownloner on June 14, 2015, 07:51:17 PM
You'll be presented with a choice of difficulty, and after selecting a difficulty you'll be able to choose a board from it.
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 15, 2015, 05:28:32 AM
Ah I see. Seems good to me. Will the harder boards in each section only unlock themselves after beating the previous one? It would be nice if the game showed which one you have beaten at least once so you can 100% the game.
Title: Re: Sudoku CSE
Post by: unknownloner on June 15, 2015, 06:16:56 AM
It'll show you which ones you've beaten, but there won't be an unlocking system. I don't really have a good way to judge how difficult a board is other than to count how many numbers are given to you when you start, so it's just going to be organized based on that.
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 15, 2015, 01:32:53 PM
Aah that still seems good to me at least. It just sucks if there is no indication about which level you have beaten in a game and you try to remember. :P
Title: Re: Sudoku CSE
Post by: unknownloner on June 16, 2015, 05:15:05 AM
(http://i.imgur.com/jzJFSpZ.png)

Not much but we're gettin' somewhere
Title: Re: Sudoku CSE
Post by: Unicorn on June 16, 2015, 05:44:42 AM
For a level editor?
Title: Re: Sudoku CSE
Post by: unknownloner on June 16, 2015, 05:46:40 AM
Nah, just figuring out how I want the board to look. I feel like a level editor is too niche for a calculator sudoku game.
Title: Re: Sudoku CSE
Post by: Unicorn on June 16, 2015, 06:12:47 AM
Ah, I see, also nice signature :P
Title: Re: Sudoku CSE
Post by: unknownloner on June 16, 2015, 07:25:05 AM
(http://i.imgur.com/PFLldmJ.png)

Now with 20% more numbers!
This actually loads from my compressed file format too, so that works!
Title: Re: Sudoku CSE [ASM] [CSE]
Post by: Snektron on June 16, 2015, 12:51:42 PM
whoa that looks kinda cool! How is the letter drawing speed and such btw? (since it still is the cse :P)
Title: Re: Sudoku CSE
Post by: unknownloner on June 16, 2015, 09:04:23 PM
It's not bad. It could be a bit faster if I went for speed over size but I think the current speed will be fine
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 17, 2015, 02:03:19 AM
Seems pretty good so far. :) How large is it right now?
Title: Re: Sudoku CSE
Post by: Unicorn on June 17, 2015, 03:09:33 AM
^
I like how crisp the letters are.
Title: Re: Sudoku CSE
Post by: unknownloner on June 17, 2015, 05:05:52 AM
1700K I believe.
The font is Terminus btw, it's a bitmap font so it works really well for making calc fonts.
Title: Re: Sudoku CSE [ASM] [CSE]
Post by: Snektron on June 17, 2015, 08:07:51 AM
Though the CSE letter layout in bytes is ridiculous. 2 bytes per line of 10 pixels <_<
Title: Re: Sudoku CSE
Post by: unknownloner on June 17, 2015, 08:48:08 AM
I'm actually storing it as 1 byte per pixel, and then compressing that with LZ4. That comes out to 216 bytes, while if I stored 2 bytes per line it'd be 300 bytes.
Originally I did this so I could use DCSE's "transparent pixel" feature in its 8-bit sprite routine, but I ended up not using that. I figured I'd keep it at 1 byte per pixel though since it was smaller to store.
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 22, 2015, 06:03:12 AM
Yeah it would be insane if we were forced to use 16-bit colors just to have custom fonts and use 2 bytes per pixel for them. Since your fonts are quite large this would have made the file size skyrocket despite the fonts only using two colors.

WOuld it be too slow if you compressed them to the same format as TI-83+ pics (1 bit per 8 pixels)?
Title: Re: Sudoku CSE
Post by: unknownloner on June 24, 2015, 03:31:10 AM
Quote from: DJ Omnimaga on June 22, 2015, 06:03:12 AM
WOuld it be too slow if you compressed them to the same format as TI-83+ pics (1 bit per 8 pixels)?
TI-83+ pics are 1 bit per pixel, not 1 bit per 8 pixels.

I don't compress them to 1 bit per pixel because it results in a larger file size than LZ4 w/1 byte per pixel, as mentioned in my previous post.
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 26, 2015, 05:53:18 AM
Ah my bad, I made a typo. But yeah I meant 1 byte per 8 pixels. And I see. I didn't realize it could end up larger that way.
Title: Re: Sudoku CSE
Post by: unknownloner on June 26, 2015, 12:51:23 PM
It's basically because numbers in fonts have a lot of repeating sequences of bytes. For example,  think of a 0. All the middle rows are the same, so once it's written out once the compressor can just refer back to the previous data.
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on June 29, 2015, 07:02:18 AM
Yeah true. I just didn't realize that the data was so simple enough to end up being smaller than 1-bit graphics. By the way, how is this project going on? Do you plan to make a CE version?
Title: Re: Sudoku CSE
Post by: unknownloner on July 04, 2015, 03:17:50 PM
When I end up finishing this I'll add it to the list of things to port to the CE. Once I get a CE I'm planning to port my ASM games to it, starting with 2048.
Title: Re: Sudoku CSE
Post by: Unicorn on July 06, 2015, 09:25:29 PM
Quote from: unknownloner on July 04, 2015, 03:17:50 PM
When I end up finishing this I'll add it to the list of things to port to the CE. Once I get a CE I'm planning to port my ASM games to it, starting with 2048.
Not snake? O.O

I actually play your snake game very much. :P
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on July 12, 2015, 06:13:44 PM
CE ports of your games would definitively be nice Unknownloner. Hopefully it's not too hard to pull off.  :)
Title: Re: Sudoku CSE
Post by: unknownloner on July 12, 2015, 06:15:37 PM
Quote from: Unicorn on July 06, 2015, 09:25:29 PM
Quote from: unknownloner on July 04, 2015, 03:17:50 PM
When I end up finishing this I'll add it to the list of things to port to the CE. Once I get a CE I'm planning to port my ASM games to it, starting with 2048.
Not snake? O.O

I actually play your snake game very much. :P

Snake is one of my oldest games so it'll be harder to port just because I'll have to figure out how the code works.
Title: Re: Sudoku CSE
Post by: Dream of Omnimaga on July 12, 2015, 07:05:32 PM
Haha I had this happen with many of my old games. In one occasion I just said "screw it! I'm rewriting the entire thing"
Title: Re: Sudoku CSE
Post by: Unicorn on July 12, 2015, 07:44:48 PM
Lol, I guess thats true. :P