• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scrabble cheater  RSS feed

Eirik Bernhart
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! I'm fairly new to java programming, and I thought, having projects was a good idea! We had a schoolproject recently, which gave me this idea. So a inputreader class is already in check! It reads strings from a txt.file.

I'm afraid this needs some patience to look through...

Now for my program...

Ever heard about Scrabble?

There is a similar program here: http://www.wordfeudcheat.com/

I want the user to input whatever characters he/she has.
Then I want my program to split up that word into characters: for eg. user enters: flog. Program reads it as: f, l, o, g.
Then shuffle each character, until it matches a word in a dictionary, in a txt.file.
For eg: golf.

Now: Firstly I got a program that did this... But it would try to match with an extremely inefficcient way: the first character randomized, then the latter char + second char randomized.
Would be much better if it could randomize all charaters (in previous example's case) at once an make a new string to check for...
Lets say user inputs 10 chars. The the program would be 90+% inefficient, if you understand what I mean. I will post sourcecode!

Then I tried a different approach: What it does, is that it takes the input in a variable, and converts it to an array of characters.
Then it adds the characters to a list, because I want to shuffle each character, then add them.... So arralist might look like: [f, l, o, g]

...then I use stringbuilder to append each by a for each loop: So if I enter by input: flog, I might get: folg. Yeah!
But then I try to iterate that operation, and then get something like: folg, folggolf, folggolfglof, and so on, which means it has to guess the word right, the first time, which is extremely improbable.

Here is the code:

Code for first program attempt:

Code for second program attempt:

Knute Snortum
Posts: 4087
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've written a Scrabble cheater program, and my experience is that you need a permuter (to shuffle the letters) and a sublister (because not all the letters may be used). Collections.shuffle() looks like it might work for the permuter if you use a good randomizer but you still need a sublister. I can get you an algorithm to build one if you need.

Also (slightly OT) I have three dictionary files, one for OSPD, one for TWL, and one for SOWPODS.

Small nitpick: don't write


It's better to use the interface as the type than the implementation.
Campbell Ritchie
Posts: 55785
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!