C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 31st, 2013, 07:01 AM
maximilian12 maximilian12 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2013
Posts: 1 maximilian12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 9 sec
Reputation Power: 0
General - Checkers longest hit algorithm.

I am currently working on a checkers game for school. Everything is going fine but I just can't seem to figure out the following:

in checkers, when one has multiple options for hitting the opponent, the player must choose the option in which the most pieces are hit. Can somebody give me some advice on how to make an algorithm that looks for the most pieces to hit?

Here is a little pseudo code I have so far:

Code:
    hitupright()
    {
        x=x-2; //Change co-ordinate;
        y=y+2;
        position = ((y*5)-6)+(((x+1)/2)); //formula that turns co-ordinates into an int
        postionarray[hitamount][route] = position; //saves position into a 2D array,

        if(checkhitupleft()=true){hitamount++;hitupleft();  }
        if(checkhitupright()=true){hitamount++;hitupright(  );}
        if(checkhitdownright()=true){hitamount++;hitdownri  ght();}
        if(checkfornohit()=true){route++;hitamount=0} //goes to next route and makes hit 0
    }
    hitdownright()
    {
        x=x+2;
        y=y+2;
        //same as other function, only doesn't call function hitupleft because we came from there.
    }
    hitdownleft()
    {
        //etc.
    }


The only problem I got is that I have to return multiple variables (`hit`, `position`, `route`) in order to make this work properly. I have looked online on how to return multiple variables out of a function, but I can't figure out how to use it for my code.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - Checkers longest hit algorithm.


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap