I'm working on a planet with robotic life, until now I think I know how they work, the only problem is that, unless I want to make all lifeforms autotrophic, I have no idea how the energy might move across the food web. By this I mean how the energy the plants store might power the 'herbivores', and the energy the 'herbivores' collect might power the 'carnivores'. The only solution I have to this problem is not having any energy movement, making all creatures capable of producing their own energy, but I don't like the ecosystem to be like that, so I'm just asking if there would be another solution to this problem.
Rather than making herbivores/carnivores for the sake of having herbivores/carnivores, let's consider some reasons why it's not optimal to make all robots autotrophic. I'm making the assumption that your robo-ecosystem primarily thrives on the following direct sources of power: the sun, nuclear energy, chemical fuel, and physical forces (which are indirectly cause by the sun). In most of the aforementioned, your energy producers are not going to be the dexterous sort of robots seen on Jimmy Neutron. It's just not optimal to produce energy in a machine that has to move around all the time. Coral-like tidal power robots may only move every decade or so to follow the long-term oceanic current shifts. Chemical plants need to get very big to approach the Carnot limits on thermodynamic efficiency. In particular, nuclear fusion robots are likely to be more sensitive and bulkier than the rest.
However there are some noteworthy exceptions: If your planet is similar in triboelectric properties to Earth, then static potential differences may regularly build up across large distances separated by insulators. However, since we're "working on a planet with robotic life", then maybe its chemistry is tuned for such an existance: snowstorms with snowflaskes made of nylon and silicone may do the trick.
Unlike bulky producers, predator robots are not constrained by the same efficiency curves, so you can imagine a sort of parasitic symbiosis between the producers and consumers with the ladder tapping into the formers' power supplies, and the former designing defensive and offensive countermeasures, even employing other robots to defend them in exchange for power.
Of course, this begs the question: why are these robots even trying to eat each other? There must be scarcity of physical resources which are most easily satisfied by preying on other robots. Since we're "working on a planet with robotic life", metals may already be abundant, but processors and other high end electronics...? It seems logical that energy producers would want to use their energy to run computations. Therefore, a correlation may be found between power production and consumption.
Finally, it's worth noting that zoological autotroph/heterotroph, herbivore/carnivore/detritivore, etc. distictions may not be the most appropriate in clasifying your robots. The autotroph/herbivore distinction breaks down when you have mining robots work for a power plant robot.
If you're talking about robots, you aren't talking about a food chain, you're talking about an energy economy. It is far easier to extract energy from the sun if you don't have to move, but it's impossible to extract resources from the world. Thus, energy generating robots would trade energy for materials with resource harvesting robots.
You're probably heard terms like "hydrogen economy," where power is converted to compressed hydrogen, and traded. Any energy base (electricity, compressed air) will work for this. Maybe they convert it to sugars.
If the robots have free will, then there will be those who optimize for theft and/or parasitism. It's just an inevitable side effect of game theory. You can model everything after the variations in a standard economy.
Let's start by asking: why are these robots even eating each other in the first place? Since we're "working on a planet with robotic life", metals, semiconductors, and other raw materials may already be abundant, but processors and other high end electronics...perhaps not? You see, these electrionic goods have already gone thorugh the value chain and are equivalent to many more times their weight in raw material. However instead of going through an economic value chain, they go through an ecological food chain.
Next, what is energy used for? Consider humans: for an organ weighing less than 3% of the body's mass, the brain consumes a whopping 20% of basal metabolic rate. The body practically worships the brain: it is one of the last organs to stop recieving energy during starvation. We might expect similar and even more exagerrated trends in intelligence robots: energy is for computation, and computation is for obtaining more energy. It follows that processor-rich targets regularly consume a large amount of energy while low-tech robots generally do not.
The converse may not necesarily be true: your planet may have nuclear fusion reactors, tidal power 'reefs', and other 'gentle giants' which produce a lot of energy but are only kept in existance because of parasitic symbiotic relationships.
Plants produce fruit/ power cells
Plant robots feed off energy sources like volcanoes, the sun, rich chemical deposits, lots of things. They produce fruit, which have nanobots on them that will form more bots. Their power cells are mostly in the form of low energy density graphene batteries.
Herbivores eat plant power cells and use them to charge their cells.
Herbivores eat these power cells, and then spread the plant's nanites outwards. They get extra power which they use to power their ethanol based power cells. This allows them to store power more densely and burn it for quick bursts of energy. Some power is lost, but they still have a lot.
Predators eat herbivore power cells to power hydrogen fuel cells.
Predator bots eat herbivore power cells and convert them into their mega dense hydrogen fuel cells. This allows for them to have powerful and intense bursts of speed, but at the loss of some degree of power.
Really. Ignore energy. Assume robots are all able to provide their own power.
The only thing that matters is raw materials, for building new appendages / reproducing. When robot A eats robot B, it probably doesn't care how much energy it has stored, it just wants B's lithium and semiconductors.
Let's look at a few reasons robots might want to eat (or at least hunt) others:
Being a predator lets you stay active all day
Sure you could be a boring robot and harvest solar energy. But this is not a very high power density. A car takes about 1L of gasoline to run 12 km. To have enough energy for a measly 1km ride, a robot with ideally efficient solar panels of 1m2 in perfect weather conditions will need to charge for almost 3 hours. You're really spending most of your day napping, and you're not going places. Then there is the night problem. We're not very good at storing electric energy. So at night you're mostly sleeping, too.
The same problem is going to arise for pretty much all renewable sources: low energy density + not available on demand. That would result in huge (which in turns consumes more power) and not very active robots. If your planet ran out of fossil fuel, generating your own energy makes you... essentially an easy prey. Predatory behaviors then seem like an efficient strategy (although it's more likely that being parasitic will give you better results; steal some batteries but don't kill the giant autonomous power station)
If you do have fossil fuel/nuclear energy, it is a bit harder to justify unless those resources are scarce enough to explain hunting for gasoline. But being dependent on fossil resources would probably lead to sedentary behaviour (you stay near that yummy puddle of oil that you found). That could still leave room for predatory nomadic species of robots.
it's not about nutrition, it's about population control
A robot can only last that long. Electronic components will oxidize, mechanics parts will rust, break, etc... So the god-engineer who designed robotic life programmed the robots to "recycle": every robot seeks to produce another robot of his own species every 5 years (you don't want to have robots only making one copy, because your population will go down every time a robot breaks before reproduction, leading to an unevitable statistical extinction).
With every robot potentially making several copies, you need to avoid overpopulation, so hunting robots are designed. They are hunting primarily the older robots close to failure. There you have your predatory chain of recylcing robots. The predators also reproduce. They are not hunted, but if they grow too numerous, they will start starving(they don't have any other mean of energy generation), thus a carefully planned equilibrium is reached (see prey-predator models)
N.B: You could have other, more ideal systems to maintain a fixed population. For example, just have the other robots build a new friend every time they detect a robot death in the world. But that would require for all robots to be connected and cooperating as a society. You could find a few reasons why this is not the case
getting resources is not hard, but crafting is a highly specialized task
Ok, maybe you have abundent fuel, but you still need to refine it. You have enough copper, silicon, etc but turning it into a processor to change yours or reproduce is another story. Those manufacturing processes are pretty complex and robots as we design them are usually good at one thing, not 1000. Very dexterous robots are unlikely to have a factory built inside them. So they need help from other robots. Sure enough you could do that in a peaceful way and build an economy around it... but if the processor-generating robots reproduce fast enough and are not very mobile, it's definitely easier to rip them open and get the goods directly.
So it's not so much a herbivor/carnivor dichotomy, it's more like you have specialized manufacturing units, and jerks who just take what they produce when they need it. The frequency of hunting in those conditions would be signifcantly lower tho (you might not need to hunt for a new processor before 10 years. Might be more regular if we're considering fuel)