Algorithms and such are nice, but they serve the same purpose as just messing around with the database. Again, as long as you can make the battles fun, anything works. So say you want your characters around level 10 for the second level with 600-800 hp each, doing maybe 50 damage per hit. Set up as many enemies as you want, and make it so that 2-3 hits will kill them, or fewer with skills. Test the battle, and if it's too easy (Characters losing something like 10 hp), bump up enemy attack. If it's too hard (Characters losing 200-300, remember, they have to go through numerous fights without an inn, unless that's how your game works), then lower attack, etc. As far as I'm concerned, the real science behind combat is fairly nonexistent unless you're willing to spend a long time on it.