(This is Day 21 of Foxy's Diary).
Update April 2021: latest versions of Foxybot working with Eulora 0.1.2b.
Like anywhere else, work in Eulora is a most wonderful thing ...to watch. So rather than work on working, I worked on avoiding working – and here are my two bots ready to take over Euloran world:
BOTS ARCHIVE - 30 September 2015 sha512sum: Updated (29 October 2015): full client archive is not needed at all, use the minimal archive:
And a minimal BOTS ARCHIVE - 30 September 2015 sha512sum:
Update (29 October 2015): for those who can't review the code but otherwise trust its existing reviews by others, the slightly older version of the minimal archive (it contains additional files that are actually not needed as they aren't changed with respect to standard client version) is still available to download, with sha512sum:
Download the file (BOTS ARCHIVE), check its checksum and otherwise just compile it according to the instructions for your OS. If you download the minimal version, you'll have to copy its contents to an existing client folder, as it contains only the src and data folders. Alternatively, you can run a diff and make a patch to apply to your own current version of the client if you already have some changes that you don't want to lose. The bots are quite contained and in a folder of their own (src/client/foxybot) – other than that there are only minimal changes to the main client code source, most notably in cmdusers.cpp (for the /pilot command) and psengine (to register the bots' window/widget). There are also help entries added for the added /pilot and /bot commands.
The archive above contains three main additions to the standard Eulora V0.1.1 client:
- /pilot command – this is very useful if you need to get to a specific point (such as a claim that you already have and you want to build now). Just give it the pos coordinates of the point you want to get to and it will rotate your character to face towards that point. After that just keep going forward until you reach your desired destination.
- /bot command – this is the control centre for Foxy's bots. Currently, the /bot command supports crafting and exploring as activities. If you type just /bot craft or /bot explore, there will be some help info shown in the bots' window. Basically the structure is /bot craft|explore numberOfAttempts [parameters], where craft and explore have their own, specific parameters. You can also stop or reset the activities at any time with /bot stop and /bot reset respectively.
The exploring bot will move in a straight line of length equal to the size parameter (measured in steps so if you want the claims more spaced out, set your mode to running, otherwise set your mode to walking to cover less ground). If size is smaller than total number of attempts, the bot will go forward size times and then backward size time and repeat. Provided you have all required ingredients, the exploring bot will build all tiny and small claims. If there are no ingredients, it will just continue ignoring those claims (it will NOT lock small and tiny claims). Any claim bigger than small will be locked. Note that the exploring bot does NOT train - it will ignore any ranking message and just keep going until it does the specified number of explore attempts. If you start with a tool in hand, the bot will change it when it is worn-out. Please note that in this situation the bot will just take the first tool of the same kind it finds in your inventory, without checking its quality or anything else. Hence, if all you have are worn-out tools, the bot will happily keep changing them - it won't fail, but you won't get a lot of such exploring either.
The crafting bot WILL train if Heina is in range. Prior to a training attempt, it will move the ingredients for your current craft to the container in order to avoid being overweight (since you can't train when overweight). However, if you have other things in your inventory and you are still overweight after moving the ingredients, it will just fail to train and keep crafting. The crafting bot requires you to equip the recipe/blueprint for what you want to craft - that's how it will know what it is you want to craft. It can handle imprecise recipes using either minimum number of ingredients (use parameter m) or maximum number of ingredients (M). By default, it will use maximum number of ingredients. There is NO use of storage, hence you need to have in your inventory all ingredients for your whole crafting run. If it runs out of ingredients, the bot will simply stop. Similarly, the bot will also stop if your tool and/or container are worn-out (it will NOT change tool/container).
Both crafting and exploring will also write out a log with some relevant information. These logs are found in the same place as your other logs (such as the chat log).
Note that the bots are almost entirely re-written since the previous version. The new overall architecture consists in a control centre (foxybot.cpp) which receives and handles all commands passed as parameters to /bot. Foxybot holds a list of activities (botactivity.cpp) that it can start, stop and reset. Each different "bot" is implemented as a new activity inheriting from the generic botactivity (abstract). Hence, exploring for instance is ExploreActivity and crafting is CraftActivity. All activities interact with the "world" (main client code) through the WorldHandler class.
As previously, the crafting and exploring activities are modeled as sequential state machines. Once started, each activity will perform its first step and then schedule itself (through an internal timer) to be called again after a specified interval. Each time the activity is called again, it will attempt to perform one additional step and then move onto the next state. However, on top of that, there are also higher-level states defined for a generic activity, such as Ongoing, Stopped, Error, Finished. Specific states include init readRecipe, use_combine, train and take_result for crafting. The internal logic for changing states is implemented in method NextAction. Method Perform is called each time the timer expires and it will call the method corresponding to the current internal state (DoInit for the init state, DoExplore for the explore state etc.)
If you want to implement a new activity, create a class inheriting from BotActivity, implement its specific behaviour and then add an object of it to the list of activities in foxybot.
Testing and Issues
As a known issue, the exploring bot will tend to slowly creep backwards if your overall number of attempts is larger than size (hence, length of line). This is because Eulorans move faster backwards than forwards... I'm not entirely sure if that truly says anything about Eulora as a world :D
Some parts of the bots have seen very little testing, mainly because it was really quite difficult to get more testing without a test environment. Most notably, the m/M part was minimally tested since at the moment I don't have the ingredients/interest for most of recipes that are imprecise. Also note that you probably do NOT want to use this feature for the shredding recipe, unless you either want to use m or you really, truly have a ton of ALL the recipes that are being shred (the bot knows no middle ground and it doesn't make exceptions if you have a ton of cft recipes but only 10 congressional pulp recipes).
Enjoy the bots, have fun in Eulora, let me know how it goes and don't get your hopes too high on me fixing /changing/ altering those bots any time soon.
Comments feed: RSS 2.0