Nerdle source code
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Nerdle source code
Here is the source code for Nerdle. It's quite rough and I'm a sloppy coder anyway, keep that in mind. But it does work. You need three files, here they are zipped:
https://lloydsplace.com/nerdle/nerdle_a5.zip
I had to post it this way because it's way to many characters for the forum.
https://lloydsplace.com/nerdle/nerdle_a5.zip
I had to post it this way because it's way to many characters for the forum.
Last edited by netmaestro on Sat Sep 24, 2022 8:12 am, edited 1 time in total.
BERESHEIT
Re: Nerdle source code
Thanks for that, doesn't look rough to me.
I had a steak of 60 early on but with the change to the nytimes the best I've got was 40 and the last couple of weeks I've lost two games due to American spelling.
I had a steak of 60 early on but with the change to the nytimes the best I've got was 40 and the last couple of weeks I've lost two games due to American spelling.
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Nerdle source code
The biggest worry is words when you've got 3 or 4 letters in the right place and there's 5 possibilities - and you've only got 3 more lines. Death ensues. For me usually, anyway. Luck is important. I got beat by the same word my wife got on the second row once. Ouch!
BERESHEIT
Re: Nerdle source code
I almost got it in two this morning, 4 in right place and then it dragged on to the 4th guess, yes there's certainly an element of luck. It's a good game with the morning coffee.netmaestro wrote: ↑Thu Sep 22, 2022 5:07 am The biggest worry is words when you've got 3 or 4 letters in the right place and there's 5 possibilities - and you've only got 3 more lines. Death ensues. For me usually, anyway. Luck is important. I got beat by the same word my wife got on the second row once. Ouch!
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Nerdle source code
The Wordle game restricts you to 1 play every 24 hours, which is one reason I made this. With over 3100 words in it you can play it whenever you like for as long as you like.
BERESHEIT
Re: Nerdle source code
3100 words isn't a lot, I would soon learn them and ace the online game. I will have a play in a couple of days, I just stuffed ~800,000 urls into a 814kb data section. Now my exe is bloated at 1,711 kb blooming heck!netmaestro wrote: ↑Thu Sep 22, 2022 5:26 am The Wordle game restricts you to 1 play every 24 hours, which is one reason I made this. With over 3100 words in it you can play it whenever you like for as long as you like.
Re: Nerdle source code
thank you netmaestro
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Nerdle source code
I forgot to mention one important item: The program has threads and it must be compiled with Threadsafe on. I added a CompilerIf block to the code and that should suffice now but if you ran it before and didn't know it needed Threadsafe you could have encountered problems because the code employs a callback for the window and it would clash with the threads.
BERESHEIT
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Nerdle source code
I fixed a couple of bugs I found in the code after what I hope was exhaustive testing. Ha, we'll see about that one. I've updated nerdle.pb so if you have it you should get the latest. It identifies itself as 'Alpha 4' at the top of the code.
BERESHEIT
Re: Nerdle source code
I am not a very good player but it is very nice.
A game would be to develop now a cheat code to find the hidden word as quickly as possible, following the letters previously found, in the right place or wrong place and optionally with a weight for the letters. And thus play against the machine.
A game would be to develop now a cheat code to find the hidden word as quickly as possible, following the letters previously found, in the right place or wrong place and optionally with a weight for the letters. And thus play against the machine.
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Nerdle source code
I've moved to Alpha 5 now. Link in the top post is updated, everything is in one zip file, exe too as it's compiled for x64 and Windows Defender likes it now.
Changes:
1. Reworked the layout to be more inutitive. I was never happy with the return key on the left side.
2. Added some words that should've been in the wordlist but weren't.
3. Cleaned up some sloppy coding.
I have the stats page to do yet, I'm considering doing away with the .ini file and putting everything in a sqlite database.
Any bugs you find in this, please let me know.
Happy nerdling!
Changes:
1. Reworked the layout to be more inutitive. I was never happy with the return key on the left side.
2. Added some words that should've been in the wordlist but weren't.
3. Cleaned up some sloppy coding.
I have the stats page to do yet, I'm considering doing away with the .ini file and putting everything in a sqlite database.
Any bugs you find in this, please let me know.
Happy nerdling!
BERESHEIT
Re: Nerdle source code
I agree with the key swap. I've made a few entries by mistake due ro the enter key being on the wrong side
Re: Nerdle source code
If u don't want cry like a little girl... U can cheat...
M.
Code: Select all
If FileSize("nerdle_wordlist_a5.pbi") < 0
MessageRequester("Attention", "nerdle_wordlist_a5.pbi not found !", #PB_MessageRequester_Info)
End
EndIf
XIncludeFile "nerdle_wordlist_a5.pbi"
; Debug words(1)
; Debug BSearch("CIVET")
Enumeration
#string
#solution
#button
#string_not_in
EndEnumeration
Global Dim Words2.s(ArraySize(words()))
CopyArray(words(),Words2())
Procedure Go()
search$=""
string$=GetGadgetText(#string)
SetGadgetData(#string,Len(string$))
If string$ = "*"
For j=0 To ArraySize(words2())
AddGadgetItem(#solution, -1, words2(j))
Next j
ProcedureReturn 1
EndIf
For i=1 To Len(string$)
ClearGadgetItems(#solution)
search$=Mid(string$, i, 1)
For j=0 To ArraySize(words2())
If FindString(words2(j),search$,1,#PB_String_NoCase)
AddGadgetItem(#solution, -1, words2(j))
EndIf
Next j
ReDim words2(CountGadgetItems(#solution))
For k=0 To CountGadgetItems(#solution)
words2(k)=GetGadgetItemText(#solution,k)
Next k
Next i
EndProcedure
Procedure reset()
ReDim words2(ArraySize(words()))
CopyArray(words(),Words2())
ClearGadgetItems(#solution)
EndProcedure
Procedure Go_Out()
search$=""
string$=GetGadgetText(#string_not_in)
SetGadgetData(#string_not_in,Len(string$))
For i=1 To Len(string$)
ClearGadgetItems(#solution)
search$=Mid(string$, i, 1)
For j=0 To ArraySize(words2())
If FindString(words2(j),search$,1,#PB_String_NoCase)
Else
AddGadgetItem(#solution, -1, words2(j))
EndIf
Next j
ReDim words2(CountGadgetItems(#solution))
For k=0 To CountGadgetItems(#solution)
words2(k)=GetGadgetItemText(#solution,k)
Next k
Next i
EndProcedure
If OpenWindow(0, 0, 0, 300, 600, "Enter characters and, Cheat...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(#string, 10, 10, 200, 30, "")
GadgetToolTip(#string, "Letters inside")
StringGadget(#string_not_in, 10, 50, 200, 30, "")
GadgetToolTip(#string_not_in, "Letters not inside")
EditorGadget(#solution,10,90, 200,540)
ButtonGadget(#button,230,10,60,30,"Reset")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #string
If EventType() = #PB_EventType_Change
If Len(GetGadgetText(#string)) < GetGadgetData(#string)
reset()
go()
Go_Out()
EndIf
go()
EndIf
Case #string_not_in
If EventType() = #PB_EventType_Change
If Len(GetGadgetText(#string_not_in)) < GetGadgetData(#string_not_in)
reset()
go()
Go_Out()
EndIf
Go_Out()
EndIf
Case #button
SetGadgetText(#string, "")
SetGadgetText(#string_not_in,"")
reset()
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
Re: Nerdle source code
To follow up on Mesa Cheat code and as I don't want to cry like a little girl with my poor English.
I made my cheat code too, integrated in nerdle source code. Sorry to spoil this nice code, I put "; Added Cheat" tags in addition to Nerdle_Cheat.pbi.
It is based on a word list that shrinks according to the letters in the right or wrong place or not in the word.
Use F1 to suggest a word that meets the conditions of the previous lines.
With F1, Enter, F1, Enter... the hidden word is usually found in 3 to 6 tries. But sometimes 6 tries are not enough.
nerdle_a5_cheat.zip
I made my cheat code too, integrated in nerdle source code. Sorry to spoil this nice code, I put "; Added Cheat" tags in addition to Nerdle_Cheat.pbi.
It is based on a word list that shrinks according to the letters in the right or wrong place or not in the word.
Use F1 to suggest a word that meets the conditions of the previous lines.
With F1, Enter, F1, Enter... the hidden word is usually found in 3 to 6 tries. But sometimes 6 tries are not enough.
nerdle_a5_cheat.zip