return to table of content

Show HN: Defrag the Game

pkstn
15 replies
1d7h

What should i do here?

v_b
14 replies
1d7h

The goal is to have as less gaps between the blocks as possible.

The High score is calculated with the following formula: (elapsed seconds / 4) + operations + fragmentation

operation: each movement = 1 fragmentation: each gap between two elements = 1

inverted score system (less is better)

pkstn
11 replies
1d6h

would be maybe good idea to add instructions :D

v_b
10 replies
1d6h

May I ask how old you are? Probably not from the Windows XP era, huh? We "old folks" know exactly what to do when it comes to defragging a drive.

Seriously though, thanks for the suggestion! I'll definitely add a small link with game rules to help everyone out.

rbonvall
3 replies
1d6h

If I was you I wouldn't bother. The cool thing is not the game itself, it's the fact that we "old folks" just know what to do right away :) If you need to read instructions, probably you'll find the game dull anyway.

v_b
2 replies
1d6h

Exactly this was my intetion :)

Thank you

user_7832
1 replies
1d5h

Counterpoint, I'd love to have this info. I grew up long enough ago to know (and do) disk defrags and the game is very similar to tetris in how it is fun and relatively easy. But iirc defrags made multiple passes, and it is not very clear whether the blocks in game correspond to pieces of the same file (where line 1 & 2 should be together) or of different files (where it does not matter). It's a nice game nonetheless!

v_b
0 replies
1d5h

@user_7832 Thank you so much for your feedback! I made this just for fun in my spare time, and feedback like yours is incredibly valuable and, more importantly, motivating.

It shows that there are people who take the time to provide thoughtful feedback in return for my invested time, which goes beyond simple comments like "this is stupid because I don't understand it."

Thank you!

moring
1 replies
1d6h

I remember defragmentation from ca. Windows 95 times, and it was totally different from this game. None of the files shown here is actually fragmented, only the used space is, and for some reason you can't place a two-block file across a "line break".

edit: I realized that the "lines" might be meant to represent disk cylinders in the pre-LBA era, but even then, a line should "wrap around" to itself instead of the next line.

em-bee
0 replies
1d5h

for the next level each file could have a different color. then multiple blocks of the same color would be one fragmented file. in easy mode the order of the blocks would not matter as long as all of one color follow each other, in hard mode the blocks would have to be in a specific order.

i would also allow blocks be moved freely with the goal to move as little data as possible.

mrgoldenbrown
0 replies
1d5h

As an old folk who watched a lot of DOS and win 3.1 defrag I could not figure out how to play. This game has many confusing differences from actual defragging: blocks can't seem to move over each other for example. And I think each block can move only once? It's a neat concept for a game but don't blame our confusion with the UX on lack of familiarity with the real defrag process.

krisoft
0 replies
1d4h

We "old folks" know exactly what to do when it comes to defragging a drive.

Has nothing to do with age. Clearly the game has a host of limitations which has nothing to do with actual disk defragging. (Can only process the blocks one at a time in a specified but unknown to the user order. Blocks move one cell at a time and can't jump over other blocks.) And doesn't have others which are core to disk defragmentation. (Sectors, and files for example.)

iamtedd
0 replies
1d6h

Ok, but I had no idea I was already choosing a position to write the first file. I was pulling to refresh constantly on Firefox mobile until I finally figured it out. Which is a big difference to all the other moves - choosing a file to move first, before choosing a position to write it to.

Nifty game, but I almost gave up on it when I couldn't figure out what the hell I was supposed to do as the first move.

dfox
0 replies
1d6h

The idea behind defragmentation is to make the files themselves consecutive, which is not done in any way in this game, which makes it somehow confusing. The fact that DOS/Windows defrag also moves the used space to the beginning of the block device is mostly an implementation detail (and the experience with unix filesystems seems to indicate that it is actually better strategy to intentionally fragment the files by allocating the space almost randomly as long as the fragments are "large").

RA2lover
1 replies
1d6h

note gaps between the first block and first file are counted, and gaps longer than 4 blocks are treated as 4-block gaps, but only for the fragmentation display rather than actual scoring.

v_b
0 replies
1d5h

I didn't mention that above, but you are correct. Kudos to your reverse engineering skills!

r1chardnl
11 replies
1d6h

Just a matter of time before Chrome pushes another JS API like File System API and you can actually defrag your drive from the browser.

HeatrayEnjoyer
6 replies
1d4h

Why do APIs like this even exist? There's no legitimate reason for an HTML webpage to need this, it's just creating more attack surface for bad actors.

zamadatix
3 replies
1d2h

The File System API is a JavaScript API, not an HTML one, so it helps to think about it from that light (programs, not documents). The API allows tools such as photo editors, file converters, code editors, and the like to be given access to a set of files they can work on directly rather than needing to import and export from the browser on every change. If the attack surface is too much for a use case it can be globally denied by default in every major browser so you won't even get prompted.

HeatrayEnjoyer
2 replies
1d1h

JavaScript is just a feature accessory for HTML. There's no meaningful difference.

zamadatix
1 replies
23h49m

For whatever your preference in slicing that up is you can carry the "programs, not documents" reasons along.

HeatrayEnjoyer
0 replies
5h56m

Right, but programs are programs. Browsers are for webpages. If we want a program we run an .exe

nox101
0 replies
1d1h

The page needs permission. That permission step is similar to the act of downloading a native app. Except for the fact that the broswer gives even less access to your system than a native app so it's safer than a native app. (at least on desktop) That file system API is super useful for cloud based IDEs as just one example

miquong
0 replies
21h1m

Microsoft has an elaborate VS Code demo app that uses this API. Click "Open Folder" to see the API in action): https://vscode.dev

zamadatix
0 replies
1d2h

They say "like" this one because it only provides file level interaction, not disk level interaction.

v_b
0 replies
1d6h

Should already work today with your cloud storage I think

jeroenhd
0 replies
4h0m

If you know the right identifiers, you should be able to use WebUSB to access a flash drive/external hard drive. Combined with C-to-WASM compilers and Linux driver code, I'm sure you can defragment from the browser alone.

Or you can hook this mechanism into one of the WASM x64 emulators and attach the drive directly to a copy of MS-DOS or Windows 98 running in the browser.

danbruc
8 replies
1d6h

This is not like defragmenting a disk at all. There are no sectors or clusters, I can and have to move entire files at once. I have to move them in some fixed order and I can only move each once. Files can bump into each other?!? This is extremely confusing if you think the game is about what the names says.

pmelendez
1 replies
1d4h

Quoting OP's:

|> it inspired me to create this small game.

It was inspiration, not a simulation nor it claimed to be realistic. This is the type of artistic license that game designers have always had at their disposal.

danbruc
0 replies
1d2h

I am not complaining about how the game works, I am just saying that there are no instructions, so the only thing I have to work with is the name and the inspiration. And if you know how defragmentation works, this all just makes no sense, why does it automatically select blocks, why can I not move them repeatedly and to any free space? Sure, most people do not know what defragmentation is and how it works, even in developer circles I would not expect people to know if they are not old enough to have worked with computers in the 90s, they might hear about this in one computer science lecture and never think about it again.

guestbest
1 replies
1d2h

This is generally my fear in creating a game in that the players would take the name and rules more seriously than me as a designer.

I liked the game, btw as it captured a certain look and feel as well as was fun to play.

mrgoldenbrown
0 replies
1d1h

I think what happened here is that author didn't include instructions, the UX was not clear, and the author said if you are old enough to remember defrag you'll just know what to do. But on the Internet everyone's a pedant and many of us remember DOS/ windows defrag in more detail than the OP seems to, so there's confusion/complaining. All that is par for the course though and hopefully you will still make and share awesome games!

stavros
0 replies
1d5h

Yeah, this needs an explanation, I went into it thinking it was like defragging and it took me a while to figure out how to play. Fun game, though.

monitron
0 replies
1d

It's quite a bit more "realistic" if you imagine it as a simulation of the "Defragment Free Space" option that at least some defraggers had.

kwhitefoot
0 replies
1d4h

I'm pretty sure that there have been disk formats that only write files to consecutive sectors just like memory allocators that only return contiguous blocks of memory.

Then you need frequent compaction of the space because it ends up full of small unallocated blocks.

See https://www.geeksforgeeks.org/file-allocation-methods/

IshKebab
0 replies
1d2h

Well... yeah but also defragmenting isn't a game. If you want to make a fun game out of it you're going to need to change a few things.

That said, I can't see how this is fun tbh.

holistio
7 replies
1d6h

Fun game, but scoring seems to be a bit off. If I just smash space I get a score higher than when I actually solve the puzzle.

mapimopi
5 replies
1d6h

Your goal is to score lower

holistio
2 replies
1d6h

That makes total sense. I guess "best score" would be a better wording in that case.

v_b
1 replies
1d6h

Thanks, I have adjusted it to:

Best Score: XXX

(Aim for a lower score)

Just refresh the page

nox101
0 replies
1d1h

"lowest score" would be self explanatory. "Best score" still made me think I was doing better with a higher score

on the other hand, it might be better to change the scoring system. Calculate the worst score using the current system. Then reverse so the score goes up as in displayScore = worstScore - oldWayOfCalculatingScore

shawabawa3
1 replies
1d3h

if i just smash space i get a lower score than when i try playing

edit: managed to get a score of 131 for getting to 0 fragmentation in 30 seconds, i had 139 from just spamming space

recursive
0 replies
1d

It's possible to do a lot better with strategy.

MattGaiser
0 replies
1d6h

Playing a few rounds, it shows your “high score” as the lowest number you earned. So it seems to be more that the score is inverted.

apopapo
6 replies
1d6h

I get terrible performance in "hard" mode (seems to be due to animations?)

Nice educational game!

v_b
4 replies
1d6h

Haha, I never played in "hard" mode because it was too challenging for me. That's probably why I didn't optimize the performance as much in that mode. Thanks for the feedback!

eknkc
3 replies
1d6h

Is this completely in React? Just curious as this should be pretty easy to render.

v_b
2 replies
1d6h

It is. To be hones I played it now in "hard" and the peformance was absolutley fine.

I know that some browsers has still issues when it comes to pure CSS animations as they are running on the GPU and when the Hardware acceleration is disabled the CPU goes sometimes crazy.

I had the same on an animation GitHub a while ago used on their landing page.

withinboredom
0 replies
1d2h

Issues seem to be random, it is like the board shifts back and forth to the right/left until it settles, causing performance to tank until it settles.

ALittleLight
0 replies
21h21m

Performance seems to get worse about midway through. I assumed it was an intentional difficulty increase though.

hellohello2
0 replies
1d4h

Lags for me as well on a recent Macbook pro. (Nice game though)

abcd_f
6 replies
1d6h

On iPhone drag-n-drop doesn't work. Long tap basically selects part of the gaming field and this selection is not draggable. Once tap is released it shows the Copy/... menu.

mastermedo
1 replies
1d6h

You need to swipe. Works on iphone 13 + chrome.

hinkley
0 replies
1d2h

I tried swiping, got nothing.

I’m not sure what else someone would interpret as drag and drop on a touch screen. That’s gonna be swiping.

insane_dreamer
0 replies
22h56m

it's more just dragging than drag-and-drop; slide finger to move the blinking in one direction; no tapping

works for me with iPhone13 + Safari

hinkley
0 replies
1d2h

It’s because the game ergonomics are questionable. You can only slide files sideways, not past other files. Your phone isn’t broken, not is the game engine. The game rules are.

I got other things I’m supposed to be doing right now so I’m gonna go do those.

KTibow
0 replies
14h10m

For other mobile users:

The black boxes are data; they are automatically picked up. You're swiping to move the cursor that places the data. The "write file" button writes the data.

Aeolun
0 replies
14h36m

It sort of works for me, but it feels far from pleasant/responsive. Feels like it only ever goes in one direction at a time. Dragging diagonally has your file stuck.

pureheartlover
1 replies
1d5h

I love watching defrag vids on youtube. There's still a strong but small community pumping out world records.

A classic from about a decade ago: https://www.youtube.com/watch?v=RUCtMIjL-Z4

stavros
0 replies
1d5h

I spent two seconds trying to figure out how someone would even do competitive defragmentation, let alone why there are multiple people doing it.

sixonesixo
0 replies
1d6h

that would be amazing

ponytech
0 replies
1d5h

I thought the same :)

hinkley
4 replies
1d2h

8 hour defrag

In the NT 4 era I had a defrag take almost 18 hours. I started it before leaving for the day and came in the next morning to find it an unknown percentage done. I didn’t trust it would be okay to restart the machine so I had to leave it.

That was a problem because we were running version control on this box. But by then everyone was bought in so we got a dedicated machine out of the ordeal, but that was super annoying.

We even called Microsoft and got through, but it turns out on NT defragment happened in real mode so there isn’t a lot of memory to buffer copied blocks. So it spends a lot of time seeking on the hard drive. So stupid.

samstave
1 replies
22h38m

5200 RPM HDD? likely contributed to time seeking?

hinkley
0 replies
13h24m

I don’t recall but that sounds plausible.

AshamedCaptain
1 replies
19h49m

out on NT defragment happened in real mode so there isn’t a lot of memory to buffer copied blocks

NT cannot run anything in real mode after ntldr. (And even boot time defragmenters run way after ntldr).

hinkley
0 replies
13h25m

Yeah the entire defrag process happens in a blue screen during the boot process.

There was a cheap defrag you could do while NT was running but it can’t move any system files, so after a few system updates you needed a full defrag.

Sarkie
4 replies
1d6h

Hit the spacebar = 155 points. Solve the game = 111 points.

Fun idea but not great point strategy.

Thanks

v_b
3 replies
1d6h

It has an inverted score system, which means less is better :-)

iamtedd
2 replies
1d6h

Where is that explained?

v_b
1 replies
1d6h

I just updated it, it shows now:

Best Score: XXX

(Aim for a lower score)

At the end of a round. Probably not perfect but I hope OK for now.

iamtedd
0 replies
1d6h

So I have to blindly play a round until I finally get the goal explained?

marvinborner
3 replies
1d6h

I wonder what the optimal strategy is, optimize for speed with more fragmentation and fewer operations or for less fragmentation but more operations and time. For 1kb, optimizing for no fragmentation I can't seem to get below ~80.

v_b
2 replies
1d6h

That's the formular I am using to calculate the score: (elapsed seconds / 4) + operations + fragmentation

RA2lover
1 replies
1d5h

Seems like there's something off about that formula. This should have achieved 63 points instead of 79: https://i.imgur.com/QGEWpgO.png

v_b
0 replies
1d5h

Actually true. Thanks, will check this one

liamwire
1 replies
1d6h

Beautiful game that’s very quick to pick up, well done.

v_b
0 replies
1d6h

That's exactly what a software developer hopes for: users enjoying their software.

Thank you ! :)

khadadalek
1 replies
1d

I played this way too long. It did take me a a game or two to figure out how the UI worked on desktop and what the point was, but after that, it's a fun little puzzle game.

I like!

v_b
0 replies
22h40m

That was a bit intentional. I personally enjoy exploring games and figuring out how they work before developing strategies. It makes the game more fun for me. However, I do understand the feedback that if someone still doesn't get the game after one or two rounds, something might be off.

At the very least, it's great to hear that I've won one fan! I'm really grateful for the time you invested in something I created. Thank you!

chiph
1 replies
1d6h

Looks like the video is no longer available.

I used to love watching the defragger back in the Windows 95 days, and later I bought copies of PerfectDisk for both home & work. Unfortunately Raxco closed up shop earlier this year, and their license server is offline[0]. So I can't run it other than in trial mode. And that's a shame, as it was the only product that could fix the fragmentation problem we had with over fifty thousand files in a directory tree[1].

I don't know if NTFS has a version ID or if PerfectDisk will respect an ID higher than it was written for, but I'm nervous that the now-unsupported defragger might trash the internals of my filesystem. :(

[0] 1990's style software licensing - super annoying.

[1] Startup. No time to rearchitect it correctly. Usual story.

weego
0 replies
1d6h

It's a fun game, my only complaint is a UX / expectation issue: when I've placed a block, my natural reaction is to press space again to "enable" the next block for moving but, as it's enable by default, it locks it. I've had to restart a lot because of that.

vunderba
0 replies
1d2h

The subtle blue color theme is great!

When I was younger, we used to joke about doing the opposite, deliberately fragmenting every file on the drive to put them as far as possible from each other so that your magnetic drive would just THRASH.

I like to make sure the actuator arm gets a good workout to feel the burn.

sarcan
0 replies
1d6h

really funny, I also think scoring should be inverted and should be more clear

p0w3n3d
0 replies
1d5h

Funny game but that's not how defragmentation works. I was troubled to understand how can I choose the file by it contents or even why can't I write to a place where there is a block below it...

mgaunard
0 replies
1d1h

I have no idea what the rules are, doesn't look like disk fragmentation at all.

memming
0 replies
1d4h

The domain appears to be flagged as "gambling" under Cisco Umbrella service. (Yes, I clicked on the link at work.)

kwhitefoot
0 replies
1d4h

Surely it should have a leader board?

keyle
0 replies
19h9m

Wonderful job, next, 3D version!

joseferben
0 replies
1d7h

fun little game, very intuitive!

insane_dreamer
0 replies
22h50m

Fun. Feedback: the only thing I found confusing is that it's not clear that the first block that is blinking is a data block. Maybe if it started with no block selected, and the user has to press Enter/Space to begin the game at which point the first data block starts blinking. That would make it clearer.

Reminds me of Sokoban.

hobs
0 replies
1d1h

Took me a second to get the rules, but a fun little unblocking game, good work!

geuis
0 replies
19h5m

Some instructions would be helpful

dncornholio
0 replies
1d6h

The puzzle stops after you solved the first line. You won't become stuck after this. Would be nice if it had reproducable levels because I feel like this is a product of the level generation. It's not providing enough problems IMO.

devit
0 replies
1d7h

I wonder what's the complexity class of the problem of deciding if it is solvable in a given number of moves?

boo-ga-ga
0 replies
1d5h

Lovely game, great animations, everything feels smooth.

alliao
0 replies
1d5h

slightly unrealistic but fun idea.. makes me wonder if there are any benefit in AI powered caching algorithm or maybe that's what all the cloud providers are reaping benefits from...

NelsonMinar
0 replies
21h32m

There's a fun simulator of Windows defrag with sounds here: https://defrag98.com/

LittleOtter
0 replies
12h53m

I love this cute game.And,I think it would be better to have the HDD Sound like the video you post. :)

HipstaJules
0 replies
1d6h

It's fun! Thanks for sharing

ALittleLight
0 replies
21h20m

I love it.

I think it needs an undo button. It sucks being most of the way through the hard level when you accidentally double tap space and ruin your game.

I also want to see score as a percentile of everyone who did it or as being X out of possible Y.