2.0.0 • Published 4 years ago

bingo-card-generator v2.0.0

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

Welcome to bingo-card-generator

Version License: ISC

Simple generator for 90-ball bingo cards, in strips of 6 tickets.

Based upon an algorithm description by Mark Henderson from: http://www.fractalforums.com/non-fractal-related-chit-chat/90-number-bingo-ticket-algorithm/

Install

npm install

Exports a number of TypeScript types, most of which are used internally, and are just type-names for number arrays.

  • TCell = number|undefined
  • TRow = TCell9
  • TColumn = TCell3
  • TTicket = TRow3
  • TStrip = TTicket6

Ticket gaps are represented by undefined; ticket numbers are regular numbers.

Ticket.generateStrip() is the main way to generate a strip of 6 tickets. As the tickets are generated iteratively, there is a chance the algorithm may get stuck in an impossible combination. Therefore there are TTLs employed to abort infinite loops. Default values are:

  • generationCycleTtl: number = 100000,
  • reattemptTtl: number = 20,
  • distributionCycleTtl: number = 100000

I've found using these combinations strip generation is almost guaranteed to succeed. However, it is still possible for it to not, so be aware that you may need to catch exceptions.

Author

👤 Pete Morris

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator