Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polygonle bot #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ <h3 class="mini-header">Choose Your Bot</h3>
<option value="Quordle" class = "Quordle">Quordle</option>
<option value="Octordle" class = "Octordle">Octordle</option>
<option value="Spotle" class = "Spotle">Spotle</option>
<option value="Polygonle" class = "Polygonle">Polygonle</option>
</select>
</p>
<p class="extra-settings"></p>
Expand Down
1 change: 1 addition & 0 deletions js/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const QUORDLE = 'Quordle';
const OCTORDLE = 'Octordle';
const WARMLE = 'Warmle';
const SPOTLE = 'Spotle';
const POLYGONLE = 'Polygonle';

spotle = false;

Expand Down
58 changes: 57 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,14 @@ function separateListByLikelihood(list) {

function getPotentialGuessesAndAnswers() {
let all_possible_answers = bot.getAllPossibleAnswersFrom(words.slice());
if (bot.isFor(POLYGONLE)) {
all_possible_answers = polygonleFilter(all_possible_answers)
}
let separated_lists = separateListByLikelihood(all_possible_answers);
let answer_list = separated_lists.likely;
let unlikely_answers = separated_lists.unlikely;
let unique_answers= uniqueWordsFrom(answer_list);

if (dontNeedToCheck(answer_list, unique_answers)) {
return {
guesses: unique_answers,
Expand Down Expand Up @@ -198,6 +201,9 @@ function initialGuesses(answer_list, sorted_answer_list, unique_answers, all_pos
sorted_guess_list = sorted_answer_list;
} else if (isDifficulty(HARD)){
sorted_guess_list = uniqueWordsFrom(all_possible_words.slice());
if (bot.isFor(POLYGONLE)) {
sorted_guess_list = polygonleFilter(sorted_guess_list)
}
// sorted_guess_list = unique_answers.slice();
} else if (bot.isFor(ANTI)) {
sorted_guess_list = filterList(sorted_guess_list, 0, true);
Expand All @@ -209,13 +215,59 @@ function initialGuesses(answer_list, sorted_answer_list, unique_answers, all_pos
sorted_guess_list = combineLists(sorted_answer_list, sorted_guess_list);
}


sorted_guess_list = reduceListSize(sorted_guess_list, sorted_answer_list, bot.getAnswerListLength(answer_list));
// new_lists = reduceListSize(sorted_guess_list, sorted_answer_list, bot.getAnswerListLength(answer_list));
// sorted_guess_list = new_lists.guesses;

return sorted_guess_list;
}

function polygonleFilter(sorted_guess_list) {
let new_list = [];
let pattern = [];
let pattern_matches = [];
$('.polygonle-tile').each(function(i, el) {
pattern[i] = el.classList[1];
if (pattern_matches[el.classList[1]] !== undefined) {
pattern_matches[el.classList[1]].push(i);
} else {
pattern_matches[el.classList[1]] = [i];
}
})
for (let i = 0; i < sorted_guess_list.length; i++) {
let this_word = sorted_guess_list[i];
let matched = true;
for (let j = 0; j < this_word.length; j++ ) {
pattern_key = pattern[j];
pattern_val = pattern_matches[pattern_key];
for (let k = 0; k < pattern_val.length; k++) {
if (this_word[j] != this_word[pattern_val[k]]) {
matched = false;
break;
}
}
if (!matched) {
break;
} else {
let current_char = this_word[j];
for (let k = 0; k < this_word.length; k++) {
if (!pattern_val.includes(k) && j != k) {
if (current_char == this_word[k]) {
matched = false;
break;
}
}
}
}
}
if (matched) {
new_list.push(this_word);
}
}
return new_list;
}

function twoAnswersLeft(answers) {
if (bot.getCount() == 1) {
return answers.length <= 2;
Expand Down Expand Up @@ -824,6 +876,10 @@ function getFirstGuesses() {
function getTempList(guesses, answers) {
let letters = bot.getBestLetters(uniqueWordsFrom(answers.slice()));
guesses = sortList(guesses.slice(), letters);

if (isDifficulty(HARD) && bot.isFor(POLYGONLE)) {
guesses = polygonleFilter(guesses);
}

guesses = bot.reducesListBest(answers.slice(), guesses.slice(0, 100));
guesses = guesses.map(a => Object.assign ({}, {word: a.word, average: a.adjusted, wrong: NOT_YET_TESTED}));
Expand Down
63 changes: 63 additions & 0 deletions js/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,43 @@ $(document).ready(function() {
$(this).children().addClass("visible");
}
});

$(document).on('click', '.polygonle-tile', function() {
let changeTable = [
["A", "B"],
["B", "C"],
["C", "D"],
["D", "E"],
["E", "F"],
["F", "G"],
["G", "A"]
];
let tiles = [
["A", '<div aria-label="yellow bottom-right triangle" tabindex="0" role="listitem" class="w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center mx-0.5 text-5xl text-center font-bold font-mono rounded dark:brightness-150"><svg width="2.25rem" height="2.25rem" viewBox="0 0 59.8 59.8" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#FEC04F" stroke-width="0.25mm" fill="#FEC04F" style="stroke: rgb(254, 192, 79); stroke-width: 0.25mm; fill: rgb(254, 192, 79);"><path d="M 59.8 59.8 L 0 59.8 L 59.8 0 L 59.8 59.8 Z" vector-effect="non-scaling-stroke"></path></g><text x="50%" y="50%" text-anchor="middle" alignment-baseline="central" dominant-baseline="central" font-size="9rem" fill-opacity="0">◢</text></svg></div>'],
["B", '<div aria-label="magenta bottom-left triangle" tabindex="0" role="listitem" class="w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center mx-0.5 text-5xl text-center font-bold font-mono rounded dark:brightness-200"><svg width="2.25rem" height="2.25rem" viewBox="0 0 59.8 59.8" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#3F1F56" stroke-width="0.25mm" fill="#3F1F56" style="stroke: rgb(63, 31, 86); stroke-width: 0.25mm; fill: rgb(63, 31, 86);"><path d="M 0 59.8 L 0 0 L 59.8 59.8 L 0 59.8 Z" vector-effect="non-scaling-stroke"></path></g><text x="50%" y="50%" text-anchor="middle" alignment-baseline="central" dominant-baseline="central" font-size="9rem" fill-opacity="0">◣</text></svg></div>'],
["C", '<div aria-label="cyan diamond" tabindex="0" role="listitem" class="w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center mx-0.5 text-5xl text-center font-bold font-mono rounded dark:brightness-150"><svg width="2.25rem" height="2.25rem" viewBox="0 0 100.7 100.7" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#2DA4A8" stroke-width="0.25mm" fill="#2DA4A8" style="stroke: rgb(45, 164, 168); stroke-width: 0.25mm; fill: rgb(45, 164, 168);"><path d="M 100.7 50.4 L 50.4 100.7 L 0 50.4 L 50.4 0 L 100.7 50.4 Z" vector-effect="non-scaling-stroke"></path></g><text x="50%" y="50%" text-anchor="middle" alignment-baseline="central" dominant-baseline="central" font-size="9rem" fill-opacity="0">◆</text></svg></div>'],
["D", '<div aria-label="red upper-left triangle" tabindex="0" role="listitem" class="w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center mx-0.5 text-5xl text-center font-bold font-mono rounded dark:brightness-150"><svg width="2.25rem" height="2.25rem" viewBox="0 0 59.8 59.8" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#CF2B52" stroke-width="0.25mm" fill="#CF2B52" style="stroke: rgb(207, 43, 82); stroke-width: 0.25mm; fill: rgb(207, 43, 82);"><path d="M 0 0 L 59.8 0 L 0 59.8 L 0 0 Z" vector-effect="non-scaling-stroke"></path></g><text x="50%" y="50%" text-anchor="middle" alignment-baseline="central" dominant-baseline="central" font-size="9rem" fill-opacity="0">◤</text></svg></div>'],
["E", '<div aria-label="blue upper-right triangle" tabindex="0" role="listitem" class="w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center mx-0.5 text-5xl text-center font-bold font-mono rounded dark:brightness-150"><svg width="2.25rem" height="2.25rem" viewBox="0 0 59.8 59.8" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#296094" stroke-width="0.25mm" fill="#296094" style="stroke: rgb(41, 96, 148); stroke-width: 0.25mm; fill: rgb(41, 96, 148);"><path d="M 59.8 0 L 59.8 59.8 L 0 0 L 59.8 0 Z" vector-effect="non-scaling-stroke"></path></g><text x="50%" y="50%" text-anchor="middle" alignment-baseline="central" dominant-baseline="central" font-size="9rem" fill-opacity="0">◥</text></svg></div>'],
["F", '<div aria-label="magenta diamond" tabindex="0" role="listitem" class="w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center mx-0.5 text-5xl text-center font-bold font-mono rounded dark:brightness-200"><svg width="2.25rem" height="2.25rem" viewBox="0 0 100.7 100.7" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#3F1F56" stroke-width="0.25mm" fill="#3F1F56" style="stroke: rgb(63, 31, 86); stroke-width: 0.25mm; fill: rgb(63, 31, 86);"><path d="M 100.7 50.4 L 50.4 100.7 L 0 50.4 L 50.4 0 L 100.7 50.4 Z" vector-effect="non-scaling-stroke"></path></g><text x="50%" y="50%" text-anchor="middle" alignment-baseline="central" dominant-baseline="central" font-size="9rem" fill-opacity="0">◆</text></svg></div>'],
["G", '<div aria-label="cyan square" tabindex="0" role="listitem" class="w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center mx-0.5 text-5xl text-center font-bold font-mono rounded dark:brightness-150"><svg width="2.25rem" height="2.25rem" viewBox="0 0 60.8 60.8" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#2DA4A8" stroke-width="0.25mm" fill="#2DA4A8" style="stroke: rgb(45, 164, 168); stroke-width: 0.25mm; fill: rgb(45, 164, 168);"><path d="M 60.8 60.8 L 0 60.8 L 0 0 L 60.8 0 L 60.8 60.8 Z" vector-effect="non-scaling-stroke"></path></g><text x="50%" y="50%" text-anchor="middle" alignment-baseline="central" dominant-baseline="central" font-size="9rem" fill-opacity="0">◼</text></svg></div>'],
];
let next = "A";
let current = this.classList[1];
for (let i of changeTable) {
if (i[0] == current) {
next = i[1];
break;
}
}
this.classList.replace(current, next);
for (let i of tiles) {
if (i[0] == next) {
$(this).html(i[1]);
break;
}
}
});

});

function createPage() {
Expand All @@ -79,6 +116,7 @@ function createPage() {
function resetPage() {
spotle = false;

clearPolygonle();
clearGrids();
clearHTML(document.getElementById('next-previous-buttons'));
drawPage();
Expand Down Expand Up @@ -140,6 +178,31 @@ function drawPage() {
createAnswerSuggestions(container);

updateSettings();

if (bot.isFor(POLYGONLE)) {
createPolygonleInput();
}
}

function createPolygonleInput() {
$(".polygonle-grid").remove();
let ele = createElement('div', '', 'polygonle-grid');
let grid = $(ele).insertAfter("#word-entered");
for (let i = 0; i < word_length; i++) {
ele = createElement('button', '<div aria-label="yellow bottom-right triangle" tabindex="0" role="listitem" class="w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center mx-0.5 text-5xl text-center font-bold font-mono rounded dark:brightness-150"><svg width="2.25rem" height="2.25rem" viewBox="0 0 59.8 59.8" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#FEC04F" stroke-width="0.25mm" fill="#FEC04F" style="stroke: rgb(254, 192, 79); stroke-width: 0.25mm; fill: rgb(254, 192, 79);"><path d="M 59.8 59.8 L 0 59.8 L 59.8 0 L 59.8 59.8 Z" vector-effect="non-scaling-stroke"></path></g><text x="50%" y="50%" text-anchor="middle" alignment-baseline="central" dominant-baseline="central" font-size="9rem" fill-opacity="0">◢</text></svg></div>', 'polygonle-tile A');
$(grid).append(ele);
}
$(".polygonle-filter").remove();
let filter = createElement('button', 'set polygonle options', 'polygonle-filter');
filter.addEventListener('click', function() {
update();
});
$(filter).insertAfter(".polygonle-grid");
}

function clearPolygonle() {
$(".polygonle-grid").remove();
$(".polygonle-filter").remove();
}

function updateSettings() {
Expand Down
33 changes: 33 additions & 0 deletions wordl.css
Original file line number Diff line number Diff line change
Expand Up @@ -918,4 +918,37 @@ input:checked + .slider:before {
.extra-settings {
margin: 0;
padding: 0;
}


/* Polygonle */
.polygonle-grid{
display: flex;
justify-content: center;
align-items: center;
width: min(630px, 100%);
max-width: 100%;
gap: 2px;
margin-bottom: 15px;
}
.polygonle-tile {
position: relative;
flex: 1;
font-size: 1.5rem;
font-weight: bold;
border-radius: 0;
border: none;
height: 100%;
padding: 15px 0px;
aspect-ratio: 1;
max-width: 3.5rem;

padding: 0;
background-color: rgb(58, 58, 60);
}
.polygonle-filter {
margin-bottom: 15px;
text-decoration: underline;
font-size: .95rem;
position: relative;
}