CMPSCI 383: Artificial Intelligence

Fall 2014 (archived)

A Simple Hill Climber

In class today we ended up working through a Java version of a simple hill climber for Assignment 02. Thanks to you all for helping me get it right(-ish). Any errors you spot are mine.

I was using the free Community Edition of the IntelliJ IDEA, which you might want to give a try if you haven’t before. PyCharm is a similar tool for Python from the same company.

You can download the code that we wrote here: simple-hillclimber.tar.gz. You are welcome to use it as the basis for your own solution.

I made a few minor changes after class:

  • I added some suggestions in comments about ways to add random restarts and stochastic searches. You won’t need to do all of them, and you might be able to think of others that will do better, or that will be easier to implement, or that are just more interesting to you.
  • I switched the sub-problem representation (that is, the sub-wall) from type Integer[] to type SubWall. It makes the program marginally more readable.
  • I limited the scope of the try/catch block to only enclose the relevant code.

Let me know if you particularly liked or disliked the use of class time for programming. I can’t do it every class, but I might do it occasionally if enough people found it useful and few enough found it useless. Alas that we have no discussion section, as that would be a great time for it.