Git Product home page Git Product logo

cs50ai-test's Introduction

CS50's Introduction to Artificial Intelligence Test Scripts

๐Ÿคทโ€โ™‚๏ธ What's this? ๐Ÿคทโ€โ™€๏ธ

This repository contains Python scripts to automate tests for most of the CS50โ€™s Introduction to Artificial Intelligence with Python projects.

It does not contain any project solution/spoiler, as per the course's Academic Honesty policy.

โ›” Disclaimer

This is a student-initiated project. Passing these test cases does not guarantee that you will receive a full grade from the official CS50 AI's teaching team.

๐Ÿ“– Table of Contents

Lecture Concept Project Test Script Description
Search Breadth First Search Degrees degrees_test.py Run test cases given by problem description and this discussion
Search Minimax Tic-Tac-Toe tictactoe_test.py Let your AI play against itself for 10 rounds
Knowledge Model Checking Knights puzzle_test.py Check the correctness of the 4 puzzle results
Knowledge Knowledge Engineering Minesweeper minesweeper_test.py Check if your AI has โ‰ˆ90% win rate over 1000 simulations
Uncertainty Bayesian Networks Heredity heredity_test.py Run test cases given by problem description and this discussion
Uncertainty Markov Models PageRank pagerank_test.py Compare the output of the 2 implemented functions
Optimization Constraint Satisfaction Crossword generate_test.py Generate crosswords using all 9 different structure + words combination and a special test case from this discussion
Learning Nearest-Neighbor Classification Shopping shopping_test.py Check the information is parsed correctly and result is within a reasonable range
Learning Reinforcement Learning Nim nim_test.py Check if the AI which moves second has a 100% win rate

๐Ÿ› ๏ธ How to Run Tests

Guide

  1. Make sure you have Python3 installed in your machine. Anything above Python 3.4+ should work.
  2. Install pytest by running pip install pytest in a terminal. More information about pip here.
  3. Make a copy of the test file and paste it in the same folder as the project that you want to test.

    For example, if you want to test your code for degrees.py, make a copy of degrees_test.py in the same folder as your degrees.py and other files that came along with the project, like util.py, large/ and small/.

  4. Navigate to the project folder and run pytest or pytest <project>_test.py in a terminal.

    For example, navigate to degrees/ and run pytest or pytest degrees_test.py.

Example

example

๐Ÿšฉ Useful pytest Flags

  • Run pytest -s to show print statements in the console
  • Run pytest -vv for verbose mode
  • Combine both flags pytest -s -vv for extra verbose mode
  • Run pytest --durations=n to see the n slowest execution time
  • Install pytest-repeat with pip and then run pytest --count n to repeat the test for n times

๐Ÿ’ป My Setup

Each test should take less than 30 seconds, depending on Python's I/O and your code efficiency.

  • Windows 10 Home Build 19042
  • Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  • Python 3.9.5 64-bit
  • Visual Studio Code w/Pylance (latest release)

๐Ÿ† Acknowledgement

Special thanks to these fellow CS50AI classmates who contributed some of the test cases on the Ed discussion site!

  • Ken Walker
  • Naveena A S
  • Ricardo L

cs50ai-test's People

Contributors

jetkan-yk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.