1 of 19

#wolfbot

#wolfbot

A quick introduction to creating IRC bots in java using pircbot.

2 of 19

PircBot

  • Old - Last updated 2009.12.14
  • Thats ok IRC is old too!
  • Written by a UKC student.
  • Built in flood control.
  • Targets java 1.1 can run on very�old hardware.

3 of 19

Our first bot!

import org.jibble.pircbot.*;��public class MyBot extends PircBot {� public MyBot() {� setName("WolfBot");

setVerbose(true);

bot.connect("irc.freenode.net");

bot.joinChannel("#wolftest");� }� public static void main(String[] args) throws Exception {� MyBot bot = new MyBot();� }

}

4 of 19

Demo

  • Joins channel.
  • Can see messages in log.
  • Doesn't do anything usefull!
  • BORING.

5 of 19

Echo echo echo echo bot

@Override

public void onMessage(String channel,

String sender, String login,

String hostname, String message) {�

sendMessage(channel,

sender + " said: " + message);

}

6 of 19

Demo

  • Still boring!

7 of 19

Adding Commands

@Override

public void onMessage(String channel,

String sender, String login,

String hostname, String message) {

if (message.startsWith("!") {

command(channel,sender,

login,hostname,message)

}

}

8 of 19

public void command (String channel,

String sender, String login,

String hostname, String message) {

String[] args;

message = message.substring(1);

args = message.split(" ");

...

9 of 19

...

switch (args[0]) {

case "help": //Java 7 bitches

sendMessage(channel, "Commands: help");

break;

default:

sendMessage(channel,

"Unknown command... Idiot.");

break;

}

10 of 19

Demo

11 of 19

So why #WolfBot?

12 of 19

What is Werewolf?

  • Werewolf takes place in a small village which is hunted by werewolves.
  • Each player is secretly assigned a role - Werewolf, Villager, or a special Villager.
  • The game alternates between night and day phases. At night, the Werewolves secretly choose a Villager to kill.

13 of 19

What is Werewolf?

  • During the day, the Villager who was killed is out of the game. The remaining Villagers then vote on the player they suspect is a Werewolf. That player is out of the game.
  • Werewolves win when there are an equal number of Villagers and Werewolves. Villagers win when they have killed all Werewolves.

14 of 19

Features

  • Lots of roles from Ultimate Werewolf (and hopefully more coming).
  • Players control available roles.
  • Automatic "good" role mixes of roles.
  • Bot takes roles of moderator�so everyone can play.

15 of 19

Un-Features

  • No Xombies, Vampires etc.
  • Hard to add new teams at the moment.
  • As of writing the messages are very repetitive.
  • Misses the subtle clues from�real werewolf in real life.

16 of 19

Shall we play!?

  • Server: irc.blitzed.org
  • Channel: #wolfbot
  • Important commands:
    • !help
    • !join
    • !lynch - During the day.
    • !kill/!nom - As a werewolf at night.

17 of 19

More Werewolf Tonight!

18 of 19

Code on github.

19 of 19

Links/Notes

  • http://www.jibble.org/pircbot.php
  • http://boardgamegeek.com/boardgame/925/werewolf