| 12345678910111213141516171819 |
- from random import randint as rand
- def randbool(r, mxr):
- t = rand(0, mxr)
- return (t <= r)
- def randcell(w, h):
- tw = rand(0, w)
- th = rand(0, h)
- return (th, tw)
- #
- def randcell2(x, y, w, h):
- moves = [(-1, 0), (0, 1), (1, 0), 0, -1]
- t = rand(0, 3)
- dx, dy = moves[t][0], moves[t][1]
- return (x + dx, y + dy)
|