vsoch / puzzles

robot puzzle solver, maybe
https://nbviewer.jupyter.org/github/vsoch/puzzles/blob/master/examples/avocado-puzzle.ipynb
Mozilla Public License 2.0
3 stars 1 forks source link

Refactor to handle pre-generated pieces #4

Open vsoch opened 3 years ago

vsoch commented 3 years ago

Working on this now!

ArcadeHustle commented 2 years ago

any progress?

vsoch commented 2 years ago

Yes! Did this as intended. https://twitter.com/vsoch/status/1406737356699291648?s=21

ArcadeHustle commented 2 years ago

Is there a way to feed puzzle.solve() a collection of images? For example a grid of six 32x32 tiles for a sprite? FA2x4uCXMAUz9-p

vsoch commented 2 years ago

There is not - but you could modify the code to support it.

ArcadeHustle commented 2 years ago

Not being familiar with your workflow, can you suggest a good place to inject this logic?

vsoch commented 2 years ago

Sure! So what I would do is make a parent class to PhotoPuzzle that has the common functions, and then create another class that manually loads the pieces instead of generate pieces here https://github.com/vsoch/puzzles/blob/c7f640b35d3849e05ab503dc2e17e3a158cb3701/puzzles/models.py#L62. So you’d have the user generate pieces first manually and then just hand to the puzzle.

vsoch commented 2 years ago

If you want to send me some example pieces I could probably also give a shot in a weekend or evening, if you tell me more details about your use case.

ArcadeHustle commented 2 years ago

Here is one sprite.

sprite_0_32 sprite_0_64 sprite_0_96 sprite_0_128 sprite_0_160

ArcadeHustle commented 2 years ago

Here is the same sprite, zoomed as per the example image a few posts up. They are 32x32 pixels. In some cases one image winds up getting split in half, and reused, either by overlapping, or allowing the other half to overhang beyond the sprite boundary. sprite_0_192 sprite_0_224 sprite_0_256 sprite_0_288 sprite_0_320

ArcadeHustle commented 2 years ago

If you are bored there are thousands of sprites here that we are trying to reassemble. https://github.com/ArcadeHustle/WatermelonPapriumDump/tree/main/Extracted/sprites/sheet https://github.com/ArcadeHustle/WatermelonPapriumDump/tree/main/Extracted/sprites/sheet2

vsoch commented 2 years ago

Haha thanks! I’ll try to work on this in some free time unless you beat me to it.

vsoch commented 2 years ago

@ArcadeHustle I looked at the repository of sprites - is what you are doing legal?

ArcadeHustle commented 2 years ago

We are reverse engineering a sprite engine... to preserve a broken game. #RightToRepair From the repo README:

Exemptions to Prohibition against Circumvention of Technological Measures Protecting Copyrighted Works Seventh Triennial Section 1201 Final Rule, Effective October 28, 2018 https://library.osu.edu/document-registry/docs/1027/stream "Video games in the form of computer programs, where outside server support has been discontinued, to allow individual play and preservation by an eligible library, archive, or museum"

https://library.osu.edu/site/copyright/2019/03/20/2018-dmca-section-1201-exemptions-announced/ "Video games in the form of computer programs, lawfully acquired as complete games 37" "CFR §201.40(b)(12)" "For personal, local gameplay; or To allow preservation in a playable format..."

"Computer programs protected by dongles that prevent access due to malfunction or damage and which are obsolete. A dongle shall be considered obsolete if it is no longer manufactured or if a replacement or repair is no longer reasonably available in the commercial marketplace." https://www.copyright.gov/fedreg/2006/71fr68472.html

"The final rule allows eligible libraries, archives, and museums to circumvent technological protection measures on certain lawfully acquired computer programs (including video games) to preserve computer programs and computer program-dependent materials." https://clinic.cyber.harvard.edu/2018/10/26/a-victory-for-software-preservation-dmca-exemption-granted-for-spn/

"Exemption to Prohibition on Circumvention of Copyright Protection Systems for Access Control Technologies" https://www.govinfo.gov/content/pkg/FR-2018-10-26/pdf/2018-23241.pdf

Please note that the following text is considered "for purposes of good-faith security research". This write up will give you all the knowledge, and access you need to backup and preserve your Genesis MegaDrive Paprium cart as supplied by Watermelon Games. It will also serve as an academic tome on the security ramification of Voltage Glitching the STM32F4 MCU, FPGA security through obscurity, physical protection methods, and anti tamper techniques.

President Joe Biden’s latest executive order is a huge win for right to repair because it specifically calls out "unfair anticompetitive restrictions on third-party repair or self-repair of items", just like the DT128M16VA1LT concept in Paprium imposes on any end user lucky enough to acutally obtain the game. https://www.whitehouse.gov/briefing-room/presidential-actions/2021/07/09/executive-order-on-promoting-competition-in-the-american-economy/

vsoch commented 2 years ago

I saw that but it was too dense to get a simple answer to my question - is what you are doing legal (yes/no)?

ArcadeHustle commented 2 years ago

As an owner of 4 copies of the cartridge, 2 of which came broken, yes I feel it ls legal to do research on repair.

Secondarily the online portion of the game is not supported, placing it in a DMCA exemption class.

Tertiary the reason the games are broken is in essence due to a technological protection measure, also placing it into a DMCA exemption class.

They are free to file a takedown request with GitHub if they feel their rights are being infringed upon, at which point I am free to contest it.

TLDR: IMHO yes reassembling a sprite, as part of a process to reverse engineer a broken game when repair/replacement is no longer reasonable available is a legal thing to do.

ArcadeHustle commented 2 years ago

Alternately 32x32 sprite sheets are very commonly archived for other classic games. https://spritedatabase.net/system/genesis

vsoch commented 2 years ago

Gotcha, thanks!

vsoch commented 2 years ago

okay, here is something to play with! https://github.com/vsoch/puzzles/pull/7 I don't think this is going to work great for your use case because the sprites have pretty uniform edges, and the algorithm is based on matching those edges (so at best you'd get random given a common green/yellow edge). It also does not take account for the single piece that is essentially two halves. But you can definitely play around with the branch and see if you can modify it to your liking.

ArcadeHustle commented 2 years ago

thanks very much! I'll have a much more solid base to stand on. Thank you kindly.