Emlyn Tech

December 28, 2008

The Clanking Replicators (game idea)

Filed under: Uncategorized — Emlyn @ 9:33 pm

A post to Open Manufacturing, regarding my game idea, The Clanking Replicators. A 2009 project. I think I’ll do the v0.1 in Python, and kill two birds with one stone.

Update: This is now in a wiki:
http://clankingreplicators.wikidot.com

Hi again all,

Paul wrote this:
> If you are getting into Flash, like with your pong game (nice sounds), a
> cool games about open manufacturing might be nice. Anything about making
> things. I have some ideas, but you might have better ones if you just think
> about it yourself first.

Ah well I *do* have a semi-manufacturing game/sim idea, which I’m
working on writing an intial spec for, and which I’m intending to get
started on in 2009.

This is a very geeky for-programmers-only game.

Has anyone here played any of the various tank or robot battle type
games that have come and gone over the years? Ones where you design a
tank/bot (choose weapons, armour, sensors, engine, etc etc), and write
a control program for it, then set it against others in a virtual
arena?

Examples:

http://www.mobygames.com/game/omega_

http://www.mindrover.com/index.html

http://robowar.sourceforge.net/RoboWar5/index.html

I used to have Omega, loved it, and I played a lot of Robowar at uni
in the mac labs.

Anyway, start with this idea in your mind. But then imagine a serious variation:

- What if this was an mmo?
- What if the bots had to find resources to “metabolise”?
- What if the bots could replicate?

Then, you’d have something approaching a life simulation. That’s what
I’m thinking of.

The general idea is this:

- There is a persistent online environment, made up of a multitude of
interconnected but relatively discreet battle fields or arenas. These
environments have resources in them (stuff you can dig up, stuff in
the air, sunlight, broken bot bodies), and are mostly flat and open.
- Players can spec up bots, including providing a control program.
They can test these locally in simulators, then they can inject them
into the online environment according to certain rules (possibly
putting them somewhere isolated to begin with so they can get a chance
to sort themselves out).
- The bots are composed of hardware modules, which all perform certain
functions (weapons, comms, manipulators, sensors, central processor,
etc), and have “metabolism” requirements (eg: energy requirements,
other material requirements, and might require repairs from time to
time).
- The bots can reproduce; ie: they can create new bots. This will
include providing the initial control program for the new bot, which
can be the parent bot’s own program, or something else.
- The control program should be represented as a string, or an array
of bytes, and should be self modifiable.
- Part of the environment will be “chat channels” which bots with the
appropriate comms hardware can talk on. So bots can collaborate fairly
easily.
- The control hardware should support powerful high level languages.
I’m thinking that a JVM, for J2ME, might be the ticket here, with the
bot hardware being accessible through a provided class library. So
then players can use any language for the game which can compile down
to j2me code, any dev environment they like, etc.

Now, when you look at an environment like the above, designed not for
a handful of simulated robots to run around in, but for really large
numbers of bots, you must immediately think “wow, that’s a lot of
processing required”. Yes!

The environment will be designed to scale to as much processing as can
be thrown at it. Think a 2D grid of connected battlefields. Over time,
each battlefield should support roughly the same number of bots, some
constant number. The processing scales, then, by the number of
battlefields growing or shrinking as resources are allocated and
deallocated. It might autoscale, trying to keep a constant ratio
between in-game time and real world time. Or, it might try to maximise
this ratio and just keep the world size constant. Or it might do a bit
of both.

The processing will be primarily based on volunteer computing. The
initial target for the world processing will be Boinc.

http://boinc.berkeley.edu/ .

One good thing about a game is you can make it artificially match the
constraints of volunteer computing; I aim to do this in the following
ways:

1: The game is temporally segmented (you can process from time X to time Y)
2: The game is geographically segmented (each battlefield is a world
of its own. you can travel between them, but this is constrained as
below)

Volunteer computing requires the ability to process discrete chunks,
and validate the results (you can’t trust the processing nodes). I
suggest doing this as follows:

1 – Cut processing into temporal+geographical chunks as above. One
unit of processing is for a set length of in-game time, on one
battlefield
2 – Movement between battlefields is constrained to happen only
between these chunks (ie: bots have to wait until the end of a time
segment to be moved)
3 – Within one chunk the game is *fully deterministic*.

The third point is important. The game is fully deterministic in one
chunk, and validation is performed by handing out the same chunk
multiple times, and bitwise comparing the results; they must match.

Also, to constrain the work to be done, everything in game must have
an in game time cost, including basic processing. So the JVM
implementation must enforce these time costs on all instructions. It
would need to be controllable from the sim engine where, at time T,
the engine would tell it “perform your next instruction and return the
time cost” (call this C), then the engine would not ask it to perform
another instruction until time T+C.

All these chunks would be assembled at a server, and the raw output of
the sim would simply be a rather stupendous log file, available
online. It might not actually be a file, I’m just using that as a
metaphor.

There need to be a LOT of tools for seeing in to the result log. These
would include action visualisation tools (where you can watch
historical action in “realtime”, maybe a flash front end?), as well as
lots of reporting type tools which can aggregate raw log information
and make it understandable, so for instance players can see how well
their bots are reproducing, all kinds of factors about resource usage,
etc etc, tools for seeing graphs of mutations where a player has
implemented a bot on which selection can occur over time, etc.

Finally, the whole thing must be open source. GPL or BSD style
license? I’m not sure. All of the above probably. Although I’ve
written about a centralised persistent environment, anyone should be
able to make their own server setup and have their own persistent
environment. Anyone should be able to modify the clients and boinc
plugins as desired. Nothing depends on binary code with hidden
secrets.

And, of course, I dedicate this idea in its entirety to the public
domain. Do with it as you will!

The Python Project

Filed under: Uncategorized — Emlyn @ 9:26 pm

The open source / free software world is the place to be. Period. Everything interesting is happening there now.

My main machine (currently a dell laptop) is the extension of my mind into infospace. I decided to remove Vista and replace it with Ubuntu. That’d be a couple of months ago now maybe. Two at most. I haven’t missed Vista.

But, using Ubuntu and actually being able to code on and for Linux are two entirely separate things. I feel so, you know, stoopid, because I just don’t have the background on this platform. I’ve got uni in the early nineties (alright, carrying through to 2000, but the early stuff was more and more important), and a few years being a bit adminy on Sco Unix (but I really didn’t know much about it). Then a lot of Windows, fast forward to now.

Firstly, you can go looking for detailed doco on how this platform works and you will quickly discover that code is king. The conversation is all in code. So, it’s time to get into the code.

A snippet from a recent post on Open Manufacturing (where I am talking to an individual, it’s to Paul Fernout on the OM list, who was talking about using Jython, which is Python compiled to the Java VM):

I see my choices grouped something like this:

- c/c++: Rusty, but I can bring these back up to scratch. Really, if
you’re doing stuff that doesn’t need to be close to the machine, these
are truly horrible languages (sorry for any offense in advance). But,
the global code conversation is largely happening in them, due to the
culture of Unix (and I think another surprising factor on which I’ll
post separately; it should be recognised that the vast new work being
done in such unproductive languages presents a quandary, on the face
of it, it doesn’t make sense for volunteers to waste time like that!).
So anyway, I do need to get back on top of C++ in particular.

- Dynamically typed “scripting” languages: I tried Perl a while back,
and still feel a bit dirty. However, Python looks decent at first
glance, and looks to have the benefit of being one of the few cross
platform choices, people are even building cross platform desktop apps
in it (eg: Miro). I take it that you like Python, being a Jython fan.
Why Jython rather than Java, btw?

- Statically typed high level OO Languages: That is, Java (that’s
about it in the open source world, no?) Java is a short leap for a c#
monkey, but seems to be terribly out of fashion. Why do people hate
the statically strongly typed languages so much? I can’t imagine
building something big without one. Probably this is a failure of my
imagination, but I’d like to know why.

- Functional languages: I only ever studied these at uni, I’ve never
used one in anger, but people are making intriguing noises about them
now that massively multi-core processors are on the horizon.
Certainly, traditional concurrent programming (ie:
thread/process/mutex/semaphore wrangling, what I spend a lot of my
paid life doing) is a big fail for mainstream software development.
Too hard, far too error prone. Functional languages, anyway,
beautiful, I’m intrigued at the possibilities of them wandering into a
practical toolkit.

I’ve since zeroed in on three choices; c/c++, Java, Python. First off the blocks is Python, basically because the more interesting people I’ve come across recently seem to be using it, and they appear to represent a healthy scene of people using code to make interesting stuff.

It’s not just home hackers, either. Google App Engine is solely a python platform atm and gives you amazing benefits if the doc is to be believed. I really need to get a piece of this!

So, I’ve started by

  • setting up Eclipse (point and click, thanks Synaptic Package Manager)
  • setting up Python (thanks again Synaptic)
  • setting up pydev for python development in Eclipse (and again Synaptic!) (and this helped me configure it)

I’ve HelloWorlded it, all good. Working python dev env with ide. Free. I clicked buttons and check boxes. Windows is so far behind this.

Oh, also Python really wants you to use it interactively, as well as in a “write code to file, run file” mode. Interactively is achieved by grabbing a terminal window, typing “python”, and pressing enter. Damned useful.

On to the learning: I started at python.org, and fairly soon found myself reading Dive into Python.

I’m a bit of the way in. It’s pretty good. Assumes you can already code, compares features to other languages a lot, nice. Has links to more detailed discussions of topics where he wants to move on, very good.

I’ll continue to post on this, but so far very interesting.

First really interesting thing I noticed:

I was playing with a fibonacci function from Dive into Python, and tried calling it with big numbers. It worked. The largest call that would work was

fib(999)

which I did in interactive mode (ie: in the terminal window), and it returned this:

40238726007709377354370243392300398571937486421071463254379991042993851239862
90205920442084869694048004799886101971960586316668729948085589013238296699445
90997424504087073759918823627727188732519779505950995276120874975462497043601
41827809464649629105639388743788648733711918104582578364784997701247663288983
59557354325131853239584630755574091142624174743493475534286465766116677973966
68820291207379143853719588249808126867838374559731746136085379534524221586593
20192809087829730843139284440328123155861103697680135730421616874760967587134
83120254785893207671691324484262361314125087802080002616831510273418279777047
84635868170164365024153691398281264810213092761244896359928705114964975419909
34222156683257208082133318611681155361583654698404670897560290095053761647584
77284218896796462449451607653534081989013854424879849599533191017233555566021
39450399736280750137837615307127761926849034352625200015888535147331611702103
96817592151090778801939317811419454525722386554146106289218796022383897147608
85062768629671466746975629112340824392081601537808898939645182632436716167621
79168909779911903754031274622289988005195444414282012187361745992642956581746
62830295557029902432415318161721046583203678690611726015878352075151628422554
02651704833042261439742869330616908979684825901254583271682264580665267699586
52682272807075781391858178889652208164348344825993266043367660176999612831860
78838615027946595513115655203609398818061213855860030143569452722420634463179
74605946825731037900840244324384656572450144028218852524709351906209290231364
93273497565513958720559654228749774011413346962715422845862377387538230483865
68897646192738381490014076731044664025989949022222176590433990188601856652648
50617997023561938970178600408118897299183110211712298459016419210688843871218
55646124960798722908519296819372388642614839657382291123125024186649353143970
13742853192664987533721894069428143411852015801412334482801505139969429015348
30776445690990731524332782882698646027898643211390835062170950025973898635542
77196742822248757586765752344220207573630569498825087968928162753848863396909
95982628095612145099487170124451646126037902930912088908694202851064018215439
94571568059418727489980942547421735824010636774045957417851608292301353580818
40096996372524230560855903700624271243416909004153690105933983835777939410970
02775347200000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000L

Python must have BigInt handling built in. I didn’t check the answer, I’m assuming python got it right. Because I’m lazy.

Also,

fib(1000)

failed, but only because of a recursion limit (it threw an explicit exception regarding this)

The result of the call was practically instantaneous. WTF?

Impressed.

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.