Click here to Skip to main content
15,848,723 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionShortes pass find + walls bypassing Pin
alikalik14-May-11 23:22
alikalik14-May-11 23:22 
AnswerRe: Shortes pass find + walls bypassing Pin
Luc Pattyn15-May-11 3:43
sitebuilderLuc Pattyn15-May-11 3:43 
AnswerRe: Shortes pass find + walls bypassing Pin
dasblinkenlight16-May-11 0:11
dasblinkenlight16-May-11 0:11 
NewsAckerman non-recursive function Pin
Raminnamiranian4-May-11 23:31
Raminnamiranian4-May-11 23:31 
GeneralRe: Ackerman non-recursive function Pin
Ravi Sant5-May-11 1:31
Ravi Sant5-May-11 1:31 
AnswerRe: Ackerman non-recursive function Pin
Luc Pattyn5-May-11 2:48
sitebuilderLuc Pattyn5-May-11 2:48 
GeneralRe: Ackerman non-recursive function Pin
Richard MacCutchan5-May-11 5:18
mveRichard MacCutchan5-May-11 5:18 
QuestionSearch Algorithm Pin
Cyclone_S16-Apr-11 9:22
Cyclone_S16-Apr-11 9:22 
Hi, I am coding an algorithm that searches for a box on the screen. So far I got the snake to find the food which works great except that for example. If the snake is moving right it will sometimes move left and move ontop of it's self. I've spent awhile trying to figure it out on my own with no success. I think it has to do with the two blocks of if statements but I'm not sure. Maybe they need to be combined somehow? This is the last thing I need to figure out and my program is finished. Thanks in advance.

I tried.

if(direction_comp!=1){direction_comp=-1;} else {direction_comp=2;}  // If snake is not moving left then move it right else move it up to avoid it from moving on top of it's self.


direction_comp of 1 = left;
direction_comp of -1 = right;
direction_comp of 2 = up;
direction_comp of -2 = down;



void comp_direction()
			{

				if(tick_comp==0 && avoiding==false)
				{
				if(segments_comp[head_comp]->panel->Left <= Food->Left)
				{	
					if(segments_comp[head_comp]->panel->Top >= Food->Top){direction_comp =2;}
					else{direction_comp=-1;}
				}
				else if(segments_comp[head_comp]->panel->Left >= Food->Left)
				{	
					if(segments_comp[head_comp]->panel->Top >= Food->Top){direction_comp =2;}
					else{direction_comp=1;}

				}
				if(segments_comp[head_comp]->panel->Top <= Food->Top)
				{
					if(segments_comp[head_comp]->panel->Left <= Food->Left){direction_comp =-1;}
					else{direction_comp=-2;}
					
				}
				else if(segments_comp[head_comp]->panel->Top >= Food->Top)
				{
					if(segments_comp[head_comp]->panel->Left >= Food->Left){direction_comp =1;}
					else{direction_comp=2;}
				}
				}
			}

QuestionRe: Search Algorithm Pin
bob1697216-Apr-11 10:28
bob1697216-Apr-11 10:28 
AnswerRe: Search Algorithm Pin
Cyclone_S16-Apr-11 14:10
Cyclone_S16-Apr-11 14:10 
GeneralRe: Search Algorithm Pin
bob1697216-Apr-11 18:52
bob1697216-Apr-11 18:52 
GeneralRe: Search Algorithm Pin
Cyclone_S20-Apr-11 10:58
Cyclone_S20-Apr-11 10:58 
GeneralRe: Search Algorithm Pin
bob1697220-Apr-11 19:06
bob1697220-Apr-11 19:06 
GeneralRe: Search Algorithm Pin
Cyclone_S21-Apr-11 15:45
Cyclone_S21-Apr-11 15:45 
GeneralRe: Search Algorithm Pin
Cyclone_S22-Apr-11 10:57
Cyclone_S22-Apr-11 10:57 
GeneralRe: Search Algorithm Pin
bob1697224-Apr-11 5:59
bob1697224-Apr-11 5:59 
GeneralRe: Search Algorithm Pin
Cyclone_S27-Apr-11 14:43
Cyclone_S27-Apr-11 14:43 
AnswerRe: Search Algorithm Pin
Luc Pattyn20-Apr-11 13:39
sitebuilderLuc Pattyn20-Apr-11 13:39 
AnswerRe: Search Algorithm Pin
AspDotNetDev20-Apr-11 14:12
protectorAspDotNetDev20-Apr-11 14:12 
GeneralRe: Search Algorithm Pin
Cyclone_S20-Apr-11 14:40
Cyclone_S20-Apr-11 14:40 
AnswerRe: Search Algorithm Pin
Stefan_Lang26-Apr-11 5:32
Stefan_Lang26-Apr-11 5:32 
GeneralRe: Search Algorithm Pin
Cyclone_S27-Apr-11 14:50
Cyclone_S27-Apr-11 14:50 
Questionconverting MFC program into web based Pin
shiks11-Apr-11 18:06
shiks11-Apr-11 18:06 
AnswerRe: converting MFC program into web based Pin
Albert Holguin11-Apr-11 19:13
professionalAlbert Holguin11-Apr-11 19:13 
GeneralRe: converting MFC program into web based Pin
shiks12-Apr-11 6:15
shiks12-Apr-11 6:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.