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

Username:   Password: 
 RegisterRegister   
 Turing Dart Program Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
snowgoblin




PostPosted: Sun Jun 21, 2020 10:59 pm   Post subject: Turing Dart Program Help

What is it you are trying to achieve?
I am trying to create a functioning dart game for turing, using no images or music files. I want to find out why a certain part isn't working and maybe implement a simple AI to play against.


What is the problem you are having?
I have a process called "adjustproc" which should move the dart slightly if it would hit something else, such as the wire or another dart. However, it doesn't seem to be working. Also, I think that the way I did the scoring (using whatdotcolour and x,y coords) is far from optimal and could be improved. I also would like some competition against me but have no idea how to even start.


Describe what you have tried to solve this problem
Well, I tried tracing the execution with breakpoints and it seemed to be running the process, just not responding in the way I want it to. I created a big off-coloured square in the centre to see whether it would work there, and it did. Yet, the dartboard still returns scores of 0 when it shouldn't. Like I said above, I really don't have any idea how to start on an AI


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Please specify what version of Turing you are using
I am using 4.1.1



darts.t
 Description:

Download
 Filename:  darts.t
 Filesize:  29.05 KB
 Downloaded:  293 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
dropdembits




PostPosted: Tue Jun 23, 2020 12:05 pm   Post subject: Re: Turing Dart Program Help

While your code definitely is updating the position of the dart, after the position is updated, it's not using the new position values to show the dart.

Turing:

% [snip]
        if dartsleft = 2 then %1st dart thrown
            % -> Show the dart at the old position
            Sprite.Hide (dartsprite1)
            Sprite.SetPosition (inboardsprite1, dartthrowx, dartthrowy, false)
            Sprite.Show (inboardsprite1)
            View.Update
            dartsoundproc
            hasthrown := false
            adjustproc
            % -> By this point, the dart's position is updated, but is not shown at the new position
            % -> (the dart has already been shown to the screen by this point)
            scoreproc
% [snip]


To fix this, show the dart after you've adjusted the position (ie, after 'adjustproc').

*edit: Add this to show where to put it
Turing:

% [snip]
        if dartsleft = 2 then %1st dart thrown
            dartsoundproc
            hasthrown := false
            adjustproc
            % -> Show the dart after 'adjustproc' to use the new position to show at
            Sprite.Hide (dartsprite1)
            Sprite.SetPosition (inboardsprite1, dartthrowx, dartthrowy, false)
            Sprite.Show (inboardsprite1)
            View.Update
            % -> Scoring
            scoreproc
% [snip]



As for a better way of determining the scoring, you could use the distance from the centre of the dart board to the thrown dart, as well as the angle between the dart board and the dart (using 'atand') to determine where the dart is on the board.

(Let me know if you are confused, this is my first helping post)
snowgoblin




PostPosted: Tue Jun 23, 2020 2:54 pm   Post subject: Re: Turing Dart Program Help

For the scoring, yes absolutely I should have done it that way... I guess my brain was a little overused at that point (I had written the program in about 3 hours).

As for the adjustment procedure, it's not so much the visual position that I'm worried about, rather that sometimes, when I throw a dart and it hits exactly on the white dividing line, the position should be adjusted so that the real position (not the visual one) is outside of the white part and therefore would count as a score other than 0 (which it does when the dart hits the wire, and it would deflect on a real dartboard). In theory, it should work, but it still returns scores of 0 and I'm frustrated with it.

Any thoughts on how to program an AI to play against? I'm not a great programmer and I've never done any AI programming before.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: