New Posts  All Forums:Forum Nav:

c++ random help?[solved]

post #1 of 7
Thread Starter 
I have no idea how to do the bold area. I had the idea of using a bool array and setting having it false for each unvisited edge but it seems too complicated for a variable size map/grid. Please help?

Quote:
After leaving a pub, a drunk tries to walk home, as shown in following Figure. The streets
between the pub and the home form a rectangular grid. Each time the drunk reaches a corner, he
decides at random what direction to walk next. He never, however, wanders outside the grid.

Write a program to simulate this random walk. The number of rows and columns in the
grid should be variable. Your program should calculate, over many random walks on the
same grid, how long it takes the drunk to get home on average. Investigate how this
number depends on the shape and size of the grid.

Modify the original simulation so as to give the drunk some memory to help him, as
follows. Each time he arrives at a corner, if he has been there before on the current walk,
he remembers what streets he has already taken and tries a new one. If he has already
tried all the streets from the corner, he decides at random which to take now. How much
more quickly does he get home?
Skylake
(10 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core-i7 6700K ASUS ROG Maximus VIII Hero EVGA GTX 970 4GB G.SKILL Ripjaws 4 32GB DDR4 2800 
Hard DriveHard DriveCoolingOS
SAMSUNG SM951 M.2 SAMSUNG 850 EVO Corsair H100i Windows 10 
PowerCase
SeaSonic G-750 Fractal Design Define R4 
  hide details  
Reply
Skylake
(10 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core-i7 6700K ASUS ROG Maximus VIII Hero EVGA GTX 970 4GB G.SKILL Ripjaws 4 32GB DDR4 2800 
Hard DriveHard DriveCoolingOS
SAMSUNG SM951 M.2 SAMSUNG 850 EVO Corsair H100i Windows 10 
PowerCase
SeaSonic G-750 Fractal Design Define R4 
  hide details  
Reply
post #2 of 7
Wow, seems intense. Maybe I'll work on this with you for my programming class...
Sweaty Fat Man
(13 items)
 
  
CPUMotherboardGraphicsRAM
x4 Phenom 965 3.8 GHz Asus M4A79XTD EVO X2 GeForce 9800 GT 512 MB OC 8GB (4 x 2GB) G.Skill 1600 DDR3 
Hard DriveOptical DriveOSMonitor
Samsung F3 1TB + 1TB F1 backup. DVD-RW Windows 7 Pro. 64-Bit Signature Edition 23" Samsung + x2 19" DELL Widescreen LCD 
KeyboardPowerCaseMouse
Logitech G110 Corsair CMPSU-650TX 650W LIAN LI Lancool PC-K62 Razer Copperhead 
Mouse Pad
Razer Goliathus Medium 
  hide details  
Reply
Sweaty Fat Man
(13 items)
 
  
CPUMotherboardGraphicsRAM
x4 Phenom 965 3.8 GHz Asus M4A79XTD EVO X2 GeForce 9800 GT 512 MB OC 8GB (4 x 2GB) G.Skill 1600 DDR3 
Hard DriveOptical DriveOSMonitor
Samsung F3 1TB + 1TB F1 backup. DVD-RW Windows 7 Pro. 64-Bit Signature Edition 23" Samsung + x2 19" DELL Widescreen LCD 
KeyboardPowerCaseMouse
Logitech G110 Corsair CMPSU-650TX 650W LIAN LI Lancool PC-K62 Razer Copperhead 
Mouse Pad
Razer Goliathus Medium 
  hide details  
Reply
post #3 of 7
the way i see it, you need to build a map with nodes and edges. each edge should be associated with 2 nodes. mark each edge with a false attribute. when he gets to a corner check each edge until he finds a false one. mark it as true and move to the other node associated with that edge. if all the edges are either true or false, pick an edge at random.

hope this helps and good luck
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
post #4 of 7
Thread Starter 
Quote:
Originally Posted by travesty View Post
the way i see it, you need to build a map with nodes and edges. each edge should be associated with 2 nodes. mark each edge with a false attribute. when he gets to a corner check each edge until he finds a false one. mark it as true and move to the other node associated with that edge. if all the edges are either true or false, pick an edge at random.

hope this helps and good luck
thanks, this is what I'm doing. it's troublesome to do it though.
Skylake
(10 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core-i7 6700K ASUS ROG Maximus VIII Hero EVGA GTX 970 4GB G.SKILL Ripjaws 4 32GB DDR4 2800 
Hard DriveHard DriveCoolingOS
SAMSUNG SM951 M.2 SAMSUNG 850 EVO Corsair H100i Windows 10 
PowerCase
SeaSonic G-750 Fractal Design Define R4 
  hide details  
Reply
Skylake
(10 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core-i7 6700K ASUS ROG Maximus VIII Hero EVGA GTX 970 4GB G.SKILL Ripjaws 4 32GB DDR4 2800 
Hard DriveHard DriveCoolingOS
SAMSUNG SM951 M.2 SAMSUNG 850 EVO Corsair H100i Windows 10 
PowerCase
SeaSonic G-750 Fractal Design Define R4 
  hide details  
Reply
post #5 of 7
building custom classes for map traversal is never fun. i wish there was an easier way.
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
post #6 of 7
2-dimensional array and backtracking ftw!
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 10 ASUS VS24AH-P 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 10 ASUS VS24AH-P 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
post #7 of 7
Thread Starter 
Quote:
Originally Posted by surfbumb View Post
2-dimensional array and backtracking ftw!
used a bool 2d dynamic array. worked fine.
Skylake
(10 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core-i7 6700K ASUS ROG Maximus VIII Hero EVGA GTX 970 4GB G.SKILL Ripjaws 4 32GB DDR4 2800 
Hard DriveHard DriveCoolingOS
SAMSUNG SM951 M.2 SAMSUNG 850 EVO Corsair H100i Windows 10 
PowerCase
SeaSonic G-750 Fractal Design Define R4 
  hide details  
Reply
Skylake
(10 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core-i7 6700K ASUS ROG Maximus VIII Hero EVGA GTX 970 4GB G.SKILL Ripjaws 4 32GB DDR4 2800 
Hard DriveHard DriveCoolingOS
SAMSUNG SM951 M.2 SAMSUNG 850 EVO Corsair H100i Windows 10 
PowerCase
SeaSonic G-750 Fractal Design Define R4 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming