Skip to content

Commit 2e890eb

Browse files
committed
started PuzzleSolver w/Jim
1 parent e5241a2 commit 2e890eb

File tree

6 files changed

+68
-185
lines changed

6 files changed

+68
-185
lines changed
45.4 KB
Binary file not shown.

TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/graders/QuizBuzzAdapter.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/graders/QuizBuzzGrader.java

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.teachingkidsprogramming.section08tdd;
2+
3+
import java.awt.Color;
4+
import java.awt.Graphics2D;
5+
6+
import javax.swing.JPanel;
7+
8+
import org.teachingextensions.logo.Paintable;
9+
import org.teachingextensions.logo.PenColors;
10+
import org.teachingextensions.windows.ProgramWindow;
11+
12+
public class PuzzleBoard extends JPanel implements Paintable
13+
{
14+
private static final long serialVersionUID = 1L;
15+
public void addTo(ProgramWindow panel)
16+
{
17+
panel.addPaintable(this);
18+
}
19+
@Override
20+
public void paint(Graphics2D g, JPanel caller)
21+
{
22+
Color color2 = PenColors.Blues.DarkBlue;
23+
g.setColor(color2);
24+
g.fillRect(20, 20, 400, 400);
25+
g.setColor(PenColors.Blues.SkyBlue);
26+
g.fillRect(30, 30, 380, 380);
27+
}
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.teachingkidsprogramming.section08tdd;
2+
3+
import org.teachingextensions.windows.ProgramWindow;
4+
5+
public class PuzzleSolver
6+
{
7+
//this problem is an ArraySort w/ custom rules
8+
//the ArraySort (square) controls which positions can be swapped with each other
9+
//must determine 'where is the blank (square)?'
10+
//must determine 'where to move the blank to get the array more sorted than it is?'
11+
//this is a type A* problem (AI) -
12+
//generate all permutations and check to see which ones are valid (evaluate costs)
13+
//throw away all non-valid choices (highest costs)
14+
//keep track of the history of cost
15+
//develop a heuristic for estimated cost of possible actions
16+
//
17+
//NOTE: this is a kata (higher level instructions)
18+
//part of the exercise is to translate into line-by-line English, THEN Java
19+
//
20+
//for more complete directions see this page
21+
//https://www.penflip.com/lynnlangit/tkp-lesson-plans/blob/master/course09.txt
22+
//complex example -- http://www.brian-borowski.com/software/puzzle/
23+
//http://en.wikipedia.org/wiki/File:Batgirl.gif
24+
//
25+
public ProgramWindow programWindow;
26+
public PuzzleSolver()
27+
{
28+
programWindow = new ProgramWindow("Puzzle");
29+
PuzzleBoard jboard = new PuzzleBoard();
30+
jboard.addTo(programWindow);
31+
programWindow.setVisible(true);
32+
//Image batGirl = batGirl.drawImage(batGirl, 0,0,100,100, null);
33+
//programWindow
34+
// .setBackgroundImage("http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Batgirl.gif/120px-Batgirl.gif");
35+
}
36+
public static void main(String[] args)
37+
{
38+
new PuzzleSolver();
39+
}
40+
}

TeachingKidsProgramming/src/org/teachingkidsprogramming/section08tdd/QuizBuzz.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)