Recommend
12 
 Thumb up
 Hide
12 Posts

Falling Sky: The Gallic Revolt Against Caesar» Forums » General

Subject: Yet another automated bot thing rss

Your Tags: Add tags
Popular Tags: [View All]
Recently I got the itch to automate the bots to enhance my solo play. I saw there was another project that was working on some automated bot scripts, but it wasn't really going the direction I prefer, seemed to be a bit dead, and I figured this would give me the chance to play around with some current web technologies, so I gave it a whirl.

After spending about 2 weeks on it, I've discovered that it is both a fun and much more challenging project than I expected. I am really enjoying puzzling out some of the logic and learning the rules so intimately. Now I've got a good framework going for it and have implemented the basic flowcharts for Aedui, Arverni (well I've got one last march case to cover), and Belgae, plus about 50% of the event handling for the Aedui. I've also done the Germans, and the rest of Winter other than some of the faction quarter actions. I've also implemented a quick UI and thought I'd solicit some feedback. There are certainly plenty of bugs in the logic at this point, but it is not far from correct.

I'm pretty sensitive to the fact that the bot flowcharts are not made public, and I don't want to upset anyone at GMT, so as of now it just plays against itself. I've implemented it such that I think adding player input should not be too hard. The commands are done in such a way that it would be fairly easy for a player to choose a command, it would tell you what regions were valid, you could choose them, execute, choose a special action at any time execute it, undo if you don't like it, try something else and so forth.

Alternatively the game state could be manipulated directly, but that would probably end up a bit more clunky, though it would be good for setting up specific situations to try out. I know VASSAL integration is desirable, but honestly, I want to use this to enhance my physical play, and I want it to work on a mobile device.

As far as I know, I'm the only target user, but if anyone else would like to provide feedback or has interest let me know. I would be willing to provide access to the github repo if someone would like to help out as well. Ultimately I would like it to be a canonical implementation of the bot logic, to facilitate solo play, or possibly to help people learn better how the bot logic works. A tricky situation could be input and then the bot could be run to see what it would correctly do. But there still is a long way to there from where I am now. In the highly unlikely case anyone is familiar with Javascript and would love to write lots of test cases it would be extremely helpful

I just whipped up the current UI over the past day or so, but basically in the top area it shows you the upcoming / current cards, the sequence of play, and the results of the bot's decisions. At the bottom there are a few tab like things which will allow you choose between showing the current state of the regions, some info about the faction's available resources and so forth, and the capabilities in play (I have yet to mark which faction). Using it on a phone size screen works, but is not ideal. There is also a tab for the board itself, but it is not functional, and was just something I was toying around with the idea of implementing. The main problem there is trying to fit pieces into tiny regions like Morini, and it also just becomes me implementing a complete browser version of the game.

It is set right now to play 52BC The Great Revolt, so just click "start" at the top and it will initialize the state to that. Then click the green button next to it to step through the turns / card draws / winter. You can click the red undo button at any time to undo, but at the moment it does not let you undo through winter. If you want to see more detailed information about what the bots are doing you can look in the console log. Right now the game does not check for victory, though it does track the margins, so it pretty much just can go until the cards run out. I think actually might let you keep executing actions on the last card which is silly, but I'll get to it

And finally, here is the url: https://justinkwaugh.github.io/COIN/

Feel free to give any feedback you like or none at all. At this point I will probably head back into working on the bot logic to add the Romans, and then start grinding through the events.

16 
 Thumb up
1.55
 tip
 Hide
  • [+] Dice rolls
Bart de Groot
United Kingdom
Oxfordshire
flag msg tools
badge
Avatar
mbmbmbmbmb
It looks great! Makes me think I shouldn't bother with the VASSAL ones.

How separated is the bot logic from the UI? (e.g. MVC?)
Could your JavaScript model be fed a game state by another script, told to execute a certain operation, and output the bot actions? (my COINBot VASSAL extension has the bot logic in JavaScript) It looks like your script already functions in a similar manner, so it would perhaps be a matter of how you designed it?
How does/would it handle Q/A on the flowchart? E.g. certain steps require asking other factions for permission before it can proceed?

From what I understand on the GMT policy is that as long as the actual flowchart images are not shared a helper bot app is fine. For example LWOTai.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Ok, good to know about the flowchart images.

As far as the design goes, it admittedly was put together quickly, but I put a modicum of thought into it. I'm using Knockout for the UI, so there is practically zero mixing of the UI and logic. It mostly it just controls a game class which handles the drawing of the cards and telling the bots to take turns. Though I do also use Knockout for non-UI aspects such as keeping computed state info like victory margin automatically up to date.

In general there are a set of commands, some more common (March/Rally/Raid/Battle) and some more specific to faction (Suborn/Trade /Rampage etc.). They all have a "test" method which will produce possible results, so for instance for Battle.test(), it returns the set of possible battle results in each region. March.test() returns a list of possible destination regions for each possible start region. The design is a little broken due to me changing my mind twenty times and things mutating over time, but I had a bit of an intent for there also to be an execute() method for each command, which then would take the instructions of what to do and do them. Some are in fact implemented this way but others are just handled by the bots themselves.

Anyway, so the bots have a takeTurn() method which then starts their flowchart. They also have a corresponding bot/faction specific class for each type of command which handles the decisions of what to do. They examine state, call the test method, consider possible results and decide what to do.

In order to actually modify game state there are a set of granular Actions, like PlaceWarband, or AddResources, or MovePieces etc. All game state mutation is intended to be handled by these actions (there are a couple things I still need to make into actions such as senate movement, which is why you can't undo across winter). The reason for this is that actions all keep track of what they did and have an undo(). The state class holds an array of these actions which represents all changes to the state over time. There also is the concept of an ActionGroup which for the most part is just a pointer to a range of the actions. There is a Turn class which is one, and it also holds action groups for commands and special abilities. This allows for the testing and rolling back of things, though there isn't much of that used at the moment except for undoing full turns in the UI. The intent here is for player input so that things can be attempted and rolled back, at whatever level of granularity is required. The combination of action groups and actions can be considered the "output" of the script (aside from the mutated game state itself) and it is used to show the list of changes in the UI.

Aside from that stuff, there is a class which handles the sequence of play, keeping track of which faction took what action and who is eligible or not and what actions are available.

My intent is to make the game state serializable to provide for local
or remote saving, so it would be easy to take state as input and produce the aforementioned output.

Q/A is currently handled by the bots in that the state has a list of players by faction. They are all bots right now, but when a bot needs to ask for an agreement, it gets the player for that faction and asks it. The bots answer in their pre-programmed way, usually in a cranky dissenting way per the flowcharts. The same mechanism will be used to ask human players though the asynchronous nature of that will need to be dealt with.

Everything is written in ES6 javascript using webpack / babel to transpile and bundle to es2015 javascript. Karma / mocha / chai are used for test cases.

I've made the repo public so you can take a look, please excuse the mess
https://github.com/justinkwaugh/COIN
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Gabriel Conroy
msg tools
mbmbmbmbmb
This is excellent.
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Well Bart is going to work on integrating it to vassal, so I guess that is happening. I'm currently working on player interaction (for agreements and so forth) and will then focus on doing the basic romans flowchart.
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Bart de Groot
United Kingdom
Oxfordshire
flag msg tools
badge
Avatar
mbmbmbmbmb
Justin is making good progress on implementing the bots. I will couple his bot logic with my VASSAL extension. In the end you should be able to use either the VASSAL module (by Joel/Dulgin) or Justin's web app to automate the bots.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
TL;DR - Bots can play themselves with no events for an entire game, and you can undo all the way back. Work continues at a good pace. Check it out!



Lots of progress is being made. All of the flowcharts have been implemented, and victory checks are done and so forth, as well as undoing through the winter. Likely there are myriad bugs at the moment, but I've implemented the flowcharts as best I understand them. My understanding has improved over time though.

So now you can start The Great Revolt and step through an entire game of the bots playing against themselves, and undo all the way back to the start.

The Aedui are the only ones that have some events implemented currently. I will be going through and implementing all of them starting with the capabilities. Most of the effects of the capabilities have been implemented apart from Vercingetorix's Elite (not too hard) and Diviciacus. Diviciacus will be a bit challenging due to its widespread impact.

Player interaction has been partially implemented, and the bots can ask a player for agreements or use of capabilities and so forth, but not quite yet in all places. Obviously as there currently is no way to be one of the factions in the UI it is not too helpful, but it works well in test cases.

I will also be adding state saving so that progress is maintained across browser sessions. It all runs locally, and I will use local storage at first to store the state.

Then I will implement the basic ability to be a player of a faction, and input what happened on your turn. The first iteration will likely be simple such that you just modify the pieces in each region and so forth. My pie-in-the-sky goal is for you to be able to choose what action / special ability you took and it will guide you more efficiently through the process (and check for errors).

This has turned out to be quite a more challenging project, and while I'm going to keep working on this for my own use regardless, I am curious if anyone is interested in using it to assist their solo games. I also am always open to any help that can be provided.

Anyway, check out the latest version at: https://justinkwaugh.github.io/COIN/
4 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
I've been working on adding events. All the factions will grab their capabilities now per the flowcharts. Verc's Elite shaded and Diviciacus unshaded are still not actually handled though. All other capabilities are handled. About 50% of the Aedui and Belgae events have been implemented as well.

I've also added a "run" button to the UI, which will start it automatically running through game after game, pausing for 2 seconds at game end. The game can be stopped at any time by pressing the "stop" button, and then normal stepping forward/backward can be done, or click "run" to resume.

I find it somewhat mesmerizing to watch. It will be interesting (to me) when all is said and done to see which bots win more than others and in what phase in a 0 player game.
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Don Beck
United States
Laingsburg
Michigan
flag msg tools
badge
Avatar
mbmbmbmb
Just wanted to drop in a note of encouragement. I only recently found your "bot engine" and am very impressed--and look forward (hungrily) to trying this out as a player once that capability is added, in order to use it during solo play.

Nice work!
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Thanks for the encouragement

I'm away this week but have made some progress. All but 12 of the events are now handled by the Belgae. If course I left some the hardest for the last so those will take some effort. Once I finish that I will probably then do the arverni events which should be fairly easy as they also use the shaded events. Some of the priorities are different from the Belgae of course so it will require a little work.

Then I will probably go through and do all the Roman events followed by Aedui.

After that I will have to work on serialization of game state to facilitate player interaction.

Then I will begin the player input UI.

It will be a long road
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Ok, just dropping in for an update. Belgae and Arverni event handling is 99% done. I might switch to working a bit on player input stuff for a while to keep myself from going insane.
7 
 Thumb up
1.00
 tip
 Hide
  • [+] Dice rolls
Don Beck
United States
Laingsburg
Michigan
flag msg tools
badge
Avatar
mbmbmbmb
Great job! Looking forward to it!
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Front Page | Welcome | Contact | Privacy Policy | Terms of Service | Advertise | Support BGG | Feeds RSS
Geekdo, BoardGameGeek, the Geekdo logo, and the BoardGameGeek logo are trademarks of BoardGameGeek, LLC.