Introducing CG Spunk

Continuing the discussion from Multiplayer helper Chrome extension:

I have renamed my Chrome extension to CG Spunk, and have enhanced it a bit:

Now, the report is no longer just in the JS console. You get a nice HTML report showing progress of a batch run, as well as a way to reproduce matches, and to see the STDERR from a given match.

Chrome Web Store link:

https://chrome.google.com/webstore/detail/cg-spunk/bkmddelokmckldmgeeiheohknodgaphi

Firefox add-on link:

https://addons.mozilla.org/en-US/firefox/addon/cg-spunk/

Also, as promised, the source code for the extension is available on gitHub:

https://github.com/danBhentschel/CGSpunk

Issues / feature requests can be added here as well:

https://github.com/danBhentschel/CGSpunk/issues

27 Likes

I have released a big update to CG Spunk today, v0.0.9. Here are some of the enhancements that have been added:

  • Most operations call directly into the CG JavaScript framework, rather than manipulating DOM objects, so they are faster and more reliable.

  • Can rerun each match in a batch run with player positions swapped (feature request from @Neumann)

  • Can see a replay of any match in a batch run (another @Neumann request)

  • Matches with crashes are clearly labeled

  • Can send match parameters to the IDE to reproduce a specific match

Enjoy! And feel free to add bug reports / feature requests on GitHub.

  • danBhentschel
2 Likes

Does that means that you directly manipulate their API ? If so, would it be possible to manually set the agentId parameter ?

Yes, that is effectively what it’s doing now in the most recent versions.

For example:

let agent0 = angular.element('.agent').eq(0).scope().$parent.agent;
angular.element('.agent').eq(1).scope().api.addAgent(agent0, 1);

So the SWAP operation is pretty much instantaneous now, instead of navigating through the agent selection screen.

  • danBhentschel

Sweet !
Every pushed AI has its own unique agentId, so it is possible to test some code against an AI version that isn’t in the arena anymore (Recar, I’m looking at you).

Adding a field in the plugin to manually type an agentId would be the ultimate feature ! No more AI-hiding problem during contests, and CG staff won’t even have to add this feature themselves.

But how do you get the agentid of an IA that was pushed once ?

1 Like

Okay, so after playing with this a bit, I have validated that it is definitely feasible, and if you wanted to, you could start doing it today. Just do this:

  1. Load CG Spunk

  2. Go to the IDE

  3. Right-click on one of the player’s avatars and select “Inspect” from the context menu. This step is important. It sets the execution context for the JS console.

  4. Open the JS console

  5. Type the following into the console:

    api = angular.element(’.agent’).eq(0).scope().api
    user = {pseudo: , avatar: }
    agent = {agentId: , codingamer: user, valid: false}
    api.addAgent(agent, )

Where:

<id> = The agentId you want to test against

<name> = The name for the agent (in quotes). This can really be anything. It’s just a label. Ideally, you use the actual username, but it’s not necessary. If you omit it, then things will still work, but the agent will be “Unnamed”

<avatarId> = The id of the avatar image to show for the agent. Again, this can be any avatarId you want, or you can omit it to use the standard ‘ghost’ image.

<position> = The index of the position to load the agent into. 0 for left, or 1 for right.

If you want me to include this in the UI for the extension, I could do so, but as @Aveuh said, I think it would be of very limited use, and might cause some confusion. Feel free to write up a proposal, though. :slight_smile:

  • danBhentschel

Just watch the outgoing request in your browser while pressing the PLAY button against that particular AI.

There is no way to retrieve that id when its no longer in the arena, but if you watch the arena leaderboard closely enough, sooner or later you’ll catch something interesting to save for later tests :wink:

1 Like

This manual work-around will do the job I guess. This feature will only be useful for a few people during contests.

Nice job! This will be handy.

Version 0.1.0 has been pushed to the Chrome Web Store, and will be rolling out soon. Changes include:

  • Improved summary info in run report
  • Fixed garbled results when multiple report windows open
  • Can now run multiple batches simultaneously from separate tabs
  • Can randomly select opponents from players ranked close to you

If you encounter problems, please let me know.

  • danBhentschel
2 Likes

Hey,

I tried to use tonight the batch run vs close people in rank and it systematically stops after one run. The javascript console gives an error :

Uncaught TypeError: Cannot read property ‘agentId’ of undefined
(Line 18 of the minimized code)

I’m using Chromium Version 51.0.2704.79 Ubuntu 16.04 (64-bit)
Same thing with Chrome 52.0.2743.116 under Windows.

1 Like

Got the same problem no matter what i use as input

[quote]de2aa34b.codingame.js:18 Uncaught TypeError: Cannot read property ‘agentId’ of undefined
f.addAgent @ de2aa34b.codingame.js:18
rotateAgents @ Injected.js:28
(anonymous function) @ Injected.js:6
[/quote]
Chrome Version 52.0.2743.116 m

Sorry. I’ve been hiking in the mountains the past 4 days. Just got back. :slight_smile: I’ll take a look at this as soon as I get some sleep.

  • danBhentschel
1 Like

I believe this is related to Issue #21. I can reproduce the bug, and it appears to only affect games where there are more than 2 players possible (i.e. Tron in Silver) and you select “Perform each iteration a second time with positions swapped”. It gets confused when trying to swap two players if the 3rd player position is empty.

I should hopefully have a fix soon.

  • danBhentschel
1 Like

A partial fix for Issue #21 (that resolves the specific problem reported) has been published as v0.1.3. It should be rolling out to clients now.

  • danBhentschel
1 Like

Thanks a lot !
So how do you perform the switch ? Are you shuffling the players ? Or just switching players 1 and 2 ?

1 Like

It shifts all players to the left, and wraps the first player to the last position. This allows for 3 (of 6 possible) different configurations with 3 players. I haven’t figured out a good way to handle the multiple player permutations issue.

Should I just stick with the shift-left strategy and execute 3 matches per run for 3 players, or should I execute 6 matches per run? This can balloon quickly, and becomes a reporting headache.

It currently executes a hardcoded 2 matches per run (when swapping is enabled) which obviously doesn’t work very well for more than 2 players.

  • danBhentschel
1 Like

Well, I wouldn’t mind having every possibility tested, but that multiplies the number of matches per 24 for 4 players so maybe not a good idea. Trying the left shift could be a good solution I guess ?

1 Like

A new version of CG Spunk (v0.2.0) has been published to the Chrome Web Store and should be rolling out to clients soon. There are pretty substantial improvements in this release, including:

  • Pretty good support for multiplayer games with more than 2 players.

  • The ability to directly compare IDE code vs. arena code in the exact same game scenarios

  • The ability to “save” and “restore” batch runs (by copying and pasting the batch description JSON) so that you can run the exact same test with updated code

  • The ability to manually enter batch description JSON (advanced) to specify opponents and boards.

Enjoy.

  • danBhentschel
1 Like