Topic: Soldier auto-fighter in webassembly
leklachu Topic Opener |
Posted at: 2021-12-11, 21:27
Hi, I was browsing things about soldier balance, and thought about a program to simulate fights to see the balance between tribes. Turns out einstein13 has already done that, but I fancied the idea for a hobby project anyway, and I now have the first vaguely-meaningful draft. Mine's written in Rust, and I got it to work on the web! So it should run fast but accessible to all. (Currently I get a total refresh in 1s; seemed to take about 4s from fully cold start.) The current version very simply pits 100,000 of each tribe, max level against each other tribe, half the battles being first-hit by each tribe, then chucks those results in a table. Underneath, the code is also calculating the % remaining health of each team and the mean/stdev of individual soldiers' remaining healths. (But I haven't wired that up to the html display yet.) I have a few more ideas planned too, such as soldiers in a line: fight the soldiers one by one keeping the survivor to fight with his remaining health. First beginnings at:https://wide-fighter.netlify.app/ einstein13's python scripthttps://github.com/einstein13/wl_soldiers Some relevant forum threads,https://www.widelands.org/forum/topic/4351/ It's an irregular hobby......but if anyone finds it fun/useful I'll do my best to get it to a sort of v1, at least with customisable fields and some more results. I'll try anyway, but time for me is quite unpredictable. And if anyone wants to help with layout/styling (even just a css file) I can hopefully wire that into the program. (It's built with https://yew.rs/ for the web framework) Top Quote |
hessenfarmer |
Posted at: 2021-12-11, 21:50
nice work. It is very fast for doing 100000 rounds. However if you swap the first hit after half of the fights the results table would be symmetric (with infintie fights) to make it more meaningful I would prefer to not swap the hit and have the values for a defending soldier and an attacking soldier. Top Quote |
leklachu Topic Opener |
Posted at: 2021-12-11, 21:56
Thanks
Yep, if I don't get stuck on how to do html input I'll hope to have that soon-ish
underneath the simulation is also calculating that already, so once I wire up making lots of tables on the UI, I should be able to get that in easily. Just might become a long page to scroll with everything! until I learn how to do multiple pages or something... Top Quote |
leklachu Topic Opener |
Posted at: 2021-12-12, 02:18
Done. v0.2 is here!https://wide-fighter.netlify.app/ That's now displaying all the results my simulator gives - I hope I put everything in the right place! v0.3 will focus on allowing user input to customise stats and levels Top Quote |
kaputtnik |
Posted at: 2021-12-12, 10:47
Very nice! You know the wikipage about Soldierlevels? Maybe we can integrate this in our website?
Top Quote |
leklachu Topic Opener |
Posted at: 2021-12-16, 14:58
Thanks
Sounds great! For wiki syntax, which seems to be Markdown, it shouldn't be too hard for me to get the results output either to a console or even on the web page as tables that can be copy-paste into the wiki. There's no point overwhelming the wiki with stats though, so maybe someone should decide what's actually helpful to have there - then have a link to the app for the rest. The app itself is just a skeleton html file, loading some javascript glue, loading a webassembly module. I think in principle I can set the the app to load into a particular html <div>, rather than the whole page, and then if someone can put the js and webasm modules on the server and put the necessary html line in the wiki page (I didn't see a way for raw html in the wiki syntax* - probably good for security reasons), the app could be loaded into the wiki. That could turn out easy or hard. I'm afraid I haven't got much time at the moment though. I also hit problems getting user input to customise the soldier stats, and it might have to wait some time now till I'm able to get that sorted. I'm happy to give pointers to anyone who wants to try fixing it themselves (and the source is on Github), and I'll get to it myself sometime... no promises when though. * huh, looks like this forum might allow putting raw html into messages. I wonder how well that's sanitised... Top Quote |
kaputtnik |
Posted at: 2021-12-16, 16:06
We allow only minimal tags and attributes Top Quote |
mxb2001 |
Posted at: 2021-12-20, 06:04
Poor Empire! Those legionaires aren't a match for anyone. -- |
leklachu Topic Opener |
Posted at: 2021-12-24, 22:33
Ah great. v0.3 is hereAs promised, some customisation. Forgive the terribly clunky interface, I can't make sense of input in yew-rs, but at least buttons work so I used those. This means actually customising the numbers within levels is still out of reach - but you can set up your fighting arena with standard soldiers of any training level now! https://wide-fighter.netlify.app/ Bugs expected in the UI; the core simulator should still be sound. You can report bugs here in this thread or on the app's github: https://github.com/leklachu/wide-fighter Future development
Happy Christmas everyone. This is apparently how I recover from COVID on Christmas Eve Top Quote |
hessenfarmer |
Posted at: 2021-12-25, 01:20
Hey great work. Top Quote |