Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: how to lock graphical frames to 1 every 2 simulation ticks?  (Read 1882 times)

BenLubar

  • Bay Watcher
  • [BODY:HUMANOID_LEGLESS_6ARMS]
    • View Profile
how to lock graphical frames to 1 every 2 simulation ticks?
« on: December 20, 2014, 12:59:47 pm »

I'm running an AI that plays Dwarf Fortress by itself. The AI automatically starts a movie recording when it starts up. I would like to force Dwarf Fortress to always use two simulation ticks for every graphical tick no matter how many frames are completed per second. That is, if my computer is capable of running at 1000 fps, it should run 1000 simulation ticks and 500 graphical frames in that second. If it can only run at 2 fps, it should only render one time during that second.

I'm doing this on Linux, so it's possible for me to modify libgraphics without needing to reverse engineer anything.
Logged

pisskop

  • Bay Watcher
  • Too old and stubborn to get a new avatar
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #1 on: December 20, 2014, 01:01:05 pm »

o.o  I will ptw.
Logged
Pisskop's Reblancing Mod - A C:DDA Mod to make life a little (lot) more brutal!
drealmerz7 - pk was supreme pick for traitor too I think, and because of how it all is and pk is he is just feeding into the trollfucking so well.
PKs DF Mod!

Sizik

  • Bay Watcher
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #2 on: December 20, 2014, 03:33:57 pm »

You could do it manually by pausing and using '.' to advance a frame.
Logged
Skyscrapes, the Tower-Fortress, finally complete!
Skyscrapes 2, repelling the zombie horde!

BenLubar

  • Bay Watcher
  • [BODY:HUMANOID_LEGLESS_6ARMS]
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #3 on: December 20, 2014, 03:58:21 pm »

You could do it manually by pausing and using '.' to advance a frame.

Can I do that automatically through dfhack somehow?
Logged

pisskop

  • Bay Watcher
  • Too old and stubborn to get a new avatar
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #4 on: December 20, 2014, 06:18:18 pm »

Can you cap the frame-rate at a certain level?

In init.txt you could change:
Code: [Select]
You may set FPS_CAP to 0 to make it uncapped.

[FPS_CAP:120]

Use this to set the maximum graphical frame refresh rate during play.

[G_FPS_CAP:60]

To as low as possible?
Logged
Pisskop's Reblancing Mod - A C:DDA Mod to make life a little (lot) more brutal!
drealmerz7 - pk was supreme pick for traitor too I think, and because of how it all is and pk is he is just feeding into the trollfucking so well.
PKs DF Mod!

BenLubar

  • Bay Watcher
  • [BODY:HUMANOID_LEGLESS_6ARMS]
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #5 on: December 20, 2014, 06:52:40 pm »

Can you cap the frame-rate at a certain level?

In init.txt you could change:
Code: [Select]
You may set FPS_CAP to 0 to make it uncapped.

[FPS_CAP:120]

Use this to set the maximum graphical frame refresh rate during play.

[G_FPS_CAP:60]

To as low as possible?


I could set FPS_CAP to 2 and G_FPS_CAP to 1, but that would mean it would take 50 seconds for each second of the output.
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #6 on: December 21, 2014, 01:55:09 pm »

Probably the best way is going to be like pisskop suggested, set the FPS limit to double your GPS limit, and set them both low enough that you will be sure your computer is hitting the maximum FPS all of the time. It won't be perfect, but the only other thing I can think of is you writing a DFHack extension yourself to do this (if it's even possible that way), because I don't know of any.

On a side note why exactly do you want to do this? If nothing is moving the only differences between something that is operating at 60 GFPS and 2 GFPS when the game is at 2 FPS is going to be the speed at which stacked creatures and blinking things blink (and IIRC they are on timers, not on frame counts, so it shouldn't make a difference once you got over about 30 GFPS as your lower number).
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

BenLubar

  • Bay Watcher
  • [BODY:HUMANOID_LEGLESS_6ARMS]
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #7 on: December 21, 2014, 01:58:09 pm »

On a side note why exactly do you want to do this? If nothing is moving the only differences between something that is operating at 60 GFPS and 2 GFPS when the game is at 2 FPS is going to be the speed at which stacked creatures and blinking things blink (and IIRC they are on timers, not on frame counts, so it shouldn't make a difference once you got over about 30 GFPS as your lower number).

The way I'm making the video, it'll run at 50GFPS no matter how fast or slow the simulation was running. If I have exactly 1/2 GFPS/FPS that means the simulation would run at exactly 100 ticks per second, which is optimal (1 hour in real life = 1 year ingame).
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #8 on: December 21, 2014, 02:16:30 pm »

In that case yeah, set your FPS to 100 and have a computer good enough to maintain that. Other than that not much you can do, most games aren't designed to be able to link GFPS and FPS once they actually have separate ones.
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Naryar

  • Bay Watcher
  • [SPHERE:VERMIN][LIKES_FIGHTING]
    • View Profile
Re: how to lock graphical frames to 1 every 2 simulation ticks?
« Reply #9 on: December 22, 2014, 09:01:31 am »

I'm running an AI that plays Dwarf Fortress by itself.

Have you been checking it's ego and empathy levels ? Because this sounds like a familiar scenario...