|
Post by bluatigro on May 18, 2018 8:31:41 GMT
this is the first step in creating a array of word games the goal of this is to try eventualy create a scrabble AI i wil need help because some code i need for this i do not know how to write the algoritm i fount a file whit al the scabble words in engish i cant attach the the scrabble file because it is 7Mb so i added the results first game : 5char it is a kind of mastermind rules : you gues a word of 5 char's the code shows the good one on good place and the good ones on wrong place and has to detect wrong words first code find al 5char words and put them in a file and count al lenght's of words dim q( 15 ) open "zinga\zingarelli2005.txt" for input as #in open "zinga\english-5.txt" for output as #uit while not( eof( #in ) ) line input #in , woord$ if len( woord$ ) = 5 then print #uit , woord$ end if l = len( woord$ ) q( l ) = q( l ) + 1 wend close #uit close #in open "english-charcount.txt" for output as #uit for i = 2 to 15 print #uit , i ; " " ; q( i ) print i , q( i ) next i close #uit
|
|
|
Post by bluatigro on May 18, 2018 9:19:12 GMT
update : first try at 5 char
! : char good and on place ? : char good but not on place . : wrong char
the code shows the answer but that is for testing
'' bluatigro 18 may 2018 '' word game 1 : 5 char dim w$( 7500 ) open "zinga\english-5.txt" for input as #in word.count = 0 while not( eof( #in ) ) line input #in , q$ w$( word.count ) = q$ word.count = word.count + 1 wend close #in [game] dice = int( rnd(0) * ( word.count + 1 ) ) game.count = 0 togues$ = w$( dice ) [try] print togues$ print left$( togues$ , 1 ) + "...." input "gues = " ; in$ if len( in$ ) <> 5 then print "wrong lenght of gues !!" goto [try] end if good = 0 for i = 0 to word.count if in$ = w$( i ) then good = 1 next i if good = 0 then print "i do not know that word !!" goto [try] end if dim fount( 5 ) for i = 1 to 5 if mid$( in$ , i , 1 ) = mid$( togues$ , i , 1 ) then fount( i ) = 1 end if next i for i = 1 to 5 for j = 1 to 5 if i <> j then if fount( i ) = 0 then if mid$(togues$,i,1)=mid$(in$,j,1)then fount( i ) = 2 end if end if end if next j next i for i = 1 to 5 select case fount( i ) case 1 print "!" ; case 2 print "?" ; case else print "." end select next i game.count = game.count + 1 if in$ <> togues$ and game.count < 5 then goto [try] print "GAME OVER" if game.count < 5 then print "you guesed the word !!" else print "you lose !!" end if input "play again ? [ y / n ] " ; in$ if in$ = "y" then goto [game]
|
|
|
Post by bluatigro on May 18, 2018 11:05:43 GMT
update : i deactevated rnd word
error : ? is somtimes to mutch or on wrong place
'' bluatigro 18 may 2018 '' word game 1 : 5 char dim w$( 7500 ) open "zinga\english-5.txt" for input as #in word.count = 0 while not( eof( #in ) ) line input #in , q$ w$( word.count ) = q$ word.count = word.count + 1 wend close #in [game] dice = int( rnd(0) * ( word.count + 1 ) ) game.count = 0 togues$ = w$( 5 ) ''w$( dice ) [try] print left$( togues$ , 1 ) + "...." , togues$ , game.count input "gues = " ; in$ if len( in$ ) <> 5 then print "wrong lenght of gues !!" goto [try] end if good = 0 in$ = upper$( in$ ) for i = 0 to word.count if in$ = w$( i ) then good = 1 next i if good = 0 then print "i do not know that word !!" '' goto [try] end if dim fount( 5 ) for i = 1 to 5 if mid$( in$ , i , 1 ) = mid$( togues$ , i , 1 ) then fount( i ) = 1 end if next i for i = 1 to 5 for j = 1 to 5 if i <> j then if fount( i ) = 0 and fount( j ) = 0 then if mid$(togues$,i,1)=mid$(in$,j,1)then fount( i ) = 2 end if end if end if next j next i for i = 1 to 5 select case fount( i ) case 1 print "!" ; case 2 print "?" ; case else print "." ; end select next i print game.count = game.count + 1 if in$ <> togues$ and game.count < 5 then goto [try] print "GAME OVER" if game.count < 5 then print "you guesed the word !!" else print "you lose !!" end if input "play again ? [ y / n ] " ; in$ if in$ = "y" then goto [game]
|
|
|
Post by B+ on May 19, 2018 14:11:12 GMT
Source (11/30/2016 link from old JB forum): TWL06 Scrabble Word List: ttps://www.wordgamedictionary.com/twl06/download/twl06.txt 5 letter English words: 'extract 5 letter words from word list
open "word list.txt" for input as #1 open "5 letter English words.txt" for output as #2 while eof(#1) = 0 input #1, fline$ fline$ = upper$(trim$(fline$)) if len(fline$) =5 then print #2, fline$ : cnt = cnt + 1 wend close #1 close #2 print "Number of 5 letter words: ";cnt
output 5 letter English words.txt 5 letter English words.txt (61.09 KB) Compare my list to bluatigro's I have to say, I recognize a few English words on the right list (mine) over the left list I am getting from this forum and thread. From ahhed : www.thefreedictionary.com/aahed Oh! it's the past tense of ahh! To zymes : www.yourdictionary.com/zyme Oh! it's short form of enzymes! Now here's the game, how many 5 letter English words do you recognize? ;-)) Heck, now I am in for a penny! with this little game.
|
|
|
Post by B+ on May 19, 2018 16:17:58 GMT
Hey finally got a word! 'Try word game.txt for JB 2.0 B+ 2018-05-19 ' copied and modified the heck out of bluatigro's start 2018-05-19 '' bluatigro 18 may 2018 '' word game 1 : 5 char
guessLimit = 5 dim w$( 8938 ) 'my word list we will be ignoring w$(0) open "5 letter English words.txt" for input as #inword while not( eof( #inword ) ) input #inword , q$ wCnt = wCnt + 1 '<<< increase count before adding to array so count = number of words loaded w$( wCnt ) = q$ wend close #inword
'test load 'print w$(8938) ' OK zymes it is!
'for debug test word BASIC and then compare to BASIS
[gameSetup] cls rw$ = w$(int( rnd(0) * ( wCnt ) ) + 1) 'random word base 1 array 'rw$ = "BASIC" 'rw$ = "BASIS"
'game.count = 0 guess$ = "" guesses = 0 'togues$ = w$( 5 ) ''w$( dice )
progress$ = left$( rw$ , 1 ) + "****" while guesses < guessLimit and guess$ <> rw$
'progress report 'print left$( togues$ , 1 ) + "...." , togues$ , game.count print "Result: ";progress$;" from guess: ";guess$;" for guess number: "; guesses print "You have: ";guessLimit - guesses;" guesses left." print
[getGuess] input "Enter your word guess > " ; guess$ if len( guess$ ) <> 5 then print "Your word guess is wrong length, need 5 letters." goto [getGuess] end if guess$ = upper$( guess$ )
'what ??? good = 0 for i = 0 to wCnt if guess$ = w$( i ) then good = 1 : exit for ' <<< EDIT: we can exit loop now, word is good! next i if good = 0 then print "Is ";guess$;" even a word???" ''' goto [try] end if
' don't know what fount means how about foundOut or fo for short dim fo( 5 ) for i = 1 to 5 if mid$( guess$ , i , 1 ) = mid$( rw$ , i , 1 ) then fo( i ) = 1 'matching letters at i end if next i
'check unmatched letters, any from guess that fit into random word? for i = 1 to 5 for j = 1 to 5 if i <> j then if fo( i ) = 0 and fo( j ) = 0 then if mid$(rw$, i, 1) = mid$(guess$, j, 1)then fo( i ) = 2 end if end if end if next j next i ' I don't think this is going to work what if guess has a letter that is used twice in random word ' That is why I am taking trouble to do all this setup and code check BASIS and guess is BSASI ' hardest part seems to work. :)
'progress progress$ = "" for i = 1 to 5 select case fo( i ) case 1 progress$ = progress$ + mid$(rw$, i, 1) 'oh heck print the letter! case 2 progress$ = progress$ + "?" 'a clue one of the other letters is right but which one? case else progress$ = progress$ + "*" 'none of letters of guess fit here! end select next i print guesses = guesses + 1 '>> let's count guesses after we've just approved one wend
'game.count = game.count + 1 'if guess$ <> rw$ and guesses < 5 then goto [game] print " GAME OVER " if rw$ = guess$ then print "You got the word!" else print "The word was ";rw$;"." print input "Play again ? [ y / n ] " ; continue$ if continue$ = "y" then goto [gameSetup] end
|
|
|
Post by bluatigro on Jul 3, 2018 9:41:13 GMT
update : i counted the nuber of len = x words in the file b+ provided
'' count len word fequence in english schrabble dim l( 20 ) open "english-scrabble.txt" for input as #in while eof( #in ) = 0 input #in , fline$ x = len( trim$( fline$ ) ) l( x ) = l( x ) + 1 wend close #in for i = 0 to 18 print "Number of " ; i ; " letter words: " ; l( i ) next i
result :
|
|
|
Post by bluatigro on Jul 3, 2018 9:46:41 GMT
total : 178691
|
|
|
Post by bluatigro on May 21, 2019 9:14:49 GMT
code shoot cross given word whit other words out of file but nothing happens . why ?
open "Games\english-scrabble.txt" for input as #in while not( eof( #in ) ) line input #in , q$ al$ = al$ + " " + q$ count = count + 1 wend close #in input "type a word : " ; in$ dim char$( len( in$ ) , 30 ) for i = 1 to len( in$ ) l$ = mid$( in$ , i , 1 ) f$ = "" tel = 0 for w = 1 to count - 1 p$ = word$( al$ , w ) if instr( p$ , l$ ) then f$ = f$ + " " + p$ tel = tel + 1 end if next w dice = int( rnd(0) * ( tel - 1 ) ) + 1 t$ = word$( f$ , dice ) h = instr( t$ , l$ ) for w = 1 to len( t$ ) char$( i , w - h ) = mid$( t$ , w , 1 ) next w next i for y = 0 to 30 for x = 0 to len( in$ ) if char$( x , y ) <> "" then print char$( x , y ) ; else print "." ; end if next x print next y
|
|