My class has been working through the Treasure Hunt STEM Lab, and we have made it to the final Treasure Hunt competition. We are currently stumped on how to code the robot to know where to drop the randomly-placed red cube and how to code the robot so it will know where to go to check the next cube. Any advice or code snippets would be appreciated!
Hi @Jonathan_Haynes! Absolutely! I’ll make you a solution and then ping you here once it’s ready
Hi @Jonathan_Haynes! Here is an example solution and a video of it in action, please let me know if this helps!
Treasure Hunt Competition Solution.iqblocks (14.6 KB)
@Lauren_Harter this is super helpful! Thank you for taking the time to create this code and video.
Absolutely! Please let me know if you need anything else
This is very helpful. Is there another way to code for this challenge.
Hi @Maria_Brinza! To better understand what you’re looking for, when you say code another way, what exactly do you mean?
Are you looking for the use of certain Computer Science concepts?
Thanks
@Lauren_Harter I know this is from a while a go but my class is currently stuck on treasure hunt. Are you able to give me more details about the code and how you made the “block” variable?
Hey Lydia,
I’ll be happy to share my code with you. This is the first unit I teach in my grade 7/8 robotics elective.
Hi! The block variable in the project Lauren shared can be made in the Variable section of the toolbox in VEXcode.
When you make a variable, you can name it whatever you may want as long as it follows certain naming guidelines (listed here).
In the code, the block variable is used to keep track of how many of the Cubes the robot has checked the color of. Since we know the length of the Field and the number of Cubes in the final competition, the variable helps calculate how far to drive to get to the exit to deposit a red Cube and where to go back to in order to check the next Cube color.
Happy to talk through anything else in the code as well if you have more questions