Git Product home page Git Product logo

het-patel99 / crossword-puzzle-as-csp Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 466 KB

A puzzle consisting of a grid of squares and blanks into which words are to be filled vertically and horizontally. In the crossword puzzle, we have a grid with blocked and unblocked cells and a dictionary of words. We want to assign a letter to each unblocked cell so that each vertical or horizontal contiguous segment of unblocked cells forms a word that appears in the dictionary.

License: MIT License

Java 100.00%
ai crossword-puzzle csp arc-consistency forward-checking

crossword-puzzle-as-csp's Introduction

Crossword-Puzzle-as-CSP

CrossWord Board


A puzzle consisting of a grid of squares and blanks into which words are to be filled vertically and horizontally. In the crossword puzzle, we have a grid with blocked and unblocked cells and a dictionary of words. We want to assign a letter to each unblocked cell so that each vertical or horizontal contiguous segment of unblocked cells forms a word that appears in the dictionary. Given a word dictionary consisting of a list of words, we need to fill the blank squares with the alphabets such that every constraint like the word size and the overlapping word constraints are fulfilled. For example in the above image shown, the word dictionary will have a list of words like Cup, chaste, petal, tulip, etc. stored.


Steps to run the code:

  1. Open terminal and go to src by "cd src"
  2. Compile cpcsp.java and Placement.java file by "javac *.java"
  3. Run the command by "java cpcsp " (Ex: "java cpcsp ../data/grid1.txt ../data/wordList1.txt")

Aproach:

The crossword puzzle problem can be described as a Constraint Satisfaction problem as follows:-

Variables: All vertical or horizontal contiguous segments of unblocked cells. Domains: The domain of each variable is the set of words in the dictionary of the same length as the corresponding contiguous segment. Constraints: For each pair of vertical and horizontal contiguous segments of unblocked cells that intersect at an unblocked cell s, we add a constraint between them, constraining the words assigned to them to have the same letter at s.

Flow Chart

crossword-puzzle-as-csp's People

Contributors

het-patel99 avatar

Stargazers

 avatar

Watchers

 avatar  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.