Allegro.cc - Online Community

Allegro.cc Forums » The Depot » Food Chain Farm week

This thread is locked; no one can reply to it. rss feed Print
Food Chain Farm week
amarillion
Member #940
January 2001
avatar

Hey Everybody

For a while now, I'm working on a game called Food Chain Farm. In this game, you have to connect farm animals and plants to form a cycle, each providing nutrients for the other. It's a resource management game with an educational angle. See also this
previous thread and this thread before that. You can download the game in its current form here

This whole week I'm going to make a major effort to get the game closer to release. I took the week off so that I can completely focus on it.

Here is what I plan to do this week:

  • Add at least one new level with a completely new mechanic

  • Improvements in the simulation engine to solve some nagging problems (more on this later)

  • Build pipes by dragging with the mouse

  • I'm adding a full 8 minutes of original music

  • Major overhaul of the art style

Elaborating a bit on the art style: This was recurring feedback I got on previous versions. One thing that was said, was that the backgrounds seemed out of place: the style of the backgrounds does not match the style of the rest of the game.

So I've been trying to draw backgrounds in inkscape. I'm trying to find the right style here. What do you think of this?

New, hand-drawn style in inkscape:
{"name":"612108","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/c\/5c4826c981d26ce2fe494f1880b28c18.png","w":1920,"h":1200,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/c\/5c4826c981d26ce2fe494f1880b28c18"}612108

Original, photographic style (actually a public domain image from NASA)
{"name":"612109","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/0\/b070a8836478a3dfa8f5f92a7fd9a813.jpg","w":1920,"h":1311,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/0\/b070a8836478a3dfa8f5f92a7fd9a813"}612109

So what do you think, is the new style better? Of course you have to really see it in combination with the rest of the game. I'll post more screenshots later.

I'm going to put updates here the whole week, speedhack-log-style. So please bump this thread once in a while so I can continue posting :) Oh and of course, stay tuned for the release which should happen around next weekend.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

amarillion
Member #940
January 2001
avatar

The only thing I want is to be able to zoom out far enough to see everything at once.

All right, I'll increase the maximum zoom level :) Is that the only thing you want? The only thing? No new levels, graphics, game modes?

That's not what I did today though. Today I dived deep down in graph algorithm theory.

I'm trying to find the best flow through the pipe system. You see, I want to make it so you can freely build pipes, and resources should always find their way. I don't want the player to have to spend a lot of time thinking about how to optimize the pipe system. On the other hand, I do want the player to think about what goes where. The whole point of the game is to learn the idea that animals consume oxygen, and plants produce oxygen. If you can just mindlessly connect things up, then you learn very little.

A simple scenario is as follows:


tree      pig
 |         |
 +--->->---+

This situation is simple. Oxygen flows from the tree to the pig, and there is only one possible direction the oxygen can flow.

More difficult is this scenario:


tree1  pig1   tree2  pig2
 |      |      |      |
 +--->--+--?---+-->---+

In the middle section, oxygen can flow both ways! For example, oxygen could go from tree2 to pig1 to the left, or from tree1 to pig2 on the right.

Current version of the game allows this, and you can frequently see resources move through each other in opposite direction. But I want to change this. I want to disallow counter flow. It shouldn't be an absolute ban though. What I want to do is create some kind of "turbulence" in the pipe where such counter flow occurs. The resources still get to their destination, but it will be much slower.

The problem now is that I want the game to identify sections of the pipe network where this counter flow could occur. I managed to write an algorithm for this. And it works... just not very fast. I did some performance testing with randomly generated networks of various sizes. Here is the speed of the counter flow identification algorithm in milliseconds:

10 nodes: <1 msec
20 nodes: 1 msec
40 nodes: 2 msec
80 nodes: 375 msec
160 nodes: 22.2 sec
320 nodes: 30 minutes :o :o :o

Clearly this needs a bit of improvement or the game will be severely limited in level size.

(P.S. please bump for tomorrows update)

bamccaig
Member #7,536
July 2006
avatar

The Linux build doesn't appear to be working for me. A graphical dialog is shown after a second that reads:

Quote:

Error: Uncaught Error: This browser does not support webGL. Try using the canvas renderer
Error: This browser does not support webGL. Try using the canvas renderer

After clicking "OK" it just seems hung doing nothing, still displaying "Loading..." in the top left corner. There is a vertical scroll bar, and if I scroll down the background changes from a picnic table cloth to what looks like a incomplete menu widget on the left (thin grey bar with what looks like an empty title bar and textbox at the top of it).

I didn't see a readme or anything in the archive so I don't know what dependencies I need to install, etc.

amarillion
Member #940
January 2001
avatar

Quote:

Error: Uncaught Error: This browser does not support webGL. Try using the canvas renderer
Error: This browser does not support webGL. Try using the canvas renderer

Yes, WebGL is required. The game is based on javascript + electron, which means that the chrome browser is included as runtime.

Apparently the chrome instance can't use OpenGL on your machine. Could you think of a reason why this might be? Maybe something to do with video drivers?

I can't work around the need for WebGL/OpenGL. I will make a note to improve the error message in this situation though.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Hi Amarillion!

No, of course that's not the ONLY thing I want but its the first most important to me. I NEED an overview of the field so I can plan my routes.

About your flow problem :

More difficult is this scenario:

tree1  pig1   tree2  pig2
 |      |      |      |
 +--->--+--?---+-->---+

In the middle section, oxygen can flow both ways! For example, oxygen could go from tree2 to pig1 to the left, or from tree1 to pig2 on the right.

I would say tree1 should only flow to pig1, and tree2 should flow to both.

If you apply the principle that a pipe can only flow forwards then the decision is easy.

BUT if you allow 'backflow' or 'diffusion' it's different.

What you could do is base the direction of flow on "pressure" in the tube. When a tube hits a turn, the pressure turns (it's a vector) and is deflected towards one or both (or all three) directions forward. Then if it meets pressure in the opposite direction it stops or reverses if the total indicates as much.

Just me thinking out loud about how you could solve your flow problem.

When I was a kid, I won a contest from Bullet Proof Software where you had to find the maximum flow through a pipe puzzle. I was so proud. They are now known as Blue Planet Software.

OOH, here it is : https://en.wikipedia.org/wiki/Pipe_Mania

An easier solution to the mouse drag pipe laying problem could be to allow the user to draw lines of pipe, or pick a start and destination and have the game hook them up automatically.

amarillion
Member #940
January 2001
avatar

I would say tree1 should only flow to pig1, and tree2 should flow to both.

If you apply the principle that a pipe can only flow forwards then the decision is easy.

That's possible, but the downside is that resource distribution would be unequal. With no way to equalize resources, eventually you can risk deadlock again as was common in version 0.1. The solution I applied to solve deadlocks requires that it's possible to distribute resources to the furthest reaches of the pipe network.

Quote:

What you could do is base the direction of flow on "pressure" in the tube. When a tube hits a turn, the pressure turns (it's a vector) and is deflected towards one or both (or all three) directions forward. Then if it meets pressure in the opposite direction it stops or reverses if the total indicates as much.

Yes, I tried this solution as well, and it's an improvement. But it's difficult dealing with cycles.

For example, if there is a cycle like this:

  tree1            pig1
   |                |
   +----------------+
   |                |
   |                |
   +----------------+
   |                |
  pig2             tree2

There is an obvious (to humans, not to computers) solution here: create a circular flow and resources can be distributed everywhere. In fact, this is the best strategy to always have a network with a nice flow, just put everything on a cycle!

  tree1            pig1
   |                |
   +-->---->---->---+
   |                |
   |                |
   +--<----<----<---+
   |                |
  pig2             tree2

However, a pressure-based solution would most likely get clogged up on both sides, as below. I haven't been able to figure out a solution for this that doesn't involve a more complex algorithm, like the one I'm writing now.

  tree1            pig1
   |                |
   +-->----><---<---+
   |                |
   |                |
   +-->----><---<---+
   |                |
  pig2             tree2

Quote:

Just me thinking out loud about how you could solve your flow problem.

Thanks! I admit my current approach is very complex, so if you find an easier way to solve it that would be fantastic! But there are a lot of corner cases to take into account.

I wanted to share some more graphics I made for the game here but allegro.cc is having a hard time with uploading images at the moment. So instead I'll link to these videos

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

OOH! I've got an awesome idea!

What if instead of pressure, you measured vacuum! A pig creates a vacuum for oxygen. A plant creates a vacuum for CO2! And then it's just a matter of backpressure! Work it out backwards! :)

I hope that idea isn't as crazy as it sounds.

amarillion
Member #940
January 2001
avatar

I hope that idea isn't as crazy as it sounds.

Maybe it's just crazy enough :) I'll play around with it but I think I'm close to a solution anyway!

I made some progress and wanted to show another screenshot. But I can't upload any attachments anymore. Allegro.cc is really going downhill isn't it?

edit: Let's try again via twitter: screenshot

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: