New Posts  All Forums:Forum Nav:

C++ help!

post #1 of 5
Thread Starter 
edit: don't need it anymore
Edited by Buster - 3/31/12 at 6:50pm
    
CPUGraphicsRAMHard Drive
Intel Core i7 4870HQ 2.5GHz AMD Radeon R9 M370X 2048 MB 16 GB 1600 MHz DDR3 1TB SSD 
OS
macOS Sierra 
  hide details  
Reply
    
CPUGraphicsRAMHard Drive
Intel Core i7 4870HQ 2.5GHz AMD Radeon R9 M370X 2048 MB 16 GB 1600 MHz DDR3 1TB SSD 
OS
macOS Sierra 
  hide details  
Reply
post #2 of 5
Ok here is the issue with your code:

after the program finds the first 'wrong' move that gets it stuck, it will backtrack one move. BUT when it checks for the next move it fails to remember that that first correct move was a wrong one.... thus making that same wrong move over and over and over and over and over....


Change the If-else structure to save all possible moves into a stack, pass that stack along with the function. Initially send it an empty stack, adding possible moves to it and then iterating through each until the correct path is found..... If there are leftover possible moves after it takes one... don't worry about clearing the stack as when it eventually backtracks it will get to them, if needed.....


I would re-write it for you, but you need to figure out how to do what I said above and you will learn more....
 
Tragbar
(14 items)
 
 
CPUMotherboardGraphicsRAM
Ryzen 1800X Asus Crosshair VI Hero Nvidia Geforce Titan X F4-3600C15D-16GTZ 
Hard DriveHard DriveHard DriveHard Drive
Combined: 6.13 TB of space Samsung SSD 960 EVO 500GB Crucial_CT1050MX300SSD1 M4-CT128M4SSD2 
CoolingCoolingCoolingCooling
EK-Supremacy EVO White Edition PrimoChill PrimoFlex Advanced LRT EK-RES X4 250 (R2.0) Reservoir EK-CoolStream XE 360 
CoolingCoolingCoolingOS
EK-Vardar F4-120ER (2200rpm)  EK-Ekoolant EVO Liquid Coolant EK-XTOP Revo D5 PWM Pump Windows 10 Pro 
MonitorKeyboardPowerCase
Asus VG278H Ducky YOTG Keyboard Corsair AX1200 Corsair Obsidian 800D 
MouseAudioAudioAudio
Logitech G700s Schiit Gungnir Multibit Schiit Mjolnir 2 Schiit LISST 
Audio
Audeze LCD 2 - pre fazor 
CPUMotherboardGraphicsRAM
intel i7 4770K ASRock Z87E-ITX Nvidia Geforce GTX Titan X GSkill F3-2400C10D-16GTX R 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro 512GB Silverstone 12.7mm Slot Load Blu-Ray Burner Noctua NH-L12 Windows 8 Pro 
MonitorCaseAudioAudio
LG PA75U Slim LED Projector Silverstone SG08 Schiit Bifrost Schiit Asgard 2 
AudioOther
AKG Q701 Headphones Pelican 1510 Green Case  
  hide details  
Reply
 
Tragbar
(14 items)
 
 
CPUMotherboardGraphicsRAM
Ryzen 1800X Asus Crosshair VI Hero Nvidia Geforce Titan X F4-3600C15D-16GTZ 
Hard DriveHard DriveHard DriveHard Drive
Combined: 6.13 TB of space Samsung SSD 960 EVO 500GB Crucial_CT1050MX300SSD1 M4-CT128M4SSD2 
CoolingCoolingCoolingCooling
EK-Supremacy EVO White Edition PrimoChill PrimoFlex Advanced LRT EK-RES X4 250 (R2.0) Reservoir EK-CoolStream XE 360 
CoolingCoolingCoolingOS
EK-Vardar F4-120ER (2200rpm)  EK-Ekoolant EVO Liquid Coolant EK-XTOP Revo D5 PWM Pump Windows 10 Pro 
MonitorKeyboardPowerCase
Asus VG278H Ducky YOTG Keyboard Corsair AX1200 Corsair Obsidian 800D 
MouseAudioAudioAudio
Logitech G700s Schiit Gungnir Multibit Schiit Mjolnir 2 Schiit LISST 
Audio
Audeze LCD 2 - pre fazor 
CPUMotherboardGraphicsRAM
intel i7 4770K ASRock Z87E-ITX Nvidia Geforce GTX Titan X GSkill F3-2400C10D-16GTX R 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro 512GB Silverstone 12.7mm Slot Load Blu-Ray Burner Noctua NH-L12 Windows 8 Pro 
MonitorCaseAudioAudio
LG PA75U Slim LED Projector Silverstone SG08 Schiit Bifrost Schiit Asgard 2 
AudioOther
AKG Q701 Headphones Pelican 1510 Green Case  
  hide details  
Reply
post #3 of 5
Thread Starter 
would it work if I just pass the array instead of using the the global array ? Will the array be pass by value ?
    
CPUGraphicsRAMHard Drive
Intel Core i7 4870HQ 2.5GHz AMD Radeon R9 M370X 2048 MB 16 GB 1600 MHz DDR3 1TB SSD 
OS
macOS Sierra 
  hide details  
Reply
    
CPUGraphicsRAMHard Drive
Intel Core i7 4870HQ 2.5GHz AMD Radeon R9 M370X 2048 MB 16 GB 1600 MHz DDR3 1TB SSD 
OS
macOS Sierra 
  hide details  
Reply
post #4 of 5
Thread Starter 
I don't really understand what you are saying. On my program, the user picks a starting position then the program will try to solve the puzzle from that starting position. If it failed then no solution else print solution.
    
CPUGraphicsRAMHard Drive
Intel Core i7 4870HQ 2.5GHz AMD Radeon R9 M370X 2048 MB 16 GB 1600 MHz DDR3 1TB SSD 
OS
macOS Sierra 
  hide details  
Reply
    
CPUGraphicsRAMHard Drive
Intel Core i7 4870HQ 2.5GHz AMD Radeon R9 M370X 2048 MB 16 GB 1600 MHz DDR3 1TB SSD 
OS
macOS Sierra 
  hide details  
Reply
post #5 of 5
Hey man, leaving your problem up will help others in the same situation one day.
2009
(15 items)
 
   
CPUMotherboardGraphicsRAM
i7 920 4.0Ghz 1.20v golden? Asus p6x58D Premium 770gtx Windforce OC ocz gold 1600 8-8-8-24-74-1T 
Hard DriveCoolingOSMonitor
x25-m80G2 Black640 H100 GT AP-15s Windows 7 Pro. 64 bit Dell U2410 1920x1200 IPS 
PowerCaseAudio
corsair tx 850 antec 1200 SoundBlaster ZX 
CPUMotherboardGraphicsRAM
Intel i7 3720qm(ivy) 2.6 Sager GTX 670m 8 gig 
Hard DriveKeyboardPower
80gig mssd steel series Huge power brick 
  hide details  
Reply
2009
(15 items)
 
   
CPUMotherboardGraphicsRAM
i7 920 4.0Ghz 1.20v golden? Asus p6x58D Premium 770gtx Windforce OC ocz gold 1600 8-8-8-24-74-1T 
Hard DriveCoolingOSMonitor
x25-m80G2 Black640 H100 GT AP-15s Windows 7 Pro. 64 bit Dell U2410 1920x1200 IPS 
PowerCaseAudio
corsair tx 850 antec 1200 SoundBlaster ZX 
CPUMotherboardGraphicsRAM
Intel i7 3720qm(ivy) 2.6 Sager GTX 670m 8 gig 
Hard DriveKeyboardPower
80gig mssd steel series Huge power brick 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming