Emulation of a Player
Emulation of a Player
I have been unable to find a way to successfully emulate player input on a tick by tick basis, I was hoping to make a more accurate version of tas tools but haven't found any way to do so. Is this a possibility to do or have I just been looking for something that isn't possible.
Re: Emulation of a Player
https://github.com/gotyoke/Factorio-AnyPct-TAS
https://github.com/Bilka2/factorio-tas-playback
Both somewhat outdated and my fork definitely isn't feature complete. Good luck.
https://github.com/Bilka2/factorio-tas-playback
Both somewhat outdated and my fork definitely isn't feature complete. Good luck.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Emulation of a Player
I'm still trying to figure out how you got movement to work 

- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Emulation of a Player
Did you ever test that in Multiplayer? I guess for speedruns that's not a relevant criteria?Bilka wrote: Mon Dec 30, 2019 6:39 pm https://github.com/gotyoke/Factorio-AnyPct-TAS
https://github.com/Bilka2/factorio-tas-playback
Both somewhat outdated and my fork definitely isn't feature complete. Good luck.
Just wondering if walking_state actually is meaningfully usable outside of a 0-ms-ping context now.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Emulation of a Player
My fork works in multiplayer if the runner is the host. That means you could host the tas and have spectators. It doesn't work for joining players, because the latency/multiplayer logic can randomly delay actions a few ticks (usually when latency changes), most meaningful of those actions are crafting, mining and walking. Since the mod just does "x task at y tick", just a 1 tick delay in for example mining means that the mining isn't finished and everything goes wrong. A true multiplayer version would have to be more dynamic and work with events etc. However, there is another flaw to multiplayer: players joining messes with the rng, so the rng "manipulation" used for mining coal rocks doesn't work. For that reason, I never looked into making the mod dynamic.eradicator wrote: Thu Jan 02, 2020 3:11 pmDid you ever test that in Multiplayer? I guess for speedruns that's not a relevant criteria?
Just wondering if walking_state actually is meaningfully usable outside of a 0-ms-ping context now.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Emulation of a Player
Ah yes, that would be exactly the experience i had :(. Thanks for confirming. Wish i could just issue a unit-style move command to the player.Bilka wrote: Thu Jan 02, 2020 4:03 pm My fork works in multiplayer if the runner is the host. [...] It doesn't work for joining players
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Emulation of a Player
eradicator wrote: Fri Jan 03, 2020 4:07 am Wish i could just issue a unit-style move command to the player.
Merry Christmas: I made this script a few months ago for an experiment I was working on, its probably still rough around the edges.
I also made this tiny scenario to demonstrate it, (not sure if it still works):
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Emulation of a Player
Can't currently test that. But if it's just an on_tick manipulation of walking_state wouldn't it still look shitty to the player who's "being walked" when lag-hiding does it's thing in a laggy mp game?Klonan wrote: Fri Jan 03, 2020 12:07 pmI made this script a few months ago for an experiment I was working on, its probably still rough around the edges.eradicator wrote: Fri Jan 03, 2020 4:07 am Wish i could just issue a unit-style move command to the player.
Edit: Original post here viewtopic.php?t=58090
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Emulation of a Player
I don't see why it would look shitty, the script will execute on_tick for the client, and latency hiding won't have any effect unless you start pressing the movement keyseradicator wrote: Fri Jan 03, 2020 12:40 pmCan't currently test that. But if it's just an on_tick manipulation of walking_state wouldn't it still look shitty to the player who's "being walked" when lag-hiding does it's thing in a laggy mp game?Klonan wrote: Fri Jan 03, 2020 12:07 pmI made this script a few months ago for an experiment I was working on, its probably still rough around the edges.eradicator wrote: Fri Jan 03, 2020 4:07 am Wish i could just issue a unit-style move command to the player.
Edit: Original post here viewtopic.php?t=58090
Ping would only have an effect if some command was being sent from the server each tick, but this is all controlled inside the Lua script of the game, so MP or not won't make a difference
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Emulation of a Player
That was also my expectation when i first tried this 2 years ago, but at the time (possibly to lacking experience) i found no way to make it work properly in mp. And it'll be a few weeks until i can test this.Klonan wrote: Fri Jan 03, 2020 1:41 pm Ping would only have an effect if some command was being sent from the server each tick, but this is all controlled inside the Lua script of the game, so MP or not won't make a difference
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Emulation of a Player
Did you read my post?Klonan wrote: Fri Jan 03, 2020 1:41 pm I don't see why it would look shitty, the script will execute on_tick for the client, and latency hiding won't have any effect unless you start pressing the movement keys
Ping would only have an effect if some command was being sent from the server each tick, but this is all controlled inside the Lua script of the game, so MP or not won't make a difference
Bilka wrote:It doesn't work for joining players, because the latency/multiplayer logic can randomly delay actions a few ticks (usually when latency changes), most meaningful of those actions are crafting, mining and walking.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Emulation of a Player
Thats not how the Lua scripting works, the Lua script isn't ever delayed, it always executes on every tick for every client and serverBilka wrote: Fri Jan 03, 2020 8:05 pmDid you read my post?Klonan wrote: Fri Jan 03, 2020 1:41 pm I don't see why it would look shitty, the script will execute on_tick for the client, and latency hiding won't have any effect unless you start pressing the movement keys
Ping would only have an effect if some command was being sent from the server each tick, but this is all controlled inside the Lua script of the game, so MP or not won't make a difference
Bilka wrote:It doesn't work for joining players, because the latency/multiplayer logic can randomly delay actions a few ticks (usually when latency changes), most meaningful of those actions are crafting, mining and walking.
EDIT: So I tested it out, the jumpiness comes from the latency hiding predicting where the player will be based on the current movement at the current tick (As opposed to player input as I thought it would use for its prediction). So if the script is going to turn the guy around in 1 tick, the latency character position will be incorrect
The solution is to disable the latency hiding, which I see from this old post you have mentioned before eradicator:
viewtopic.php?t=63525
- Attachments
-
- 2020-01-03_21-45-15.mp4
- (8.45 MiB) Downloaded 92 times
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Emulation of a Player
By setting shooting state? Certainly never thought of using it like that. Albeit that has the drawback of applying the weapons movement penalty.Klonan wrote: Fri Jan 03, 2020 8:11 pm The solution is to disable the latency hiding, which I see from this old post you have mentioned before eradicator:
viewtopic.php?t=63525
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Emulation of a Player
That is how lua scripting works. Here is a demonstration. On the left is the host, on the right the joining player. The joining player is commanded to craft pipes by script, and the finishing ticks of the crafts are printed into chat. You can see that the crafting takes 2 ticks longer to complete than it should (see chat history) due to a latency change.Klonan wrote: Fri Jan 03, 2020 8:11 pm Thats not how the Lua scripting works, the Lua script isn't ever delayed, it always executes on every tick for every client and server
I used crafting as the example because it is extremely easy to demonstrate the issue with it, however mining and walking (and some other stuff) exhibit the same behaviour. Here is the command in case you want to try it yourself:
Code: Select all
/c local player = game.players[2]; global.tick = game.tick; player.insert{name = "iron-plate", count = 8}; player.begin_crafting{count=8,recipe="pipe"}; script.on_event(defines.events.on_player_crafted_item, function(e) game.print(e.tick - global.tick) end)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.