Giter Club home page Giter Club logo

crossword_puzzle's Introduction

Crossword Puzzle Generator

A Python script to generate crossword puzzles

Why?

I'am quite the fan of the little crossword books in the checkout isle. Looking at one, naturally the question occured to me on how these things are generated. After some googling you'll find that they are commonly generated by computers and there isn't an exact way to generate them. One of the reasons for that is that crossword puzzles can look quite different; compare the back of a cereal box to a newspaper for example. Density of words is a key difference you will generally find accross examples.

Taking then my thoughts and questions, I decided to make a program that generates the puzzles that I find confortably dense.

What?

Words can only go down or accross, upward and reverse are confusing. Finding possible matches in of words is simple in it of itself. To get optimal density I went with a point system. Possible places to place a new word are assigned points given 4 criteria.

  • Points are given if it intersects a word on a vowel.
  • Points are given if it the intersection is closer to the middle of the word.
  • Points are removed if the start location is crowded by other words.
  • Points are removed if the end location is crowded by other words. Then it simply becomes a matter of picking the placement with the most points.

However, since the best placement for a word is constrained by the words allready placed on the grid this might not be the optimal solution. As is with any search problem we might be stuck in a local minima. To accomodate this we shuffle the word list and generate multiple grids. The grid with the highest number of total points is the chosen one.

Run

Expects 4 Arguments:

  1. Number of crossword grids to generate
  2. Number of words in each puzzle
  3. Max size of grid
  4. Number of how many grids to test before picking one Example:
python ./GridWorld.py 2 20 40 3

Credit

Much credit to adambom for his dictionary respoitory found here. And of course to Project Gutenberg for putting up the webster dictionary in the first place.

Licence

Dictionary and Project Gutenburg have their licences. My code is under MIT.

crossword_puzzle's People

Contributors

dubliyu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.