Testing Counterfeit Monkey on Iphone?

Counterfeit Monkey keeps getting faster. The latest test version can be found here as usual.

I would be nice to have a way of testing it on a slower device, such as my non-jailbroken Iphone. Is there a simple way to, say, get it on a webpage and play it with a web-based interpreter?

That’s what Inform’s “release along with an interpreter” option does, right? I mean, that’s what you’re looking for?

You can also go through iplayif.com.

So what would be the simplest way to actually access the files, index.html etc, that “release along with an interpreter” creates on my hdd with Safari on the Iphone? Do I run a http server on my computer, do I have to find a web hosting solution? Sorry if this is a stupid question.

There is no way to push HTML files directly onto the iPhone and then browse them locally with Safari, if that’s what you’re asking. (App sandboxing prohibits that kind of thing.)

Either of those will work. I don’t know what the world of cheap/free web hosting looks like these days. (DropBox no longer supports playable Javascript, sadly.)

MacOS comes with an Apache install; Windows comes with IIS (I am told).

Thanks. I’m struggling a bit with Apache at the moment (I’m on El Capitan). I think I have it up and running, but I still haven’t worked out how to give myself permission to actually access the files in the Sites folder. I’ll keep trying.

You might try NeoCities.

Getting closer:

Quixe init: QuotaExceededError (DOM Exception 22): The quota has been exceeded. The quota has been exceeded. QuotaExceededError

Is that like a timeout error? Is my phone just too slow?

EDIT: I’m not the first!

EDIT 2: Some more progress. For no reason whatsoever, I’m now past the QuotaExceededError. Did Safari just realize that it needed more storage space? Instead I’m stuck on the “Loading…” screen with an animated compass rose. Five minutes and counting.

If the game sticks at the compass rose, there was almost certainly an error during the loading process.

We’ve had trouble with very large blorb files in the past, so this may just not be runnable with Quixe as it stands.

iOS Safari has a developer console (look under Settings/Safari/Advanced) but you have to hook it into MacOS Safari to see what’s going on.

The first thing to try would be running the same web page with MacOS Safari, to see if that works.

Yay, it works! Turns out I had private surf mode on. With that switched off, it runs. Not exactly well, but playable.

EDIT: Well, playable except for the frequent crashes, that is.

EDIT 2: Recurring bugs in mobile Safari seem to be: Room descriptions sometimes not printed, occasional “A problem occurred with this web page so it was reloaded” (and the game restarts), keyboard not responding on restart.

None of these show up in desktop Safari, or in Firefox on my Windows computer. Out-of-memory issues, perhaps? The developer console seems to be wiped clean when the page reloads. It would be interesting to try it out on the latest and greatest Iphone or similar (mine is a 5s).

Right, if anyone wants to try it out, here is a NeoCities link. Note that the map isn’t working – there will be a black rectangle in its place. There also seems to be a problem where the initial question (“Can you hear me?”) won’t show if there is a startup precomputation file present. If the game starts at an empty prompt, just type YES.

Out of memory errors are almost certainly the problem. The code itself is well-tested (and iOS Safari is the same codebase as MacOS Safari to begin with).

I guess that means it’s running out of disk space to page to as well? My phone has 1 GB RAM and 4,5 GB free disk space, and that is apparently not enough.

I wonder where in the game we are wasting most memory. Do unused properties use a lot of space?

This is memory managed by the Javascript interpreter, so it’s more limited than general OS memory. I don’t know what the interpreter’s policy on limits is.

The immediate problem is a product of two factors: CM uses a very large amount of RAM, and Quixe uses inefficient Javascript arrays for storing the game file and undo snapshots. The latter is my problem (I will eventually switch over to Uint8Arrays). The former, you’ll have to dig into.

(Attributes use space. Properties use space, particularly if they’re defined for larger kind-classes than necessary. Tables use space. Relations can use a lot of space.) (Optimizing RAM use in Inform is an old problem because there are no easy answers.)

One thing that I’m sure would help: instead of using a startup precomputation save-file, put the precomputed values directly into the Inform source code. That doesn’t change RAM usage but it cuts the undo-snapshot files way down.

Thanks, that’s good advice!

Another stupid question: what would the proper way be to represent all that data in Inform 6 code? I was considering putting the FWMatrix route-finding data in the source code, but I had no idea how to do it.

Array path_finding -> 1 3 1 1 12 4 ...
with a total of 10 000 numbers on a single line, or 10 000 lines of

path_finding->0 = 1; path_finding->1 = 3; ...

The former.

Undo snapshots are compressed (in a very simple way) by comparing to the original data file. So any array which is never changed will not take up (much) snapshot space. If you change the array contents (at game startup or later) then it has to be snapshotted as different.

Now, it’s possible that the I6 compiler will choke on arrays that size. I haven’t tested that case. I’m willing to treat that as a compiler bug and fix it, if it happens.

Yes, it seems that the compiler can handle it. Thanks! Another case of “should have tried it before asking”, but I suppose I was hoping there was some nicer syntax for this that I had missed.

If the arrays could be put in a dedicated extension then it would be easier to regenerate them if necessary. It also wouldn’t be too hard to make a function which would output that array.

Do we know which rules are making the biggest difference to the memory/size of saves or undos? Maybe we could make it save between each of the rules to tell where the big jumps are.

The memory layout will also affect the savefile size, and it might be possible to define some arrays earlier.

I’ve added a testing extension to the repo, which (by manually listing every rule) saves before each rule.

The results:

  • By the time of the Flexible Windows sort the Table of User Styles rule the save file is already at 17KB. Presumably most of this comes from INITIALISE_MEMORY_R() (which I’m guessing also needs to run before it will save files for some reason) through its creation of the heap etc. I doubt we can do anything to cut this.
  • The alternative position player in model world rule adds 7KB
  • The new declare everything initially unmentioned rule adds 6KB
  • The move all quips to the quip-repository rule adds 3KB
  • The initialize route-finding rule adds 31KB
  • The initialize drawers rule adds 8KB
  • The setting proffered rule adds 6KB
  • The initialize hash codes rule adds 12KB

Some of these things could presumably be relatively easily changed.

  • Instead of running the new declare everything initially unmentioned rule can we just make that a default property?
  • Testing code could output instructions which set the startup location of all quips to be in the quip-repository (in the same way that Conversation Builder does). And eventually we could even automatically run and regenerate that code as part of the testing framework.
  • The initial hash codes could also be set in the same way

Great! Plenty to work with, there.

I have some functioning code now that hard-codes the route-finding into the source, which obviously is the big one.

EDIT: Here, if anyone wants to have a look: https://github.com/angstsmurf/counterfeit-monkey/tree/data-in-source

The I7 compiler really wants to include " with room_index -1" in every room declaration, so I had to create a new property for this (room_index_2) that could be hardcoded to something else.

Now I have something to do this Christmas. :wink: