Jump to content

Regular Expressions, comparing strings, need a push =D


nafetski

Recommended Posts

Hello!  I've been learning quite a bit of PHP lately, and am pretty comfortable with the basics.  What I'm looking to do now is take it to the next level by cheating at a video game that I always get beat at by my girl =P

 

It's a word game (lingo), and the basis is you guess 5 letter words.  You always get the first letter of the word, and after each guess it will show you which letters were in the right spot by a red box with the letter, or if the letter is in the word but in the wrong spot by a yellow circle.  What I need, is just help outlining the logic of this project so I can get moving in the right direction - not looking for anybody to code it for me! =)

 

First, here is a word list of every 5 letter word (the most common ones at least)

 

http://www.math.utoronto.ca/jjchew/scrabble/lists/common-5.html 

 

I have a basic understanding of regular expressions, but I guess my only question is what would be the best way to arrange that data?  In arrays?  Keep it as it is?  With whatever data I have (the first letter, exact letter/place matches, etc) I want to compare it with the data in the website I linked above.  Then output the results that match, so I can use those for more "educated" guesses =P  If this is the wrong forum I appologize, all of hte PHP projects I've worked on so far have been either done before or easy to wrap my small designers mind around :P  Excited to delve deeper into php tho, any help is appreciated!

 

-Nafetski

Link to comment
Share on other sites

Actually, any links to really good tutorials on serious string manipulation (that start off at least somewhat easy to understand) I would LOVE.  I've worked with databases, fine with moving variables around, understand how functions work...but as far as comparing/replacing/moving around strings I'm still pretty wet behind the ears.  Any links or tips would be great.

 

Thanks so much!

Link to comment
Share on other sites

I would put all the words into an array. Since you are given the first letter to start, you immediately narrow down your choices.

 

If you want to do this really good, you should make a function to calculate the 'worth' of a guess. If you have M, malls and march would be both be guesses, but march would be a better on, because you are trying more letters. The best way I can think to weight guesses is to make a function that takes in a set of letters, ignores duplicate letters, and adds together something like 30 minus their scrabble value. If you go off of scrabble value. If you have already guessed a letter and not gotten it, set it's value to 0.

 

If you play on AOL, I think you can win cash. After you make your game solving script, you might want to use AutoIT to make an automation script and win some cash. Remember to give it a little bit of a delay, so they don't think you are using a bot.

 

$scrabblevalues = array(16, 4, 6, 8, 24, 4, 5, 5, 13, 2, 2, 7, 6, 13, 15, 4, 2, 13, 10, 15, 7, 3, 4, 2, 4, 2, 4);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.