Reddit is a popular social media service used by many students. Reddit also encourages its users to make bots, and it has an active "botting" community. In this assignment, students join this botting community by building bots that "talk" to each other. To make the assignment more fun, I try to time the assignment's due date with an election and have the bots talk about political candidates.
Students learn many technical skills from this assignment: how to use external python libraries, how to navigate trees, how to deal with randomness, and basic devops.
But the real benefits of this assignment are non-technical. The assignment forces students to wrestle with important ethical/legal dilemmas about online botting and freedom of speech, and it gives them the technical knowledge necessary to meaningfully participate in these debates.
Because of these non-technical applications, this assignment is particularly well suited for getting humanities students excited about computer science.
I used this assignment in a CS1 class in Fall 2020, and the students' bots sent messages supporting their favorite presidential candidate. Most students bots wrote messages supporting either Biden or Trump.
All of these messages are publicly viewable on the /r/csci040temp subreddit. The screenshot below shows a typical conversation between two student bots:
Since these posts are publicly viewable, a large number of ethical and legal questions are raised by this assignment. The ethical/legal FAQ below addresses these concerns.
This project is relatively long for CS1, and I've scaffolded it into 2 labs and a homework.
Lab 1 introduces students to Python's PRAW library. Students learn how to download and install external libraries using pip, and read/write messages to reddit programmatically. Students are also exposed to many examples of good reddit bots that are important parts of the reddit ecosystem. Materials can be found in the lab-PRAW folder.
Lab 2 teaches students how to programmatically generate text using a simple MadLibs-style formula. This is a relatively easy assignment compared to the previous lab and final homework, but students find it particularly fun because I have them play around with AI Dungeon to explore state-of-the-art text generation. Materials can be found in the lab-madlibs folder.
The Homework combines the two labs into a full-fledged bot that posts random comments to reddit. The homework requires both writing code and running it for an extended period, which exposes students to basic devops ideas. I typically give students 2 weeks for the coding portion of the assignment, and 1 week for the devops portion. I don't require students submit their code until the end of the devops portion, however, so students typically continuously make corrections and improvements to their bot during this time as well. Materials can be found in the hw-redditbot folder.
Support files: There are also many supporting files needed for this assignment, all located in the support directory. There are three example solutions, each of which posts slightly different messages:
The main purpose of all of these files is to generate a handful of starter posts and comments so that students have something that their bots can reply to. They can also serve as a reference for instructors for how to implement the assignment. Unfortunately, the code cannot be run as-is because credential information needs to be provided.
This assignment raises many ethical and legal questions for students, faculty, and administrators. This FAQ addresses these questions. I make this FAQ available for students, and we have extensive in-class discussions about these topics.
Q1: Bots are bad for democracy. Why would you want to teach students to make them?
Bad bots spreading fake news have gotten a lot of media attention, but many bots are actually good for society. The community /r/TheoryOfReddit maintains a wiki of reddit's most famous good bots. Other online social networks like Twitter also have many good bots.
Students who complete this assignment will have the skills needed to both distinguish between good and bad bots online, and to make their own good bots.
Q2: But is it legal to develop bots?
Yes. Reddit actively encourages its users to create bots, and bots form an important part of the reddit ecosystem. Reddit requires all bots to comply with the API terms and bottiquette, and students are required to review and comply with these documents. This is fairly easy to do. Basically, bots are not allowed to do things humans are not allowed to do (e.g. spam, harass, spread malware), and bots must comply with technical constraints like providing a valid HTTP user agent and obeying rate limitations.
Outside of reddit, the legal status of bots is a more interesting question. In 2019, the California Senate passed the Bolstering Online Transparency (BOT) law that requires most political and commercial bots to clearly label themselves as bots. This is an intuitively sensible regulation, but it has many subtle first ammendment implications and so legal scholars are currently unsure about it's constitutionality (see comments by Politico, and Electronic Frontier Foundation, and the Knight First Ammendment Institute). Fully understanding these legal issues requires a technical understanding of how bots work, and that understanding can only be gained by actually building bots.
Q3: I've heard that most bots are run by foreign governments like Russia. Don't you need a lot of resources and expertise to create a bot?
No. Bots are easy to create, and anyone with a small amount of CS knowledge can create them. A major purpose of this assignment is to help students understand that anyone can write a bot, not just state-actors.
Q4: How do you prevent unintended negative externalities of this assignment?
Since student bots are posting messages to the public internet, the main risk of this assignment is that someone who is not part of the class finds these messages and doesn't realize they are being sent by bots. I take two measures to prevent this from happening:
I create a specialized subreddit dedicated for class activities, and student bots are required to post only in this subreddit. The subreddit is clearly marked as being only for class activities and that all posters are bots.
These measures exceed the requirements imposed by law and reddit's terms of service.
Q5: Why give students a potentially controversial assignment that raises so many ethical and legal questions?
Ethical reflection is a core part of a good CS curriculum. For example, accreditation agencies like ABET require that we integrate ethics into computer science courses, and the ACM's Code of Ethics and Professional Conduct admonishes CS professionals to "reflect upon the wider impacts of their work". This assignment and accompanying in-class discussion teach students how to reflect on the ethical considerations of their work.
Bot technology (and other potentially dangerous CS technology) is going to be a central part of our future. We cannot shield students from this fact, so we must prepare them for it. Students will have to make personal decisions about how they will interact with this technology online, and our society will have to make collective decisions about how this technology will be regulated. It is best that students make these decisions from an informed perspective.
I'd love to help other instructors get setup running a similar assignment, or collaborate with other instructors to run this assignment jointly between our two schools. I think it would be particularly cool if we could have students' bots from different schools all "talking" with each other on the same subreddit, perhaps debating which school is best. Please email me at email@example.com if you're interested :)
|Summary||Students build a reddit bot that posts messages to reddit and replies to other student's messages|
|Audience||The assignment is designed for humanities majors taking CS1. I've found that these students enjoy both working with real world social media websites and the ethical/legal issues raised by this assignment.|
This assignment integrates a large number of both technical and non-technical topics.
Technical topics include:
|Difficulty||This is a relatively long and difficult project for a CS1 course.
I normally give students 3 weeks for this assignment: 2 weeks for coding, and 1 week for devops.
The main challenges students stuggle with are:
The main weakness of this assignment is that it's much more work for the instructor than a typical CS1 assignment.
|Variants||There are many variants to this problem described in the extra credit section of the grading rubric. Students often have a lot of fun on this assignment, and put in a lot of extra work to complete these extra credits. For students who do this, I'm happy to give them 150% on the assignment because they've demonstrated both a real enthusiasm for programming and the ability to work through novel complex problems that weren't covered in class. From my perspective, that's the best case result of a CS1 course, and I'm happy to use lavish extra credit to incentivize this behavior.|