https://rcardinal.ddns.net/code
See elsewhere for recommended software packages.
Su Doku Solver
- Solves 3 x 3 Su Doku puzzles, as featured in the Times T2 section for a daily prize of a bottle of champagne. Shows its working. Takes 0-1 ms for simple puzzles, 3 ms for the average "fiendish"-level puzzle from the Times, and ~64 ms for very difficult puzzles, on a 2.5 GHz Pentium 4.
- Strategy: (1) Attempt to solve current state of puzzle analytically. (2) If unsolved, guess one value and attempt to solve that, recursively, until all possible uncertain values have been guessed or a solution has been found. Tactics: (1) Analyse using a three-dimensional matrix (x, y, digit) of boolean variables indicating the possibility of a digit being in a particular location or cell. (2) Where a digit is known, eliminate it as a possibility from other cells in the same row/column/3x3 square. (3) Where there is only one possible cell for a digit in a row/column/square, confirm that digit by eliminating other possible digits from that cell. (4) Where there are n identical sets of n possible locations for n digits (e.g. for n=2: digit 4 can only be in locations A or B, and digit 8 can only be in locations A or B), eliminate all other possible digits from those locations. This is an extension of the previous tactic (for which n=1). (5) Repeat these tactics until the puzzle is solved or there is no improvement in knowledge.
- Flaws in the current incarnation: (1) doesn't give all solutions to underdetermined puzzles (just the first one it finds); (2) only handles 3 x 3 puzzles; (3) only shows its working for successful lines of attack (if guesses fail, those attempts aren't shown); (4) bug in the "inconsistency" detector that fails to detect some inconsistent puzzles, and therefore tries to solve them, locking up in the process [thanks to MRFA 31 Aug 2005 for spotting this]; (5) I've seen puzzles where my algorithm succeeds through guessing where others don't need to (implying a slight error in the application of the strategy or that I've missed some other way to use the available information).
- SuDokuSolver source (zipped) , executable (zipped) , executable (.EXE) . The user interface is for Windows, but the core puzzle-solving code (in C++) is pretty much cross-platform.
- For a JavaScript solver, and links to yet more, see http://act365.com/sudoku/.
Fix for random_shuffle algorithm
Update to XML ParamIO for VisualStudio 2008
- The ParamIO project is an XML-based library to load/save application parameters. If you're starting to code from scratch, I'd suggest the Boost Serialization library. However, if you already have XML ParamIO software and you need to upgrade from (e.g.) Microsoft Visual C++ 6 to (e.g.) Visual Studio 2008, then the ParamIO library breaks. Here's an update, XMLParamIO2, that fixes the problems and also provides built-in support for the MFC CString class. Comments labelled "RNC" indicate my modifications, and there's a bit of explanatory text in ParamIO.h.
Amalgam
- Amalgamates text files that have a common header. Intended for merging many similar comma-separated value (CSV) files before importing a single file into a relational database.
- Perl version ; less sophisticated NT batch file version .
Other Perl scripts
- Source code line counter (counts total number of lines in all .C, .CPP, .H, .HPP files in the current directory and subdirectories thereof).
- Systematic review of PubMed. You tell it a PubMed query, and a directory to store its results. It searches PubMed and creates (1) a tab-delimited summary file suitable for importing into (e.g.) Excel and hand-editing as you work through your systematic review; (2) an index.html and associated HTML files for each search result. Load the index file into your brower to explore.
- Systematic review of OMIM. This performs the same function for the OMIM (Online Mendelian Inheritance in Man) database.
- webfetch. This retrieves any URL (including binary files) without modification.
- Other Perl scripts.
Whisker and related tasks
- Whisker is a software suite for controlling devices, primarily oriented towards in a behavioural research environment. It controls touchscreens, monitors, sound devices, and digital input/output devices, among others. It is used by a number of universities, governmental research organizations, and commercial companies.
- Tasks written for Whisker (by Rudolf Cardinal and/or Mike Aitken) include AttMem, ConditionedReinforcement, CondWithdrawal, DialysisStimuli, FearCond, FiveChoice, ImpulsiveChoice, LeverAutoshaping, LeverReversals, PIT, SecondOrder, SeekTake, SeekTakeShock, SimpleSchedules, DMTS/DNMTS, and VisualAutoshaping.
- Task suites written for Whisker include MonkeyCantab (probably the most popular worldwide), RatBat, and PigTab.
Arachnid behavioural tasks
- All programs are in BBC BASIC V with Arachnid real-time extensions, but are supplied here as text files. They run on the Acorn Archimedes, a computer excellent for its time but long since defunct almost everywhere except experimental psychology laboratories. Arachnid is an add-on package to BBC BASIC that was sold by Cambridge Cognition Ltd, originally written by Paul Fray, and a successor to the previous generation (!) of similar software, known as Spider, that ran on the BBC microcomputer (also from Acorn).
- Readme from 1 July 1999 about this collection of software.
- ProgLibs. First, a set of libraries, to go in a "ProgLibs" directory. Many other tasks rely on these: ARACHNID (input/output line control routines), ASCII (sending text to files for data recording), BOXCONST (line number constants for various types of operant chamber), DATETIME (date/time functions), DELAYLIB (common functions used by a number of tasks assessing choice involving delayed reinforcement), FILENAME (simple file handling), JP (routines written for John Parkinson to control Intasolve touchscreens directly through a serial port), RANDOM (random number functions), SPOOL (to manipulate spool files and printer output), UI (user interface functions, e.g. to retrieve parameters sensibly), YOGILIB (box definitions and touchscreen functions for Yogita Chudasama).
- Sample !RUN and START files.
- Tasks used by me. 2-CRF (two-stimulus conditioned reinforcement task), 2-DA-OM (two-stimulus discriminated approach task with an omission contingency), 2-DISCAP (two-stimulus discriminated approach task), ADJDELAY (adjusting-delay task where delay can vary after every choice trial), BRADSHAW (original version of an adjusting-delay task, after that of Mazur and Bradshaw; some code by Rob Rogers and Nathaniel Daw), CAPTRAIN (train on a fixed-ratio-1 schedule for a capped number of reinforcers), CRF (conditioned reinforcement, acquisition-of-a-new-response design: one lever produces an abbreviated version of the conditioned stimulus from the DISCAP task while the other has no programmed consequence), DISCAP (discriminated approach: light/sound CS predicts sucrose), DTRAIN (trains a schedule in which nosepokes initiate forced-choice trials), EVENDEN (one pellet now, or four pellets later? Delays are 0, 10, 20, 40, 60 s and vary systematically across the session, with a session length of 100 min), EVINFUSE (for intracerebral infusions: delays are 0, 20, 60 s for a session length of 60 min), EVNODEL (Evenden task with no delays, but still a 100 s trial period), FVRIP (FR, VR, FI, VI, and probabilistic simple schedules), INFUSE (simple infusion timer), LARDY (gives free pellets at high speed), PIT-MULT (multiple-stage task to test 'specific' and 'general' Pavlovian-instrumental transfer), PIT-SIMP (simple Pavlovian-instrumental transfer), RICHARDS (adjusting-magnitude task, after that used by Richards), SP-PIT (sensory preconditioning, using appetitive PIT as the measure of conditioning), TESTCBOX / TESTIBOX / TESTPBOX / TESTSBOX (test programs for 'combined', 'intermediate', 'pellet', and 'sucrose' boxes), YOKEDCRF (a yoked conditioned reinforcement task - incomplete).
- Tasks written for others.
- Anastasia Christakou. 5CHOICE (five-choice task, designed to mimic the behaviour of the Paul Fray original but to provide better output; some code by AC), 5CB-TEST (test program for 5-choice boxes).
- Yogita Chudasama. ATTMEM/CAM (two-stage five-choice task with attentional/mnemonic demands, originally known as ATTMEM, later known as CAM [combined attention/memory]; some code by YC), YSCRTEST (tests multiple VDU output system), YTCHTEST (tests touchscreen apparatus - conventional digital inputs/outputs, plus touchscreen sensors and interface), AUTOSHAP (autoshaping task using touchscreen apparatus), sample !RUN and START files.
- Felicity Miles. TESTEXT (records responses on two levers in extinction), RNCLIBS (collected relevant code from the libraries shown above).
- Yia-Ping Liu. TESTYBOX (box test program).
- John Parkinson. TESTTCH (tests touchscreen apparatus).
- Rachel Quirk. VIREV8 (concurrent random interval schedule written by Nathaniel Daw and modified by me), TEST_RHQ (box test program).
- Catharine Winstanley. EVFIXED (modification of the EVENDEN delay-of-reinforcement task to give a forced trial sequence prespecified completely by the experimenter), EVPROB (again, modified EVENDEN task: all trials are forced-choice, and the experimenter specifies a probability that a small/immediate or a large/delayed reward will be offered), GAMBLE (uses five-choice boxes to offer choice between rewards differing in reward probability/magnitude and punishment probability/magnitude; some code by CW, YC, and Mike Aitken).
- Jeff Dalley. 5CHYOK (yoked five-choice task), five-choice task allowing training with only one hole per session.
- Hannah Clarke. Reversal learning task (for touchscreens).
- Marie Pezze. Five-choice task with white noise option.
- Olivia Lehmann. 5-NMCAM (version of "CAM" [combined attention/memory] task that can also require >1 nosepoke per stimulus and perform both matching and non-matching to sample).
- IVSA group. IVSA (processes output from old Fray/Killcross second-order program into something legible in comma-delimited format, giving session summary data), AMALGAM (as above), IVSA (batch processing and amalgamation using the preceding Perl scripts), DAN-RESPONSE (processes output from old Fray/Killcross second-order program into something legible in comma-delimited format, extracting response times), DAN (batch processing and amalgamation using the preceding Perl scripts), IVSA response graph (Excel format; gives cumulative record and 'ticker' graphs), README for this data-processing kit.
Key to platforms: Windows, Macintosh, UNIX/Linux, Acorn Archimedes, MS-DOS or Windows command line, cross-platform.
Key to languages: C/C++, Perl, DOS/Windows batch file, BBC BASIC V with Arachnid real-time extensions, Visual BASIC.
Other symbols: PDF format (click here to download Adobe Acrobat Reader, which is free).