Skip to content

Commit

Permalink
Fix scoring for repeated letters
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorg16 committed Aug 4, 2022
1 parent d4d6aab commit caec7f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ BOOL Engine::makeGuess(char* word)
{
return FALSE;
}

printf("Guess: %s, selected: %s\n", word, selectedWord);

BOOL letterScore[WORD_LENGTH] = {FALSE};

Expand Down Expand Up @@ -127,12 +125,13 @@ BOOL Engine::makeGuess(char* word)
// Wrong position but correct guess
for (i = 0; i < WORD_LENGTH; i++)
{
char* foundLoc = strchr(selectedWord, word[i]);

if (foundLoc && letterScore[foundLoc - selectedWord] == FALSE)
for (int j = 0; j < WORD_LENGTH; j++)
{
scores[numGuesses][i] = WrongPos;
letterScore[foundLoc - selectedWord] = TRUE;
if (word[i] == selectedWord[j] && !letterScore[j] && scores[numGuesses][i] == NoMatch)
{
scores[numGuesses][i] = WrongPos;
letterScore[j] = TRUE;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion macwords.r

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void drawAboutWindow(WindowPtr window)

DrawString(writeString);

c2pstrcpy_cust(writeString, " v1.0.0");
c2pstrcpy_cust(writeString, " v1.0.1");

DrawString(writeString);

Expand Down

0 comments on commit caec7f1

Please sign in to comment.