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

add QuizBot #262

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

add QuizBot #262

wants to merge 5 commits into from

Conversation

JeliHacker
Copy link
Contributor

@JeliHacker JeliHacker commented Feb 20, 2024

A bot solution for issue #10. It's not true artificial intelligence, but this lets users play against the computer.
Like @geoffrey-wu said,

Or, the AI can just buzz within a certain range (range would change based on difficulty)

The bot difficulty is in a range from 0-100, just like reading speed. You can think of the difficulty as the percentage of the question that is unread when the bot buzzes in. So if difficulty is set to 90, the bot will buzz in when 90% of the question is unread. At 100% the bot buzzes in instantly and at 0 it doesn't buzz in at all.

I made this a feature for multiplayer rooms instead of single player. I just find myself using a multiplayer room by myself instead of single player mode. Could be personal preference though

users can add and remove a bot to a multiplayer room, the bot answers questions
@JeliHacker JeliHacker marked this pull request as ready for review May 7, 2024 03:10
@JeliHacker JeliHacker changed the title WIP: add QuizBot add QuizBot May 16, 2024
Copy link
Contributor

@VillainsRule VillainsRule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few nitpicks from a security standpoint. I love this PR idea, keep it up!

@@ -769,7 +778,7 @@ function upsertPlayerItem(player) {
playerItem.id = `list-group-${userId}`;
playerItem.innerHTML = `
<div class="d-flex justify-content-between">
<span id="username-${userId}">${escapeHTML(username)}</span>
<span id="username-${userId}">${player.userId == 'QuizBotId' ? '<i class="fa-solid fa-robot"></i> ' : ''}${escapeHTML(username)}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't userIDs be spoofed by a user if directly connecting to the WebSocket?

isOnline: true, // You might want to always consider the bot as online
};

upsertPlayerItem(quizBotPlayer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't the server send this player instead of the client?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might've misunderstood how these are added, if so, my bad.

@@ -185,6 +192,15 @@ class TossupRoom {
const type = message.type || '';

switch (type) {
case 'bot-difficulty':
this.settings.botDifficulty = message.value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add invalidations for what this can be, from what I can tell a user could input a string as a value here.

type: 'join',
isNew: true,
userId: 'QuizBotId',
username: '🤖QuizBot🤖',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This username should be blacklisted from account creation or names in public games, as that could lead to impersonation/abuse.

@VillainsRule
Copy link
Contributor

+ how hard would it be to add to singleplayer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants