mjsalerno / unobot Goto Github PK
View Code? Open in Web Editor NEWA bot that connects to an IRC channel and plays uno.
A bot that connects to an IRC channel and plays uno.
found a bug when someone gives a wrong input the script stops accepting input
[main] INFO org.pircbotx.InputParser - :[email protected] PRIVMSG ##uno :!play yr [listenerPool0-thread1] ERROR org.pircbotx.hooks.managers.ThreadedListenerManager - Exception encountered when executing event MessageEvent(channel=Channel (name=##uno, channelId=5223f51d-fb26-4342-ad63-60e6188a9221, dao=org.pircbotx.UserChannelDao@1990ca, bot=Version{mIRC v7.32 Khaled Mardam-Bey} Connected{tr ue} Server{znc.centravi.org} Port{9001} Password{uno:KXghTgVA}, output=org.pircbotx.Channel$1@70f11d, mode=+ntz, topic=���Uno Game Channel! Use !uno to sta rt the game, if there are any issues PM Hari_Seldon., topicTimestamp=1466671926000, createTimestamp=1466284882, topicSetter=Hari_Seldon, moderated=false, n oExternalMessages=true, inviteOnly=false, secret=false, channelPrivate=false, topicProtection=true, channelLimit=-1, channelKey=null, modeStale=false, mode Latch=null), user=User(bot=Version{mIRC v7.32 Khaled Mardam-Bey} Connected{true} Server{znc.centravi.org} Port{9001} Password{CENSORED}, dao=org.pircbo tx.UserChannelDao@1990ca, userId=f3e4a6e5-5f20-4048-89cf-3ce5a8ee737d, output=org.pircbotx.User$1@e5cd19, nick=Hari_Seldon, realName=Hari_Seldon, login=Har i_Seldo, hostmask=Hari_Seldon.user.OnlineGamesNet, awayMessage=null, ircop=false, server=*.OnlineGamesNet.net, hops=3), message=!uno +e +a) on listener com .mjsalerno.unobot.UnoBot@a6a5dc java.lang.ArrayIndexOutOfBoundsException: 2 at com.mjsalerno.unobot.UnoBot.onMessage(UnoBot.java:718) at org.pircbotx.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:63) at org.pircbotx.hooks.managers.ThreadedListenerManager$1.call(ThreadedListenerManager.java:119) at org.pircbotx.hooks.managers.ThreadedListenerManager$1.call(ThreadedListenerManager.java:115) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) [main] INFO org.pircbotx.InputParser - :[email protected] PRIVMSG ##uno :!play y r [main] INFO org.pircbotx.InputParser - :[email protected] PRIVMSG ##uno :hm [main] INFO org.pircbotx.InputParser - :[email protected] PRIVMSG ##uno :!play y r
How could I change the AI's name?
hello, the server i am trying to connect to is password protected how would i set the bot up with a server password?
to be more specific i am trying to connect to a ZNC, however i would like it if the uno ai didn't connect with the ZNC since it would work anymore
You can most likely see a pattern emerging here :P
I get lonely and try to play some uno, by myself, but I end up breaking things
[21:12:54] <Marco_Polo> !uno
[21:12:54] <bot-en-uno> Marco_Polo has joined.
[21:12:54] <bot-en-uno> type !join to join the game.
[21:12:54] <bot-en-uno> player who typed !uno (Marco_Polo) - can start the game with !deal.
[21:13:43] <Marco_Polo> Liam9?
[21:14:24] <bot-en-uno> This game is taking too long to start so I'm starting it for you!
[21:14:24] <bot-en-uno> Only one player in this game, launching AI player
[21:14:24] <bot-en-uno> Top Card: ��00,04RED D2�
[21:14:24] <bot-en-uno> Marco_Polo it is your turn.
[21:14:24] <bot-en-uno> Starting AI
[21:14:28] *** Joins: uno-AI ([email protected])
[21:14:28] <bot-en-uno> uno-AI there is a game up type !join to play.
[21:14:35] <uno-AI> !join
[21:14:35] <bot-en-uno> uno-AI has joined.
[21:14:35] <bot-en-uno> There are now 2 people in the players list
[21:15:10] <Marco_Polo> !leave
[21:15:10] <bot-en-uno> Marco_Polo has quit the game.
[21:15:10] <uno-AI> !play RED THREE
[21:15:10] <bot-en-uno> Top Card: ��00,04RED D2�
[21:15:10] <bot-en-uno> uno-AI it is your turn.
[21:15:10] <bot-en-uno> Top Card: ��00,04RED D2�
[21:15:10] <bot-en-uno> uno-AI it is your turn.
[21:15:10] <bot-en-uno> Top Card: ��00,04RED THREE�
[21:15:10] <bot-en-uno> uno-AI it is your turn.
[21:15:11] <uno-AI> !play RED THREE
[21:15:11] <bot-en-uno> Sorry uno-AI you dont have that card
[21:15:13] <uno-AI> !play RED TWO
[21:15:13] <bot-en-uno> Top Card: ��00,04RED TWO�
[21:15:13] <bot-en-uno> uno-AI it is your turn.
[21:15:15] <uno-AI> !draw
[21:15:17] <uno-AI> !play RED ZERO
[21:15:17] <bot-en-uno> Top Card: ��00,04RED ZERO�
[21:15:17] <bot-en-uno> uno-AI it is your turn.
[21:15:19] <uno-AI> !play BLUE ZERO
[21:15:19] <bot-en-uno> Top Card: ��00,02BLUE ZERO�
[21:15:19] <bot-en-uno> uno-AI it is your turn.
[21:15:21] <uno-AI> !play BLUE SKIP
[21:15:21] <bot-en-uno> uno-AI was skipped.
[21:15:21] <bot-en-uno> Top Card: ��00,02BLUE SKIP�
[21:15:21] <bot-en-uno> uno-AI it is your turn.
[21:15:23] <uno-AI> !draw
[21:15:25] <uno-AI> !play YELLOW SKIP
[21:15:25] <bot-en-uno> uno-AI was skipped.
[21:15:25] <bot-en-uno> Top Card: ��01,08YELLOW SKIP�
[21:15:25] <bot-en-uno> uno-AI it is your turn.
[21:15:27] <uno-AI> !play YELLOW EIGHT
[21:15:27] <bot-en-uno> Top Card: ��01,08YELLOW EIGHT�
[21:15:27] <bot-en-uno> uno-AI it is your turn.
[21:15:29] <uno-AI> !play YELLOW ONE
[21:15:29] <bot-en-uno> ���10uno-AI has UNO!!!!
[21:15:29] <bot-en-uno> Top Card: ��01,08YELLOW ONE�
[21:15:29] <bot-en-uno> uno-AI it is your turn.
[21:15:31] <uno-AI> !draw
[21:15:33] <uno-AI> !pass
[21:15:33] <bot-en-uno> uno-AI passed.
[21:15:33] <bot-en-uno> Top Card: ��01,08YELLOW ONE�
[21:15:33] <bot-en-uno> uno-AI it is your turn.
I want the bot to join multiple channels.
With latest code, i have observed a strange bug that happens sometimes when AI tries to play a WILD - but I haven't yet been able to track it down.
<unoBot> Top Card: GREEN SEVEN
<unoBot> unoAI it is your turn.
<unoAI> !play GREEN WILD
<unoBot> Sorry unoAI that card is not playable. Try something like !play red wild
Logs from ScoutLink In the channel #uno on 05/04/2021 (DD/MM/YYYY)
06:15:10 PM <Marco_Polo> !uno
06:15:10 PM <@bot-en-uno> Marco_Polo has joined.
06:15:10 PM <@bot-en-uno> type !join to join the game.
06:15:10 PM <@bot-en-uno> player who typed !uno (Marco_Polo) - can start the game with !deal.
06:15:16 PM <Marco_Polo> !ai
06:15:16 PM <@bot-en-uno> Starting AI
06:15:18 PM *** uno-AI ([email protected]) bot-en-uno - has joined the channel
06:15:18 PM <@bot-en-uno> uno-AI there is a game up type !join to play.
06:15:20 PM <Marco_Polo> !deal
06:15:20 PM <@bot-en-uno> Only one player in this game, launching AI player
06:15:20 PM *** uno-AI ([email protected]) has quit (Quit: )
!draw:
Allows multiple draws in one turn. I fixed with the following modifications...
In Player.java I added:
private String lastDrawnCard;
private boolean hasDrawn;
this.hasDrawn=false;
this.lastDrawnCard=""; \both to both constructors
public String getLastDrawnCard() {
return lastDrawnCard;
}
public boolean getDrawnStatus() {
return this.hasDrawn;
}
public void setDrawnStatus(boolean status) {
this.hasDrawn=status;
}
public void setLastDrawnCard(String theLastDrawnCard) {
lastDrawnCard=theLastDrawnCard;
}
In UnoBot.java I changed:
The !draw handler code to:
if(!players.at().getDrawnStatus()) {
String drawnCard=players.at().draw(deck).toString();
sendNotice(sender,"you drew a " + drawnCard);
players.at().setDrawnStatus(true);
players.at().setLastDrawnCard(drawnCard);
}
else {
sendNotice(sender,"You already drew a "+players.at().getLastDrawnCard()+"! Either play a card or pass.");
}
and I changed !pass handler to check value of players.at().getDrawnStatus() instead of drawn private variable.
!play executes players.at().setDrawnStatus(false); if it's a playable card.
For !leave...
In the UnoBot.java leave method...
I commented out line 156 because a ArrayList is being used so this is unnecessary.
I added:
String currPlayer=players.at().getName();
if(!players.at().getName().equals(currPlayer)) { sendMessage(channel, "The player list has been modified!");
sendMessage(channel, players.at().getName() + " it is your turn.");
this.sendNotice(players.at().getName(), showCards(players.at()));
if(botAI && (players.at().getName().equals("unoAI"))){
bot2.playAI(channel, players.at(), deck);
}
}
sendMessage(channel, name + " has quit the game like a pussy.");
But when I did this I was getting index out of bounds exceptions so in CircularArrayList.java I changed at() to:
if(at==super.size()) { return super.get(at-1); }
else { return super.get(at); }
This is a valid command. It sets the top color to WILD and makes it impossible to continue the game. Example:
09:25:39* ~Bao ║ !play wild wild
09:25:40* uno ║ Top Card: WILD WILD
09:25:40 uno ║ Hess it is your turn.
09:25:42 @copypaste ║ wow
09:25:47* @copypaste ║ >wild wild
09:26:01 ~Bao ║ Wild sounds really weird now.
09:26:02 Hess ║ ok
09:26:13 Hess ║ !play green two
09:26:13 uno ║ Sorry Hess that card is not playable.
09:26:17 @copypaste ║ lel
09:26:28 Hess ║ !play wild WD4
09:26:34 Hess ║ !play wild WD4
09:26:34 uno ║ Sorry Hess you dont have that card
09:26:36 ~Bao ║ What.
09:26:41 Hess ║ !play WILD WD4
09:26:41 uno ║ Sorry Hess you dont have that card
09:26:44 Hess ║ what
09:26:45 Hess ║ hmmm
09:26:46 @copypaste ║ w8
09:26:50 @copypaste ║ how do you choose color?
09:26:54 ~Bao ║ Copypaste says the day.
09:26:56 Hess ║ !play red eight
09:26:57 uno ║ Sorry Hess that card is not playable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.