View Full Version : Avisynth does Tic Tac Toe, BUT...
vion11
9th August 2003, 22:04
I'm testing AviSynth for real world apps and got strange behaviour:
- 30MB needed per second (both 1f/s and 25f/s)
- very slow in comparison to other languages (basic, lisp)
- crashes if runs out of memory
For demonstration this script uses simple AI functions and renders
random TicTacToe games, download it here:
updated: www.avisynth.org/vion11/stuff/ttt.avs (http://www.avisynth.org/vion11/stuff/ttt.avs)
main function in line 14 is: PlayGames(int)
If you want to render three games with about 33 pics,
you need 1GB of virtual memory. Otherwise adjust your swapfile.
Enlightening is the combination of taskmanager, vdub
and stepping through the frames.
Will this unreasonable behaviour change in version 3.0?
esby
10th August 2003, 17:58
"Will this unreasonable behaviour change in version 3.0?"
From my point of view, it is unreasonable to use avs for any other
purpose than video.
Avs is obviously not fitted for these kinds of needs,
sounds like you are trying to use a nuclear plant
as a coffee machine for me...
Or maybe the reverse, i can't tell.
Aside from that, optimizing memory use or suchs schemes
linked to this 'game' might be a good idea...
if they can be met in a video encoding content.
esby
TCM
10th August 2003, 21:36
am i the only one falling out of the chair when reading this?
good joke vion11. however, if you are really trying to be serious then i have to say: good troll.
zettai
10th August 2003, 22:08
Troll or not, the memory issues within Avisynth are significant when using avisynth for video editing.
Wanting to edit around 20 avs files in Adobe Premiere forces me to put SetMemoryMax(16) at the top of every avs script to make sure that avisynth doesn't cause a memory access violation when loading up all 20 avs files at once (due to memorymax being percentage based and set upon script activation)
I'm sure there's got to be a more sensible way of handling memory when using multiple scripts at once (we've discussed this before in a thread called Thanks for the Memory).
sh0dan
10th August 2003, 22:14
Really impressiv ewhat you've made AviSynth do!
@zettai: Put a "something.avsi" file containing the setmemorymax int your plugin dir. It can even be setmemorymax 1 - then only the memory needed will be used.
The current behaviour is not very likely to change, even though it might be optimized a bit. For NLE it is still recommended to render out your material as a temp file anyway.
Bidoche
10th August 2003, 23:14
@zettai
Actually, avisynth was not designed to run multiple scripts at once.
Then it does not automatically share memory between renders, filters does not use instances folding (avisource definitely should do it)
In fact, it could even crash due to the shared code which is not synchronised. (very very unlikely to happen though)
vion11
11th August 2003, 15:11
I'm simply searching for a solution to generate dvd video content
automatically without clicking like hell.
I've some avisynth apps programmed running good and stable.
As a matter of copyright I use this braincandy TicTacToe stuff
showing the limits. So thats no trolling at all.
Avisynth automates tasks in a convenient way with the power of a nuclear plant,
nobody has told me to use only the coffee-machine from the janitor in second floor.
I can programm around the memory limit crash
and horsepower will avoid runtime.
But I'll never understand the need of terrabytes of RAM to fill
a mini-DVD with 600MB when the source is a frame.
Or more simple: why does rendering one frame needs 30MB memory?
May be a simple description of the memory management for
non C-programmer would enlighten. Gimme a link!
b0b0b0b
12th August 2003, 04:46
Your script looks like something that SML / OCaml / ... would be able to handle (and actually want to handle). I'm guessing that if you're seeing high memory consumption / cpu usage, there is probably a lot of redundant work being done and done again, something you might address in an imperative language with memoization. Cool script though! My computer is weak and cannot run it :)
Bidoche
12th August 2003, 10:21
@vion11
the clip is not a frame, but a clip, even if it's repeat the same frame, avisynth is not aware of that.
Would you import it from a jpeg and loop it, it would probably be better.
vion11
13th August 2003, 19:50
@Bidoche
Same problem with jpegs. You'll see the point
if you load script into vdub, wait till first frame,
and then move *one* frame further and look what
happens to memory consumption (taskman).
Every frame makes 30MB in 1f/s mode.
@b0b0b0b
Compiler languages will help in memory issues, but kill automation.
Depending on database content avisynth and authoring scripts are generated,
which I can test via mpc or load into mpeg2-encoder.
When finished authoring prog creates the build.
So it's a one-click solution from an updated database to a ready DVD-image.
Do you know other interpreter languages with avi capabilites?
What kind of weakness prevents your machine from rendering?
Have you tried PlayGames(1)?
@sh0dan
Thanks! Actually to continue the developping of avisynth is impressive as well.
Why it's recommended to render out temp files?
@all
Who can help me to understand the way avisynth uses memory
so I can write better code?
Are any there other places where avisynth issues are discussed?
WarpEnterprises
13th August 2003, 20:51
as discussed some time ago, AviSynth uses very much memory for recursive (user) function, which you make excessive use of.
After reading quickly through your script some control structures (loops,if/else, breaks,...) would seem good.
The script runs forever on my PC.
Could you _sketch_ what it does?
vion11
14th August 2003, 19:25
@WarpEnterprises
with 900mhz it runs about 3min. With a lisp interpreter less than 1sec.
Searching in a hierarchy with structures like for/next is horrible,
so I'm trained to use recursive functions. You'll get the point if you try to translate the GameMatches() function.
Description:
There is a background, the board with nine squares, two players,
the next pull and the decision if game finished.
The board is a string with nine Chars with spaces(e.g. ". . X . O O . . X")handled as a list.
X always starts.
PlayGame() will play till end of game and adds new pics with PrintGame().
Printgame() uses PrintPin and SetPin() for marks.
GetNextStep() first determines current player, then looks for free squares,
checks if current player can win, if not if opponent can win, if not chooses random square. and so on.
mf
15th August 2003, 11:01
Ooo! And there I was, thinking I was virtually the only one using AVS for things other than simply putting filters after eachother. Nice work :).
mf
15th August 2003, 14:28
Btw, you can also script your tic tac toe board. You import an AVI file, yet you can also do:
function TicTacToeBoard() {
topbottom = BlankClip(1, 768, 52, "RGB24", 1, color=$000000)
left = BlankClip(1, 152, 472, "RGB24", 1, color=$000000)
right = BlankClip(1, 144, 472, "RGB24", 1, color=$000000)
block = BlankClip(1, 156, 156, "RGB24", 1, color=$000000)
gridhor = BlankClip(1, 2, 156, "RGB24", 1, color=$FFFFFF)
gridver = BlankClip(1, 472, 2, "RGB24", 1, color=$FFFFFF)
block1 = StackHorizontal(block, gridhor)
block2 = StackHorizontal(block1, block1)
block3 = StackHorizontal(block2, block)
block4 = StackVertical(block3, gridver)
block5 = StackVertical(block4, block4)
block6 = StackVertical(block5, block3)
full1 = StackHorizontal(left, block6)
full2 = StackHorizontal(full1, right)
full3 = StackVertical(topbottom, full2)
full4 = StackVertical(full3, topbottom)
return full4
}
:D :D
vion11
18th August 2003, 18:19
hi mf
looks great, should decrement memory use. Will check asap.
What do you elicit of avisynth?
Looks like there's a need for a sophisticated development forum.
What about starting with a my longest script contest?
mf
18th August 2003, 18:53
Originally posted by vion11
hi mf
looks great, should decrement memory use. Will check asap.
What do you elicit of avisynth?
Looks like there's a need for a sophisticated development forum.
What about starting with a my longest script contest?
Well, it's simple. I can't program, so I script my own filters in AVISynth instead. It's not very special, just some mask making and processing based on those masks (apparently, that's just about all I seem to do). I think the longest script I ever made is about 150-200 lines or something, but I don't think I have it in full anymore (and it ran at sub-1fps). I think you'd win such a contest anyway, since what I do is still only one step beyond simply placing filters in linear succession. I still use it for its intended purpose, which is still just video editing.
thoralf
13th August 2004, 21:12
Hey,
does any of you still have this script somewhere? Unfortunately, it's not on the server anymore.
I love things like this ... :)
With kind regards,
Thoralf.
vion11
14th August 2004, 16:01
Together with mfs work it is here now:
www.avisynth.org/vion11/stuff/ttt.avs (http://www.avisynth.org/vion11/stuff/ttt.avs)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.