Vocabulary dictionary

Kanji dictionary

Grammar dictionary

Sentence lookup

test
 

Forums - [Project] Crossword generation code (Javascript)

Top > renshuu.org > Developer corner



avatar
マイコー
Level: 281

renshuu's crossword generation code is pretty old, and suffers from a number of weaknesses that will not be fixed without a complete rewrite. A very nice user whipped up some simple code in JS a few years ago, but I never had the time to take it and move it far enough for it to be usable in renshuu. If anyone is interested in working with this code and expanding on it, let me know!


Current system

The current code is written in PHP, but I have no issue calling out to a node script for the heavy lifting, and then bring the json data back into the PHP.

The current system will make a set of a few dozen crosswords at once, grade them, then save the best few from the group.

The main metrics for grading are fairly simple (too simply, really):

1. number of words that was able to get packed into the puzzle.

2. ratio of width/height (so it's as boxy as possible.)

There are two main issues with this approach:

1. With the code I wrote, it heavily favors longer words because there are more places to branch off of them, so longer words are used for frequently than not.

2. There is no memory between puzzle generations. In most situations (whether its in the main crossword section, or in the personal crosswords built for schedules), you're generally working with the same word set. So with #1, there is not a wide enough variety of words across (for example) 5 puzzles made from the same set of words. 20% of the words might appear in all 5 puzzles, while 40% of the words appear in one puzzle or less.

This is not tied to my code specifically, but Japanese is trickier for doing crossword puzzles because of the higher number of characters, and the general tendency towards 2-3 character words.

Here is the JS code that was written: https://jsfiddle.net/Hacktix/1...

This code is just utilizing a single set of words, and is built for a memory-less, single puzzle functionality. In order to bring it up to something that renshuu can use (I also have no problem with the produced code being open-sourced), it'll need a few more things added:

1. The input will be objects similar to the following:

{id : 1234345, word : "ラーメン", historical_weight: 0}

2. It's fine to output the crossword puzzle for testing, but the actual code will need just a object with a few key elements:

width, length (of entire puzzle)

list of words (by id), showing starting x,y point, and direction

There's a lot of secondary information that could be generated by the javascript, but it just as easily could be done on my end from the main data above.


I haven't *fully* thought through all constraints that need to be considered, but if you're interested in working on this, first respond here and let me know!

0
6 months ago
Report Content
avatar
ichikjell
Level: 24

I'd be interested in solving this issue. I'll have a look at the code.

0
6 months ago
Report Content
avatar
マイコー
Level: 281

If you look and are interested, toss me a DM, and we can look into setting up a github instance, as well as more sets of input data for you to work with (with word_id, etc.)

0
6 months ago
Report Content
Getting the posts




Top > renshuu.org > Developer corner


Loading the list
Lv.

Sorry, there was an error on renshuu! If it's OK, please describe what you were doing. This will help us fix the issue.

Characters to show:





Use your mouse or finger to write characters in the box.
■ Katakana ■ Hiragana