mxgmn / WaveFunctionCollapse

Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics
Other
23.18k stars 1.24k forks source link

Unhandled Exception: System.Exception: 0.0001 is not a valid value for Single #11

Closed nylki closed 7 years ago

nylki commented 7 years ago

On Fedora 24, Mono JIT compiler version 4.2.4.

WaveFunctionCollapse git:(master) ✗ mono Main.exe 
< Chess
> DONE
> DONE
< Chess
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
< City
> DONE
> DONE
< Flowers
> DONE
> DONE
< Hogs
> DONE
> DONE
< Hogs
> DONE
> CONTRADICTION
> CONTRADICTION
> CONTRADICTION
> DONE
< Knot
> DONE
> DONE
< Less Rooms
> DONE
> DONE
< Mountains
> DONE
> DONE
< Office
> DONE
> DONE
< Paths
> DONE
> DONE
< Platformer
> DONE
> DONE
< Platformer
> DONE
> DONE
< Red Maze
> DONE
> DONE
< Rooms
> DONE
> DONE
> DONE
< Rule 126
> DONE
> DONE
< Simple Knot
> DONE
> DONE
< Simple Maze
> DONE
> DONE
< Simple Wall
> DONE
> DONE
< Simple Wall
> DONE
> DONE
< Simple Wall
> DONE
> DONE
< Simple Wall
> DONE
> DONE
< Trick Knot
> DONE
> DONE
< Village
> DONE
> DONE
< Water
> DONE
> DONE
< Summer

Unhandled Exception:
System.Exception: 0.0001 is not a valid value for Single. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ParseSingle (System.String value, NumberStyles options, System.Globalization.NumberFormatInfo numfmt) <0x413eb590 + 0x00183> in <filename unknown>:0 
  at System.Single.Parse (System.String s, NumberStyles style, System.Globalization.NumberFormatInfo info) <0x413eb550 + 0x00017> in <filename unknown>:0 
  at System.Single.Parse (System.String s, NumberStyles style, IFormatProvider provider) <0x413eb440 + 0x0003b> in <filename unknown>:0 
  at System.ComponentModel.SingleConverter.FromString (System.String value, System.Globalization.NumberFormatInfo formatInfo) <0x413eb3d0 + 0x0001f> in <filename unknown>:0 
  at System.ComponentModel.BaseNumberConverter.ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) <0x413d5060 + 0x00259> in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.ComponentModel.BaseNumberConverter.ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) <0x413d5060 + 0x0028b> in <filename unknown>:0 
  at System.ComponentModel.TypeConverter.ConvertFromString (System.String text) <0x413cc070 + 0x00021> in <filename unknown>:0 
  at Stuff.Get[T] (System.Xml.XmlNode node, System.String attribute, T defaultT) <0x413eac30 + 0x000b7> in <filename unknown>:0 
  at SimpleTiledModel..ctor (System.String name, System.String subsetName, Int32 width, Int32 height, Boolean periodic, Boolean black) <0x413e7000 + 0x01827> in <filename unknown>:0 
  at Program.Main () <0x4135ee30 + 0x003fb> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: 0.0001 is not a valid value for Single. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ParseSingle (System.String value, NumberStyles options, System.Globalization.NumberFormatInfo numfmt) <0x413eb590 + 0x00183> in <filename unknown>:0 
  at System.Single.Parse (System.String s, NumberStyles style, System.Globalization.NumberFormatInfo info) <0x413eb550 + 0x00017> in <filename unknown>:0 
  at System.Single.Parse (System.String s, NumberStyles style, IFormatProvider provider) <0x413eb440 + 0x0003b> in <filename unknown>:0 
  at System.ComponentModel.SingleConverter.FromString (System.String value, System.Globalization.NumberFormatInfo formatInfo) <0x413eb3d0 + 0x0001f> in <filename unknown>:0 
  at System.ComponentModel.BaseNumberConverter.ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) <0x413d5060 + 0x00259> in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.ComponentModel.BaseNumberConverter.ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) <0x413d5060 + 0x0028b> in <filename unknown>:0 
  at System.ComponentModel.TypeConverter.ConvertFromString (System.String text) <0x413cc070 + 0x00021> in <filename unknown>:0 
  at Stuff.Get[T] (System.Xml.XmlNode node, System.String attribute, T defaultT) <0x413eac30 + 0x000b7> in <filename unknown>:0 
  at SimpleTiledModel..ctor (System.String name, System.String subsetName, Int32 width, Int32 height, Boolean periodic, Boolean black) <0x413e7000 + 0x01827> in <filename unknown>:0 
  at Program.Main () <0x4135ee30 + 0x003fb> in <filename unknown>:0 
drake7707 commented 7 years ago

I assume your locale is using the comma as decimal point. Changing the current thread culture to System.Globalization.Culture.InvariantCulture should fix the problem.

nylki commented 7 years ago

I assume your locale is using the comma as decimal point

I actually do. I am sorry, but I have no experience with Mono; could you indicate where the change would have to be made, in the code or as a compiler argument?

drake7707 commented 7 years ago

in Program.cs in the Main method (which is the entry point of the application) add the following before the whole XML parsing is going on, so at the top of the method: System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

nylki commented 7 years ago

@drake7707 Thank you, that worked! :)

I'll leave the issue open for @mxgmn to decide what to do with it.

Cookingsource commented 7 years ago

I had the same problem, i solved it in a pull request. The method he currently uses to parse strings into numbers does it with local system locale. There's an alternative that uses a culture invariant locale.

petersvp commented 7 years ago

Add using System.Globalization;

in Main add: CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

This will force proper culture. Also, set Bulgaria as your region during development, it will help you a lot with fixing such stuff :)

mxgmn commented 7 years ago

I merged @Cookingsource 's PR, so this should be solved.