You can just use the last x bits of hashes for the last y blocks to generate a random number.
The seed would have to be picked as the number is drawn if the system is public.
This is actually a popular scheme used by a lot of 'provably fair' gambling sites/smart contracts.