diff --git a/Makefile b/Makefile
new file mode 100755
index 0000000..332549c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,31 @@
+JAVA = /usr/bin/java
+# JAVAFLAGS = -version # -classpath $(LIBS)
+JAVAC = /usr/bin/javac
+JFLAGS = -g # -classpath $(LIBS)
+
+SRCS = uk/org/mafoo/wordsearch/GridFactory.java \
+ uk/org/mafoo/wordsearch/Bounds.java \
+ uk/org/mafoo/wordsearch/CouldNotPlaceWordException.java \
+ uk/org/mafoo/wordsearch/Direction.java \
+ uk/org/mafoo/wordsearch/DistributedRandomNumberGenerator.java
+
+OBJS = ${SRCS:.java=.class}
+
+.SUFFIXES: .java .class
+
+all: build wordsearch.jar
+
+run: all
+ $(JAVA) uk.org.mafoo.wordsearch.GridFactory 10 10
+
+.java.class:
+ $(JAVAC) $(JFLAGS) $<
+
+build: $(OBJS)
+
+clean:
+ rm -f $(OBJS) wordsearch.jar wordsearch.war
+
+wordsearch.jar: build
+ jar cf $@ $(OBJS)
+ cp wordsearch.jar war/WEB-INF/lib
diff --git a/war/about.html b/war/about.html
new file mode 100755
index 0000000..a49f653
--- /dev/null
+++ b/war/about.html
@@ -0,0 +1,22 @@
+
+
+ About
+
+
+
+ Wordsearch Builder: About
+ Wordsearch Builder takes a list of words and places them on a grid in any direction allowing the to cross-over where possible then fills in the remaining empty spaces with semi-random letters.
+ Basic algorithm
+
+ - Foreach word
+
+ - Pick a direction at random
+ - Compute possible start points based on word length, direction and grid size
+ - Begin placing word. If an occupied cell is encountered which contains a different character than would go in for this word, then abort and start this word again.
+
+
+ - When all words are placed, infill the remaining cells with random characters weighted by standard English letter frequencies
+
+ The abort-and-retry word placement to try 500 times before giving up.
+
+
\ No newline at end of file
diff --git a/war/build.jsp b/war/build.jsp
index f07358e..299e845 100755
--- a/war/build.jsp
+++ b/war/build.jsp
@@ -7,10 +7,28 @@
border-collapse: collapse;
padding: 2px 4px;
}
+
+ #grid {
+ font-family: monospace; font-size: 16;
+ }
+
+ #wrapper {
+ width: 80%;
+ margin: 0 auto;
+ }
+ #wordsearch {
+ float: left;
+ }
+
+ #words {
+ float: right;
+ width: 200px;
+ }
<%@ page import="uk.org.mafoo.wordsearch.*" %>
<%@ page import="java.util.*" %>
+<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page errorPage="error.jsp" %>
<%
@@ -24,31 +42,52 @@
for ( String line : request.getParameter("words").split("\r\n")) {
words.add(line.trim());
}
-
+ Collections.sort(words);
+
+
char[][] grid = GridFactory.makeGrid(words, height, width);
+
+ String csv = "";
%>
Wordsearch builder
-Words
-
-
-
- <% for (String word : words) { %>
- - <%= word.trim() %>
- <% } %>
-
+
Download CSV
+
-Grid
-
-<% for(char[] row : grid) { %>
-
- <% for(char c : row) { %>
- <%= c %> |
- <% } %>
-
-<% } %>
-
+
+
+
Grid
+
+ <% for(char[] row : grid) { %>
+
+ <% for(char c : row) {
+ csv += "" + c + ',';
+ %>
+ <%= c %> |
+ <% } %>
+
+ <%
+ csv += "\\n";
+ }
+ %>
+
+
+
+
Words
+
+ <% for (String word : words) { %>
+ - <%= word.trim() %>
+ <% } %>
+
+
+
+
+