Shell: see
Course webpage, with
referee.rb. First step is to make "pick()" beat "pick_rand()".
As an example of an alternative look, here's a Tk version to start: othello_demo.rb
othello01.rb - Strategy 1: Pick max count versus Random pick,
Sample output
Strategy 2: Pick min count versus Pick max count,
Sample output
othello02A.rb, othello02B.rb, etc - Investigate various strategies to determine your best strategy. For example:
If the space choice is a corner square, take this move. $corners = [11,81,18,88]
If the space choice is adjacent to a corner square, try not to take this move. $adjacents=[12,21,22,17,27,28,82,71,72,78,77,87]
Sample output
othello3.rb Minimax (also with alph-beta pruning?) - look ahead several moves in order to evaluate your best and most realistic next move.
In this process, give your opponent the benefit of the doubt (a good pick) when assume what the opponent move will be. This is a minimax concept.
You'll need an "evaluate_board" method to give scores to particular boardstates.
Example pseudo-code:
Minimax,
Minimax with Alpha beta pruning
Strategies to try
Strategy guide (scroll down to Introduction to Strategy)
Assignment One - ghost01.rb, Human vs Human, multi-player
Write a program that facilitates two or more humans playing ghost.
Players alternate naming letters which are appended to a string. If a
player names a letter that forms a word, or if he or she names a letter
that makes it impossible for the string to eventually form a word, and the
next player challenges, then the offending player receives a letter (in
order, G-H-O-S-T) and the challenging player begins a new string. If a
player challenges incorrectly then he or she loses the round and the next
player begins a new string. If a player receives all five letters to
spell GHOST then he or she is out. Play continues until only one player
is left, the winner.
Example
Player 1: C
Player 2: C-A
Player 3: C-A-T
Player 1: C-A-T-E
Player 2: C-A-T-E-G
Player 3: C-A-T-E-G-O
Player 1: C-A-T-E-G-O-R
Player 2: C-A-T-E-G-O-R-I
Player 3: C-A-T-E-G-O-R-I-C
Player 1: C-A-T-E-G-O-R-I-C-A
Player 2: C-A-T-E-G-O-R-I-C-A-L
Player 3: *challenge*
In this example Player 2 gets a G and Player 3 starts a new string.
Note that in ghost "words" must have at least four letters, so Player 3
does not lose on CAT.
Assignment Three - ghost03.rb, Use recursion and minimax tree, player points of view alternate at different levels of recursive tree calls
Program the computer to play ghost well.
Minmax output1 + algorithm,
output2 using "faster" algorithm (takes first good choice, not random)
output3 using "faster" algorithm (takes first good choice, random)
queensGA.rb - Genetic algorithm version, with crossovers and mutations
Generate 4 boards randomly
Clone the top ranked board and remove the lowest ranked board
Crossover "mate" each of the cloned top ranked board with one of the other two boards picked randomly. Randomly pick a crossover point.
If any of the 4 children from the crossover are duplicates, randomly mutate to generate a different child, so that all 4 children are unique.
You can also introduce mutations with a given probability at certain times in the process.
Sample output - solved 6 generations for queensGA.rb (storing conflicts with board state),
another version (storing conflicts and non-conflicts with the board state)
functionGA.rb (solve 1 or 2 of the following functions) (also see
course website)
newX1=0.5*x1+0.5*x2
newX2=1.5*x1-0.5*x2
newX3=-0.5*x1+1.5*x2
If newX out of bounds then add or subtract xmax-xmin (thanks to Alex Krzepicki)
Take best two out of these three newX values
ladder00.rb,
sample output - input start word followed by 5 valid continuations (change 1 letter, stay in dictionary, same length, new word not already used)
ladder01.rb, sample output - same as ladder00 except the program randomly picks a word from a list of valid continuations. It's possible that the continuation list is empty, stopping the program
ladder02.rb, sample output - same as ladder01 except the final word needs to have different letters than the start word (letters can match but need to be in different possitions). The length of the ladder is not limited to 5, and it's possible to reach a deadend. Extra - can your program handle deadends, backtracking to find non-deadend path?
ladder04.rb - iterative deepening: Start with a level limit of 1 and keep increasing until a path is found or you reach some higher limit level - iterative deepening-
sample output
convert the information to a ruby hash structure looking like this: map1.rb. Your program doesn't need to generate the %w syntax. The lists of cities need to be comma separated strings.
romania01.rb: (example starter hash table) Using the Romanian map, find a non-heuristic path, breadth first, from a start city to a goal city. This path does not need to be optimal and does not analyze distances. It only looks at connecting cities.
Example output
romania02.rb:
Part A: Build a "hash of hashes" table, City1 => City2 => distance City1 to City2.
Part B: Using this new hash table, calculate the cost of your path start to goal city.
romania03.rb: Uniform cost search. Choose the next city in the path according to the cheapest path cost of known distances between the cities.
Cost is the actual distance traveled from start city to the current city.
romania04.rb: Best First Search. Use the coordinates of each city, calculate estimated distances between each city and the goal city.
Choose the next city in the path according to the cheapest path cost..
Cost is the estimated distance from current city to the goal city.
locations.csv from
from course website,
romania05.rb: AStar Search. Use the evaluation function for the cheapest cost: f(n) = g(n) + h(n). g(n) is the total actual distance traveled (see Uniform Cost search), h(n) is the estimated distance from the current city to the goal (see Best First Search).
romania06.rb: Heap version of sort. Use a heap data structure to keep the list of potential paths in a priority queue, the shortest path is always at the top of the heap. Each new path is added directly to the heap, so no separate sort is needed. Verify that your heap works for Uniform cost, Best First, and AStar searches.
tile00.rb: mouse click on a tile adjacent horizontally or vertically to the white space tile and interchange "move" to the space (interchange the space and numbered tiles)
tile01.rb: board evaluator, underneath the tile grid print three heuristic evaluations of the current board state:
# of tiles in the incorrect spot (0 if the board is in the goal configuration)
manhattan distance: the sum of the distances of the tiles from their goal positions
linear conflict: for every two of the tiles being evaluated manhattan distance, if two are in the same row or column, add two to the manhattan score for these two tiles.