Skip to content

jlu5/wikiTrivia

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

wikiTrivia

wikiTrivia is an interactive CLI trivia game written in SWI-Prolog. It sources questions from Wikidata, using swipl's built-in SPARQL client to pull down results.

This project was written as part of CPSC 312 - Functional and Logic Programming @ The University of British Columbia, Sep-Dec 2021.

Features

  • Alternative answers (usually alt labels in Wikidata)
  • Hints for text responses - 3 attempts per question
  • Lenient scoring for numerical answers, using a range of accepted responses
  • Caching to local JSON

Query format

All of the SPARQL queries used in the game expect a specific set of arguments in order: the question entity, the question entity's label, the answer entity/value, the answer entity/value's label, and any alternative text answers. For values, the game currently supports text literals (with or without a language), decimal literals, and date literals (exported as the year only).

In practice, trivia queries should take care to filter away extraneous relations for playability - e.g. capitals-to-countries.rq has to remove historical countries or those that a particular city was formerly in.

See queries/ for more examples.

Usage

You can start the game by running ./main.pl

The following command line arguments are supported:

wikiTrivia - a trivia quiz game based off Wikidata relations
--num-rounds       -n  integer=5                  number of rounds to play
--scoring-range    -R  integer=100                range size of accepted answers for
                                                    numerical based scoring
--query-file       -f  FILE:atom=_                load a SPARQL query from FILE instead of
                                                    prompting
--question-format  -q  QFORMAT:atom=Question: ~w  string to format questions; this should
                                                    include a ~w to substitute the question
                                                    item
--help             -h  boolean=false              show this help text

Tests use PlUnit; you can run them with make test or make test-repl.

About

Interactive console trivia game using SWI-Prolog and Wikidata

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published