Jump to content




[wip/fun] Ant Farm [v0.2]

game

  • You cannot reply to this topic
17 replies to this topic

#1 ben657

  • Members
  • 65 posts

Posted 16 November 2012 - 05:58 AM

Hello!

Recently I've been wanting to try out some basic game AI programming, but I've had no formal education in anything like that, so I decided what better way to give it a try than in computer craft?

Update:
The ants now prefer to dig tunnels, this gives a much nicer look to the program.
Once a certain percentage of the screen is tunnel, it will reset.

Pics:
Spoiler

Code:
Spoiler
Or a pastebin link for an easier to read version: http://pastebin.com/kpimQphs

All it does at the moment, is create two ants, which will wander around their farm, and dig up trails as they go along.
But this is only the very first step, i'm planning on having a nest with breeding and food mechanics, as well as maybe some predators.

Also, I'm looking on suggestions on what would be a nice way to interact with the farm? My main idea is to have red stone inputs which will allow you to add ants and such manually.

I suppose this could also be a good example of using basic objects, as the ants are all the same, but run different code for each of them.

Next up:
Some form of breeding to introduce new ants

#2 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 16 November 2012 - 06:34 AM

nice man. looks quite good. I have always been fascinated with simulating randomness, introducing trends and seeing if there is no way to make it predictable or even intelligent when it is really just a bunch of random chances. I built a basic game code where there are friendly, hostile and neutral mobs, friendly mobs follow you (at a small distance so they do not get in the way much) and run at hostile mobs, trying to surround them. hostile and neutral mobs run around randomly until a hostile mob sees a friendly one or the player (I implemented sight ranges and inability to see through opaque items) in which case he runs at them, there are spawn zones and everything but I got over it before I implemented item drops, inventories and damage etc. you are welcome to take a look if you like. here is the code...

TL;DR great idea man, keep working at it

#3 ben657

  • Members
  • 65 posts

Posted 16 November 2012 - 06:42 AM

View PostKaoS, on 16 November 2012 - 06:34 AM, said:

-snip-

TL;DR great idea man, keep working at it

Thanks! Like you, I've always loved looking at turning randomness into some sort of pattern, and simple little AI's like this are great fun to make!
Your program sounds pretty cool, I'll definitely take a look through it :P/>

#4 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 16 November 2012 - 06:52 AM

you know what you should do? try algodoo. It is a physics simulation. disable the default downwards gravity and add quadratic gravity effects to all matter, paste a few circles in and remove all simulation borders.... when I say a few I mean millions :P/>... what you get:

a simulation of a 2d universe with multiple circles acting as molecules, bundling together into planets and smashing into other planets, stealing their matter etc. also add a fairly high restitution (bounciness) to the matter to stop everything from forming into 1 big planet too quickly. it is a very fascinating program... also try liquefying matter and making planets with water atmopheres, if you can get a high enough rotation on those water particles you can make them orbit etc... all very fascinating

if only such complex things could be programmed in CC :)/>

EDIT: it never fails to fascinate me how out of random movement a stable orbit can be formed... physics and maths my friend, amazing stuff

Edited by KaoS, 16 November 2012 - 07:11 AM.


#5 Leo Verto

  • Members
  • 620 posts
  • LocationOver there

Posted 16 November 2012 - 07:41 AM

Nice program, going to try it out.
I like your idea of running this on a monitor and pretending it was a real ant farm.

#6 ben657

  • Members
  • 65 posts

Posted 16 November 2012 - 07:51 AM

View PostLeo Verto, on 16 November 2012 - 07:41 AM, said:

Nice program, going to try it out.
I like your idea of running this on a monitor and pretending it was a real ant farm.
Thanks, It's just me messing about really, but I thought it'd be nice for a screensaver when i'm not online on the server I play :P/>

#7 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 16 November 2012 - 08:39 AM

This is really neat. I like the basic concept behind it. It usually is the most simplistic things that make us happy.

#8 anonimo182

  • Members
  • 252 posts
  • LocationIn the universe

Posted 16 November 2012 - 09:41 AM

Nice program! Is just so random...

#9 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 16 November 2012 - 10:14 AM

And I was one of the first to know that they could dig now.... I was one of the guys on that server when you did it!

#10 ben657

  • Members
  • 65 posts

Posted 16 November 2012 - 10:21 AM

View PostCranium, on 16 November 2012 - 08:39 AM, said:

This is really neat. I like the basic concept behind it. It usually is the most simplistic things that make us happy.

View Postanonimo182, on 16 November 2012 - 09:41 AM, said:

Nice program! Is just so random...

View PostShnupbups100, on 16 November 2012 - 10:14 AM, said:

And I was one of the first to know that they could dig now.... I was one of the guys on that server when you did it!

Haha thanks all! :P/> by the way, shnupbups, if you see ikk on the server, could you ask him to delete my player file from the world? I can't log in due to me getting an error when i spawn :/

#11 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 16 November 2012 - 12:12 PM

View Postben657, on 16 November 2012 - 10:21 AM, said:

Haha thanks all! :P/> by the way, shnupbups, if you see ikk on the server, could you ask him to delete my player file from the world? I can't log in due to me getting an error when i spawn :/

Lol, that was literally just posted after he left the server!

#12 junithorn

  • New Members
  • 5 posts

Posted 17 November 2012 - 07:50 AM

Hello, this looks really cool and I'd love to try it out but I seem to be getting a "attempt to index ? (a nil value)"

at line 24

halp?

#13 ben657

  • Members
  • 65 posts

Posted 17 November 2012 - 08:31 AM

View Postjunithorn, on 17 November 2012 - 07:50 AM, said:

Hello, this looks really cool and I'd love to try it out but I seem to be getting a "attempt to index ? (a nil value)"

at line 24

halp?

Hmm, very odd... When does it happen? Are you trying on a monitor or just a pc?

I'm not on my computer right now, but I'll have a proper look soon once I'm on.

#14 junithorn

  • New Members
  • 5 posts

Posted 17 November 2012 - 08:39 AM

Using a monitor on top just like your picture, advanced computer, advanced monitors :)/>

#15 ben657

  • Members
  • 65 posts

Posted 17 November 2012 - 12:10 PM

View Postjunithorn, on 17 November 2012 - 08:39 AM, said:

Using a monitor on top just like your picture, advanced computer, advanced monitors :)/>

Hmm, still works fine for me... Well I'm planning on doing some work on it tomorrow, so I'll make sure to have a good poke around that part of the code and see if I can come up with anything.

Is anyone else having a problem?

#16 BigSHinyToys

  • Members
  • 1,001 posts

Posted 17 November 2012 - 12:18 PM

This could be a awesome screen saver. I have one set up in my world resets ever time a start the game interesting to watch.
This is a cool program.

#17 ben657

  • Members
  • 65 posts

Posted 23 November 2012 - 09:30 PM

Updated! see update section.

#18 Laserman34170

  • New Members
  • 34 posts
  • LocationProgramming Land

Posted 26 November 2012 - 05:51 AM

Awesome, I never expected for something like this to be so simple to code. Great job.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users