[Tutor] 15 puzzle
JAIME'S MAIL
jaime@hilcos01.hilconet.com
Sun, 29 Apr 2001 18:36:28 -0500
I would like to make a program for the 15-puzzle in python language. I have
this program for it, but it is in another language. Could you help me
translate it to python?
import java.applet.*;
import java.awt.*;
//--------------------------------------------------------------------------
public class fifteen extends Applet
{
private SevenSegmentDigit[] display = new SevenSegmentDigit[3];
private Button[] Buttons = new Button[16]; //This array is an actuall
playfield.
private Button shuffleBtn = new Button ("&Shuffle");
private int score=0;
private int shuffling=0;
private Font f;
/*---------------------------------------------------------------*/
public String getAppletInfo() //Do I need this function?
{
return "Name: fifteen\r\n" +
"Author: Eugene\r\n" +
"Created with Microsoft Visual J++ Version 1.0";
}
/*---------------------------------------------------------------*/
public void init()
{
int i=0;
String str=new String();
resize(200, 300);
setLayout(null); //Why do they bother so hard with layouts?
setBackground(Color.black);
for(i=0; i3)
moveBtn(empty-4);
return true;
case Event.LEFT: if(empty % 4 !=3)
moveBtn(empty+1);
return true;
case Event.RIGHT: if(empty % 4 != 0)
moveBtn(empty-1);
return true;
case 's':
case 'S': shuffle();
return true;
}
return false;
}
/*---------------------------------------------------------------*/
public boolean action(Event evt, Object what)
{
int i=0;
for(i=0;i
_____________________________________________________________
I would appreciate any help!
Maritza