1

I´m working on a mod update checker for minecraft, but there is a big problem: The modders and online database that I´m using for update checks has no standard software versions e.g.:

Local: rv0-stable-10 Online: rv1-alpha-13
Local: R1.1-83 Online: r1.1-81
Local: 1.7.10-0.2.250 (1.7.10 is indicating the Minecraft version) Online: 0.2.274
Local: 1.1.0c Online: 1.1.0e
Local: 2.2.526 Online: 2.2.526-experimental

Is there an algorithm or something like that, that is able to compare such different versions?

2
  • 2
    These look too diverse for a single algorithm to work.
    – svick
    Jul 20 '14 at 11:46
  • But in most cases there are patterns that can be matched with some special cases, but I have less experience with pattern recognition.
    – WhiteIntel
    Jul 20 '14 at 12:06
2

I'd say your best bet is to create some sort of pattern for either each mod, or a dictionary of all known patterns, and use that to parse each version.

For mod1, Local: rv0-stable-10 Online: rv1-alpha-13, the pattern will be complicated. It looks like you'll need to first parse rvX- as a number, the middle part perhaps as an enum, and the last as a number again. That can be your first pattern class.

Ones like Local: 1.1.0c Online: 1.1.0e should be easier, since the alphabetic component can easily be treated as a number.

For random -experimental and 1.7.10- affixes, you'd probably need to decide how you want to treat them yourself - but an experimental version should generally be treated as a lower number than the same number without experimental.

Overall, you may end up creating several strategy classes to cover all the comparisons. (They could probably be IEqualityComparer instances, which would make some things easier!) I'd give each mod a comparison class (maybe save the comparison/modname mapping to a file)

Overall, It may not be as bad as you might expect.

1
  • +1 just to add another strategy class for each new pattern crafted by someone ;)
    – alessandro
    Jul 21 '14 at 15:02
1

Seems you are in trouble, if missing a public API based on semantic versioning you must know the rules which govern the release update.

Quote from Semantic Versioning 2.0.0 by Tom Preston-Werner

In the world of software management there exists a dread place called "dependency hell." The bigger your system grows and the more packages you integrate into your software, the more likely you are to find yourself, one day, in this pit of despair. In systems with many dependencies, releasing new package versions can quickly become a nightmare. If the dependency specifications are too tight, you are in danger of version lock (the inability to upgrade a package without having to release new versions of every dependent package). If dependencies are specified too loosely, you will inevitably be bitten by version promiscuity (assuming compatibility with more future versions than is reasonable). Dependency hell is where you are when version lock and/or version promiscuity prevent you from easily and safely moving your project forward.

As a solution to this problem, I propose a simple set of rules and requirements that dictate how version numbers are assigned and incremented. These rules are based on but not necessarily limited to pre-existing widespread common practices in use in both closed and open-source software. For this system to work, you first need to declare a public API. This may consist of documentation or be enforced by the code itself. Regardless, it is important that this API be clear and precise. Once you identify your public API, you communicate changes to it with specific increments to your version number. Consider a version format of X.Y.Z (Major.Minor.Patch). Bug fixes not affecting the API increment the patch version, backwards compatible API additions/changes increment the minor version, and backwards incompatible API changes increment the major version.

I call this system "Semantic Versioning." Under this scheme, version numbers and the way they change convey meaning about the underlying code and what has been modified from one version to the next.

I think you should rely to a more empirical method in which it is possible to extract the minimum fixed information, but in the examples that you have mentioned is very difficult to establish a pattern recognizable as:

[Major Release].[Minor Release].[hot Fix].[build]

from which tokenizing the strings with the dot as delimiter and then compare the integer translation side by side, begining from the left.

In essence, NO, if there are no uniformly accepted rules that govern the release of those software versions, NO, there is no algorithm that can help you; sorry.

1
  • 1
    Explaining the right way to version things may not help someone whose only goal is to consume radically different versioning schemes.
    – Magus
    Jul 21 '14 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.