Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Checkers King Problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
AdeptZero




PostPosted: Thu Jun 19, 2008 12:59 am   Post subject: Checkers King Problem

I'm having a problem with my com sci final project, so it'd be nice if I could get some pointers or tips. I've gotten a red king to be displayed on the board, but I can't get it to move back. I used the same code as I did for the regular red & blue pieces. I can't see the problem, and the project is due tomorrow. Help would be greatly appreciated. Thanks!

Instructions

1. Simply download the files and save them under the same directory

Problem

1. Move any Red to the last row of the board.

2. A Red King will appear thus replacing the red piece that entered the last row

3. However, the Red King cannot be moved --> Problem



redking.jpg
 Description:
Red King Piece Pic
 Filesize:  35.57 KB
 Viewed:  206 Time(s)

redking.jpg



blue.jpg
 Description:
Blue Piece Pic
 Filesize:  28.53 KB
 Viewed:  156 Time(s)

blue.jpg



red.jpg
 Description:
Red Piece Pic
 Filesize:  19.97 KB
 Viewed:  180 Time(s)

red.jpg



temp.t
 Description:
Game File Itself

Download
 Filename:  temp.t
 Filesize:  12.01 KB
 Downloaded:  147 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
gitoxa




PostPosted: Thu Jun 19, 2008 12:09 pm   Post subject: RE:Checkers King Problem

The first thing I see is your validmove function. The big if statement:

Turing:
if turn = "R" then
    ...
elsif turn = "B" then
    ...
elsif turn = "R" and board (frompiecer, frompiecec) = "RK" then
    ...
elsif turn = "B" and board (frompiecer, frompiecec) = "BK" then
    ...
end if


The logic there is a little off. The other problem lies in your "frompiececlicked" procedure.

Turing:
if (board (frompiecer, frompiecec) = turn) then
    mouseclicked := true
end if
Warchamp7




PostPosted: Thu Jun 19, 2008 7:48 pm   Post subject: RE:Checkers King Problem

Well, if you're using the SAME code as the normal red and blue pieces and you have it coded properly (as the game rules are), the problem is that your king is not allowed to move backwards if it has the normal piece code.
gitoxa




PostPosted: Thu Jun 19, 2008 10:25 pm   Post subject: RE:Checkers King Problem

It's coded to allow the kings to move backwards, other than the two things I pointed out. Because of them, the king can't move in any direction.
AdeptZero




PostPosted: Fri Jun 20, 2008 9:36 pm   Post subject: RE:Checkers King Problem

Is there any way I can fix this without adding a new parameter to turn for the Red King and Blue King?
gitoxa




PostPosted: Fri Jun 20, 2008 11:44 pm   Post subject: RE:Checkers King Problem

Here's a hint.
code:
"RK" = turn+"K"
AdeptZero




PostPosted: Sat Jun 28, 2008 1:21 pm   Post subject: RE:Checkers King Problem

Although its already been evulated, I'm curious on how to solve this problem. Gitoxa, if I assign RK the value of turn plus "K", it still draws the red king. But I don't see the difference between that and what I currently have. Could you please explain? Thxs..
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: