| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #!/usr/bin/env th
- local threads = require 'threads'
- local nthread = 8
- local njob = 100000
- local pool = threads.Threads(
- nthread,
- function(threadid)
- end
- )
- local jobdone = 56530
- for i=jobdone,njob do
- pool:addjob(
- function()
- require "image"
- gen = require("DungeonGenerator")
- gen.DIMENSION=64
- tensor = torch.Tensor(1, gen.DIMENSION, gen.DIMENSION)
- m = gen.generate(i)
- index = 1
- for y=0,gen.DIMENSION-1 do
- for x=0,gen.DIMENSION-1 do
- tensor:storage()[index] = m.tiles[y][x]
- index = index+1
- end
- end
- image.save(("out/%06d.png"):format(i), tensor)
- return __threadid
- end,
- function(id)
- jobdone = jobdone + 1
- print(("%d pictures generated"):format(jobdone))
- end )
- end
- pool:synchronize()
- pool:terminate()
|