stardance has been extended another month! the new deadline is october 31 :)

You are browsing as a guest. Sign up (or log in) to start making projects!

REACTOR

  • 4 Devlogs
  • 13 Total hours

REACTOR is a CLI tool for testing and developing bots for Defector, a hack club event (https://defector.hackclub.com)

Open comments for this post

34m 56s logged

REACTOR DEVLOG #3.5! :jamegam-yay:

This is a very speedy devlog, since it’s only like 30 mins of bugfixing so I can reship, but Ill give some details:
So basically, when I wrote the error handling in the last devlog, turns out I was trying to write to a dictionary (the bot’s data dictionary) without actually initializing it first, causing a silent crash.
I just did a little switcharoo to move the init statement (which was right after :sobbing: ) to run first and now it works fine! I also just added some more error logging with the textual notification system in case something goes wrong and bumped up the PyPi python package version to 1.0.4 instead of 1.0.3.
Also, for the shipwrights, I just want to clarify that it only loads files if they are .js or if they have no extension at all, so no .txt or any other file.

0
0
24

This needs changes before we can consider it shipped. Review the Shipwright feedback, make updates, then ship again.

Shipwright walkthrough

Ship #1 Pending review

Reactor is a special python TUI tool for running bots made for the hack club defector event 100% locally. Gone are the days of uploading your bot to the defector website just to see if there is a bug! Now you can test your bot locally, even against the top 20 leaderboard bots! This project made me relearn python, and also learn a bit about the internal workings of javascript, and most importantly, taught me how to publish a python package to PyPi. If you want to try out Reactor for yourself, download it with pip install reactor_mindstormpro3 or check out my github for more instructions! once downloaded all you gotta do is restart your terminal and run Reactor in it to start it up!

  • 3 devlogs
  • 12h
Try project → See source code →
Open comments for this post

1h 30m 45s logged

Reactor Devlog #3! :jamegam-yay:

Hello guys! Ive been a little busy the past week, but I finally got around to making some progress, and so here’s what I have to show for it:

WE’RE ON PYPI!

I managed to upload Reactor to pypi under the name reactor_mindstormpro3 (Check it out here!)
It took a while to get everything set up but basically I just used hatchling to build and twine to upload, with a pyproject.toml I borrowed from some guide and modified to require some dependencies like py_mini_racer. (Hippity Hoppity Your Code Is Now My Property)

A Lot of Bug Fixing And Changes!

I fixed the following issues:

  • Invalid bots that throw errors when loaded now throw an error as a push notification but doesnt crash the app.
  • Made refreshing more reliable
  • Moved loading bots at boot to a separate thread to not impair loading time of the app.
0
0
24
Open comments for this post

3h 58m 34s logged

Reactor Devlog #2! :jamegam-yay:

What changed?

A lot has happened since my last devlog! I locked in and implemented a bunch of new features, such as:

  • error handling!!!
  • a WORKING request system to fetch the latest reactor bots to test your bot against
  • A bot selector system to add any bot in the CWD or sub-directories into the runner, so you can test your own bot!
  • Better UI!!

Woah thats a lot of changes, lemme break it down…

First, the Error Handling!

This one is kinda the most self-explanitory. Basically, The mini_racer engine for python uses an old version of javascript, so some features, like table.at() isnt supported. For table.at() I just added a filler script to the front of the src that defines it, but I can’t realistically catch everything so I a segment in the loading of the bot that runs the code once and checks for a crash or parsing error from the engine and if it fails then it doesn’t import the bot into the bot table. (AI wrote the filler script, but I originally found the bug and also made the error handling section)

Secondly, The Request System!

The request system is arguably the coolest part of this project, but I feel obligated to also explain that some of the request system was assisted by AI (meaning that AI wrote code, I read it, and then reimplemented it with the same general idea) and also ai DID write the leaderboard grabber which just grabs all of the bots’ id’s that I can use to find their links and grab the src, but ONLY the leaderboard parser, not the bot page parser.
Ok, with that out of the way, how does this really work?
well basically I take and parse the current leaderboard stream at defector.hackclub.com/_app/remote/1jsclqx/leaderboardData. Then with that info, I manually take the bot IDs given with that and shove them into this template: https://defector.hackclub.com/bot/(bot ID here). That spits out an HTML page, so I use BeautifulSoup to parse it with this absolute horror of a line: BeautifulSoup(response.text, "html.parser").find_all("pre")[-1].get_text() and extract the source code, before writing them into a file in the botCache folder in the CWD. Then I load the file as normal, just like any other bot.

Thirdly, The Bot Selection System!

The bot selection system works by just replacing the normal leaderboard widget with a DirectoryTree widget and then setting it to show the current working directory, or CWD. I then use a custom sorter script to show only folders and .js files. whenever a JS script is clicked, it just imports it as a normal bot.

Finally, we have UI Improvements!

I added zebra tiling to the leaderboard to make it more readable, made buttons disable themselves during certain actions like disabling the run button when refreshing, and fixed a few little UI bugs.

What’s Next?

well after this I’m going to try to ship, with only 9 days left in Stardance. I Just need to package it with PyPi and I’m done!

0
0
52
Open comments for this post

6h 33m 21s logged

Reactor Devlog 1! :jamegam-yay:

Wait…. So what is Reactor?

Reactor is a tool to test bots made for Defector without having to publish your bot to the website and go through all that hassle.

What I’ve done in the first 6 hours

  • Installed mini_racer for python and wrote a basic function to take a .js script and run the bot function inside it.
  • Fixed a but with mini_racer lacking array.at() due to mini_racer using an outdated version of js by just defining it myself :)
  • Learned the basics of Textual for making TUIs in python
  • Made a cool TUI that allows you to start the reactor and then shows the statistics of the sim in a table. (see attached image)
  • fixed some misc bugs

Ok, now how does it actually work?

So basically, whenever I want to to play two bots against each other, I define a new mini_racer context with a modified version of their src (changed the export default with export default", "globalThis.botFunc = because otherwise mini_racer wouldnt be able to see it, and added a polyfill to the front of the script to define table.prototype.at()) and then evaluate the bot () function for both bots and simulate a match between them! I then just made a function to loop through each possible robot matchup and run the game of 100-150 rounds, and then delegated the whole thing to a thread so the UI could still render while it runs.

So What’s next?

  • Add the ability to get the bots on the leaderboard and play against them
  • Make some more simple bots
  • add misc features like better UI and the ability to select extra bots to add instead of just ones in the cache folder

See Ya Later!

- Elio :3

0
0
66

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…