Skip navigation

Monthly Archives: May 2009

Man, I’ve had to deal with writing so brutal java programs this quarter for my 143 class. The LinkList program which requires you to write your own node class, and LinkLint class, plus three other classes that create a mini word editor was probably the hardest. You had to be able to insert or delete a letter at your cursor using LinkLists. If you don’t know what I’m talking about, a LinkList works by using only one class and the only way to get to a node in the list is to call the same class. LinkLists don’t bother me when you just have to use a class that is already written, but when you have to write your own class to make it work that’s a whole nother story… who ever came up with the concept I bow to, lol.

 

Anyways, I spent all night on another ridiculous program. Basically I had to find all possible words that can be created within a certain phrase/word. Like, how many words can you make out of the word "sink". The solution took me forever to find. After asking my teacher for help I finally came up with one. It’s a recursive solution that explodes extremely fast in memory due to the amount of possible solutions. For brushhair there are 362,880 solutions just for using all the letters (also know as a anagram – if i printed them out the list would be huge), and then when counting smaller words it grows to an even more extremely large number. If you enter a word over 10 letters it takes about 5 minutes to finish gathering all the possible solutions. Out of the millions of possible solutions there are only a couple words that match in the dictionary file that was given to us!  Anyways, here is the solution I came up with the code:

 

/* Joey Sipos
 * Assignmetn 07 Anagram solver
 * May 19, 2009
 */
import java.io.*;
import java.util.*;
public class AnagramSolver {
  //ArrayList of all anagram-phrases
  private List<String> finalAnagramList = new ArrayList<String>();
  List<String> gumbleAnagramList = new ArrayList<String>();
  private String phrase = "";
  Set<String> dictionary = new TreeSet<String>();
 
  public AnagramSolver(String phrase1, String dictName) throws FileNotFoundException {
    //add the dictionary words to the set
    String dictWords = "";
    Scanner input = new Scanner(new File(dictName));
    while (input.hasNext()) {
      dictWords = input.next();
      dictionary.add(dictWords);
    }
   
    //remove white spaces from phrase, cosolidate into one word
    Scanner tokenScanner = new Scanner(phrase1);
    String temp = "";
    while (tokenScanner.hasNext()) {
      temp = temp + tokenScanner.next();
    }
    phrase = temp;
  }
 
  //takes a word and produces all possible anagrams
  //all anagrams that are the orginal length of the phrase are stored in a list
  //The list is procesed for smaller words is the solver method
  public void produceAllAnagrams(char insertChar, String word) {
   
    //store the letters into a char array
    char[] arrayWord = word.toCharArray();
    //turn the char array into a linked list
    LinkedList listWord = new LinkedList();
    for (int i = 0; i < arrayWord.length; i++) {
      listWord.add(arrayWord[i]);
    }
   
    for (int i = 0; i <= listWord.size(); i++) {
      //add the insert char to create the new word
      listWord.add(i,insertChar);
      int j = 0;
      //turns the new Word into a string
      String newWord = "";
      while (j < listWord.size()) {
        newWord += listWord.get(j);
        j++;
      }
     
      //recurse
      if (newWord.length() <  phrase.length()) {
        produceAllAnagrams(phrase.charAt(newWord.length()), newWord);
      }
      //store if it the length of the orginal phrase
      if (newWord.length() == phrase.length()) {
        gumbleAnagramList.add(newWord);
        //System.out.println("test");
      }
      //remove our insertchar 
      listWord.remove(i);
    }
  }
 
  public void printAnagrams() {
    String firstLetter = "" + phrase.charAt(0);
    produceAllAnagrams(phrase.charAt(1), firstLetter);
   
    for(int j=0; j < gumbleAnagramList.size(); j++) {
      String anagram = gumbleAnagramList.get(j);
      for(int k=1; k <= phrase.length(); k++) {
        //if the dictionary has the word and is not already in the final list
        if ((dictionary.contains(anagram.substring(0, k))) &&
             (finalAnagramList.contains(anagram.substring(0, k)) == false)) {
          finalAnagramList.add(anagram.substring(0,k));
        }
      }
    }
    System.out.println();
    for (int i=0; i < finalAnagramList.size(); i++) {
      System.out.println(finalAnagramList.get(i));
    }
  }
}
 
 
 
 
 
 

While working on the F-18 mission as well as my 3D stuff, I’ve learned a thing or two about the process of storytelling. The first thing I’ve learned is it’s not easy! It’s hard to make a good story, and make it appealing to watch – or play. With my 3D stuff we have to create a 3D animatic of a real life story we came up. We had to tell the story like 5 times in front of a group of people and each time try and make it more detailed and appealing to the listener. Then we had to take our story and turn it into a script with detailed descriptions of how we plan to do our shots. Now I’m working of creating the shots. The shots are supposed to be extremely simple (blocked out) with simple geometry. But of coarse I got sidetracked into making visually appealing which is a bad habit of mine. I always get caught up in the details instead of letting it go and keep blocking my scene out. My teacher and I had a discussion about this. He stated how important it is to throw your ideas together really fast then go back and work on the details. Which is a simple concept, but nothing I took very seriously. Now I’m sitting here at midnight rendering and trying to finish my scenes for tomorrow because I spent too much time trying to make stuff more visually appealing. And of course with more detail it takes a lot more time to render! So now I’ve decided to take out the visual stuff for now and just get it blocked out. Hehe. Dam– he was right!

So lessoned learned, the preliminary work that goes into preproduction is actually a very important step. Get your ideas all sorted out, right the script, create a quick rough draft of your project then go back and add your changes and details. When you spend too much time on the details, and you get to the end and realize your story sucks then you have to scrap everything and start over again. Block it out first! 

Update: here is the stroy I threw together that night. Now I am going back and adding the more detailed models and textures.