1

I'm trying to build a machine in Minecraft that will act similarly to an array. It will be implemented using physical blocks, not using a traditional redstone CPU type architecture of redstone signal 1s & 0s. It will be a collection of like-sized cells (say 3x3x3) and I would like to be able to "access" any cell at random. My needs for accessing the cells can be satisfied by either travelling to the cell using the tp command or by using the clone command.

I've given some thought to this and could only come up with a sequential access solution on my own. I've attempted to find documentation on how random access is implemented in computers, but I didn't take Data Structures and Algorithms in college and am unsure of what to search for :P Besides that, there is the in-game limitation of not being able to specify a variable for the tp or clone command.

The best solution I've come up with so far is to have the addressing work sequentially, by assigning two scoreboard objectives to a minecart. The first objective would be the desired address of the cell and the second would be the cart's current address location. Then, the cart would be tp'd ahead by the offset (3 blocks), the current addressobjective would increment, the cart's current address would be compared to the desired address. If the cart's address was lower, then it would be tp'd to the next offset, where the process would repeat. Otherwise, the process will have been completed and the minecart will reset itself by some arbitrary process.

So for example:

- array starts at address 0 along the X axis (X=0)
- cells are offset by 3 blocks
- minecart starts at address 0 (A=0)
- we want the cell at address 4 (D=4)

1 set the desired address objective for the minecart (D=4)
2 set the current address objective for the minecart (A=0)
3 tp the minecart ahead by the offset (A=0,X=3)
4 increment the minecart's current address (A=1,X=3)
5 compare the minecart's current address to the desired address (A=1<D=4)
6 A<D => repeat steps 1-5 until A==D
7 COMPLETE => reset minecart

Does anybody know of a more efficient way to achieve this goal? Can anybody think of a way to implement Random Access here, so that each cell can be accessed equally as fast as each other cell? Alternatively, can anybody think of a way to improve my Sequential solution?

4
  • Is this different from How can I make a Random Number Generator with vanilla redstone? Commented Feb 2, 2015 at 7:25
  • 1
    @SevenSidedDie I didn't thoroughly read this question but it seems that this question is about RAM.
    – Q20
    Commented Feb 2, 2015 at 11:09
  • 1
    Yes it is different.
    – Johonn
    Commented Feb 2, 2015 at 15:44
  • Is it possible to send the minecart down the track with a fill clock that will tp the minecart down quickly?
    – Moddl
    Commented Feb 3, 2015 at 0:51

1 Answer 1

1

So here's an idea (and I haven't tested it yet, but hear me out): you put a minecart on a line of powered rails with some power source on them all (nearby redstone blocks, torches, whatever). This rail travels past all your locations. When you want to get to a certain place, you use a command block with /setblock to replace the powered rail at your desired location with a solid block, and the one in front of it with an unpowered rail. Then push your cart--you'll continue down the rail until you hit the new wall and stop when you get to your destination. To reset it, you can just fill the rail row with powered rails again (using the replace parameter to only replace unpowered rails and your stopping block, for safety); then push the cart back to the start (which, by the way, the first rail should have no constant power source and only be powered when you want to access something).

Or, if you want an auto-reset, you could even use setblock to spawn a command block above your stopping block which tests for the presence of a nearby cart, run that into AND gate with another (always-present) block which tests for the presence of a nearby player and inverts that, and when the output turns on, run the reset circuit (which would /tp the cart to the beginning again, fill the track up with powered rails, and clear out the new command block).

Maybe there's a more efficient way of doing this, but I think it should at least work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .