Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Defrag the Game (defrag-game.com)
326 points by v_b 3 months ago | hide | past | favorite | 107 comments
Hi,

A while ago, I came across this https://www.youtube.com/watch?v=KR3TbL3Tl6M on YouTube showing 8 hours of defragmenting a hard drive. For some reason, it inspired me to create this small game.

Have fun :)




> 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.


> 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).


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.


5200 RPM HDD? likely contributed to time seeking?


I don’t recall but that sounds plausible.


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.


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.


Your goal is to score lower


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


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


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


Thanks, I have adjusted it to:

Best Score: XXX

(Aim for a lower score)

Just refresh the page


"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


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.


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.


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.


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.


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


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.


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


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.


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.


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...


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


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.


I fixed the link in the post, there was a M missing at the end, here the correct:

https://www.youtube.com/watch?v=KR3TbL3Tl6M


Some instructions would be helpful


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.


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.



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.


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.


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


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


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


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


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


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


Should already work today with your cloud storage I think


I actually had played a different game before here https://losttraindude.itch.io/zfrag


From the title at first I thought this was a Quake browser port [0]

[0] https://en.wikipedia.org/wiki/DeFRaG


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


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


And the supposedly 24/7 defrag twitch stream


I thought the same :)


that would be amazing


Lovely game, great animations, everything feels smooth.


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


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

Thank you ! :)


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.


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


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


Actually true. Thanks, will check this one


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

Fun idea but not great point strategy.

Thanks


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


Where is that explained?


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.


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


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!


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!


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.


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.


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!


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.


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.


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/


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.


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.


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.


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


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


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.


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

Nice educational game!


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!


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


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.


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.


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


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


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


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.


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


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.


Surely it should have a leader board?


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


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...


What should i do here?


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)


would be maybe good idea to add instructions :D


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.


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").


> 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.)


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.


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.


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.


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.


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.


Exactly this was my intetion :)

Thank you


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!


@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!


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.


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


Wonderful job, next, 3D version!


It's fun! Thanks for sharing


fun little game, very intuitive!


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


not to be confused with the original defrag game mode https://en.wikipedia.org/wiki/DeFRaG




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: