andybalaam / rabbit-escape

Android and PC game inspired by Lemmings and Pingus
http://artificialworlds.net/rabbit-escape
GNU General Public License v2.0
75 stars 40 forks source link

Bug: world with n's in #374

Closed colonelfazackerley closed 8 years ago

colonelfazackerley commented 8 years ago

After trying to play a level on android with invisible water, this happens. I don't quite get it, but I think the problem is that level that is running can't round trip with the 'n' chars in.

03-27 08:19:06.241 26726-26726/? D/AndroidRuntime: Shutting down VM
03-27 08:19:06.243 26726-26726/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: net.artificialworlds.rabbitescape, PID: 26726
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{net.artificialworlds.rabbitescape/rabbitescape.ui.android.AndroidGameActivity}: rabbitescape.engine.textworld.UnknownCharacter: Line number 25 contains an unknown character 'n' in text world lines:
                                                   :name=Aquifer
                                                   :description=Try not to drown.
                                                   :author_name=tttppp
                                                   :author_url=
                                                   :hint.1=a
                                                   :hint.2=b
                                                   :hint.3=
                                                   :hint.4=c
                                                   :solution.1=;dig;(19,4);2;bash;(18,7);dig;;block;3;(15,1);3;bash;dig;(17,7);(18,7);3;bash&bash;dig;(1,4);dig;block;;(4,1);4;bash;(2,7);3;dig&(3,7);105;dig;6;(9,2);2;block;2;(6,4);2;(15,4);;dig;2;(12,4);3;(9,6);(14,6);12;(6,4);;(6,6);10;(15,1);block;2;(16,4);4;block&bash;;(15,4);3;dig;;(10,6);8;block&bash;dig&(4,1);3;bash&(16,4);12
                                                   :num_rabbits=10
                                                   :num_to_save=5
                                                   :rabbit_delay=4
                                                   :num_saved=0
                                                   :num_killed=10
                                                   :num_waiting=0
                                                   :paused=false
                                                   :bash=20
                                                   :block=10
                                                   :dig=17
                                                   :explode=10
                                                   #####################
                                                   #         *         #
                                                   #  ###\       /###  #
                                                   #    ###########    #
                                                   #nnnnnnnnnnnNNNnnnnn#
                                                   #############N#######
                                                   #  #*NNNNNNN*NNN*#  #
                                                   #  ###############  #
                                                   #### #    O d  # ####
                                                        ###########     
                                                   :*=Q{Entrance.timeToNextRabbit:3}
                                                   :*=NP
                                                   :*=Nd
                                                   :*=NP
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4077)
                                                       at android.app.ActivityThread.-wrap15(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:148)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                    Caused by: rabbitescape.engine.textworld.UnknownCharacter: Line number 25 contains an unknown character 'n' in text world lines:
                                                   :name=Aquifer
                                                   :description=Try not to drown.
                                                   :author_name=tttppp
                                                   :author_url=
                                                   :hint.1=a
                                                   :hint.2=b
                                                   :hint.3=
                                                   :hint.4=c
                                                   :solution.1=;dig;(19,4);2;bash;(18,7);dig;;block;3;(15,1);3;bash;dig;(17,7);(18,7);3;bash&bash;dig;(1,4);dig;block;;(4,1);4;bash;(2,7);3;dig&(3,7);105;dig;6;(9,2);2;block;2;(6,4);2;(15,4);;dig;2;(12,4);3;(9,6);(14,6);12;(6,4);;(6,6);10;(15,1);block;2;(16,4);4;block&bash;;(15,4);3;dig;;(10,6);8;block&bash;dig&(4,1);3;bash&(16,4);12
                                                   :num_rabbits=10
                                                   :num_to_save=5
                                                   :rabbit_delay=4
                                                   :num_saved=0
                                                   :num_killed=10
                                                   :num_waiting=0
                                                   :paused=false
                                                   :bash=20
                                                   :block=10
                                                   :dig=17
                                                   :explode=10
                                                   #####################
                                                   #         *         #
                                                   #  ###\       /###  #
                                                   #    ###########    #
                                                   #nnnnnnnnnnnNNNnnnnn#
                                                   #############N#######
                                                   #  #*NNNNNNN*NNN*#  #
                                                   #  ###############  #
                                                   #### #    O d  # ####
                                                        ###########     
                                                   :*=Q{Entrance.timeToNextRabbit:3}
                                                   :*=NP
                                                   :*=Nd
                                                   :*=NP
                                                       at rabbitescape.engine.textworld.LineProcessor.processChar(LineProcessor.java:622)
                                                       at rabbitescape.engine.textworld.LineProcessor.processItemsLine(LineProcessor.java:481)
                                                       at rabbitescape.engine.textworld.LineProcessor.process(LineProcessor.java:244)
                                                       at rabbitescape.engine.textworld.LineProcessor.<init>(LineProcessor.java:139)
                                                       at rabbitescape.engine.textworld.TextWorldManip.createWorldWithName(TextWorldManip.java:122)
                                                       at rabbitescape.engine.textworld.TextWorldManip.createWorld(TextWorldManip.java:102)
                                                       at rabbitescape.ui.android.AndroidGameActivity.loadWorld(AndroidGameActivity.java:119)
                                                       at rabbitescape.ui.android.AndroidGameActivity.onCreate(AndroidGameActivity.java:76)
                                                       at android.app.Activity.performCreate(Activity.java:6251)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                        ... 10 more
colonelfazackerley commented 8 years ago

I guess an implementation of #369 may fix this.

colonelfazackerley commented 8 years ago

This problem makes android crash for levels with water in when the screen is rotated.

andybalaam commented 8 years ago

Yes, we will need to make water save and load before we can release.

tttppp commented 8 years ago

I just thought about this some more today after seeing Andy's comment in the water animations pull request.

If the method of persisting level state is by using characters then we're going to have a lot of pain trying to persist water. For #369 I was planning to only allow loading full and half full water regions, but obviously it's possible to have any amount of water in a region midgame. This needs some design work to consider how we're currently persisting the level, and whether it scales when we have more features than printable ASCII characters.

andybalaam commented 8 years ago

Yes I'd be open to proposals for saving water state such as a list of numbers, a secondary grid for water, * symbols with more info below like e.g. bashing state is stored or something else.

tttppp commented 8 years ago

A separate grid or list of numbers for water state might work well. I think trying to include it in the standard grid will be messy because the range of values is so large. Using * points might work too, as it would allow adding the water out of sequence.

Possibly allowing a special character of N for 'full water region' might be useful, as it could be used ore easily during level design.

andybalaam commented 8 years ago

Definitely agree we should provide at least 1 water level that is easily encodable in the standard grid.

Was wondering about something like:

:~
:~23,1,,255,,,,,4
:~,,,4,,,199
:~

I.e. a non aligned comma separated grid where zero values are skipped and trailing zeroes are omitted and trailing empty rows are omitted. (And all lines begin :~)

Just a first suggestion, not thought through.

tttppp commented 8 years ago

Since we have a power of two for the maximum, how about using hexadecimal representation and allow spacing or leading zeroes to align.

:n
:n 17, 1,  ,ff,,,,,4
:n   ,  ,  , 4,,,57
:n

Maybe better to start simple and add more features later. Maybe hex is more confusing, as the other numbers (eg token counts) are all dec.

tttppp commented 8 years ago

Also, I l tried to use ~ during development, but got burnt as it means something else already. I suggest using n for water rows. (But I'm not too strongly opposed to ~)

CodeSmith00 commented 8 years ago

got a idea like this:

:name=example
:description=no need
:author_name=GamingInky
:author_url=https://github.com/GamingInky
:hint.1=no hints
:hint.2=no hints
:hint.3=no hints
:num_rabbits=0
:num_to_save=0
:rabbit_delay=0
:num_saved=0
:num_killed=0
:num_waiting=0
:paused=false
:bash=0
:block=0
:dig=0
:explode=0
####
#r #
#nn#
####
:n1=167
:n2=34
tttppp commented 8 years ago

I think I have a fix for this. I need to test it.