Re: Robot challenge
- Posted by Hawke <mdeland at NWINFO.NET> Nov 08, 1998
- 544 views
Lucius Hilley III wrote: >It returns a sequence while it is still alive >When my bot quits searching and is dead it returns an atom. ok.... > draw_maze() > integer busy > object bot > busy = 1 > bot = {{24, 24}} --starting point > while busy do > if sequence(bot) then > pixel(BLUE, bot[1])--erases bot > bot = lucius(bot) > if atom(bot) then > if bot then > pixel(RED, bot[1])--bot reached RED > else > pixel(BLUE, bot[1])--bots dead REMOVE carcus > end if > end if > end if ummmm i was trying to follow this, make sense of it... but i'm having trouble because of this section of the example... > if atom(bot) then > if bot then > pixel(RED, bot[1])--bot reached RED > else > pixel(BLUE, bot[1])--bots dead REMOVE carcus > end if first you test if bot is an atom, and if it _IS an atom_, you pass bot[1] to pixel(). now, if we agree that an atom is a length 1 sequence, then bot[1], when atom(bot) is true, is a single digit, either real or integer, and passing a single digit to pixel() (ie:pixel(color,bot[1])) in the parameter location you're placing it, won't work because that parameter is a coordinate sequence pair. now, if we agree that an atom and a length 1 sequence are NOT the same thing, then, when you test for bot being an atom, and it passes, you will subsequently attempt to subscript an atom by passing bot[1] to pixel(). (and the latter is what i believe will happen, and what i believe is the correct interpretation) so, with this in mind, i'm having trouble following how bot=lucius(bot) would work... perhaps, if we modified things a wee bit... constant DEAD = 0, FINISHED = 1, WORKING = 2 integer busy,flag sequence bot,pos busy = 1 flag = WORKING pos = {24,24} bot = {flag,pos} --now, to tend to your other passed back parameters, just --append them to the end of the above, making sure that --you always returned a minimum of a length 2 sequence --that held {flag,pos} and your parameters *after* that while busy do pixel(BLUE, pos)--erases bot bot = lucius(bot) flag = bot[1] pos = bot[2] if not OnScreen(pos) then --Error("bot went out of bounds, tsktsk") end if if flag = DEAD then --bots dead REMOVE carcus pixel(BLUE, pos) elsif flag = FINISHED then --bot reached RED pixel(RED, pos) elsif flag = WORKING then --bot's cogitating, *sniff* sthmoke! pixel(BRIGHT_WHITE, pos) else --Error("we're not real sure what the bot is doing") end if --he is less than working, ergo:lounging or comatose --and the memo said that comatose and deceased was no reason --not to be working... busy = flag < WORKING end while implementing it this way will also allow for multiple bots... ----although, here, i would have a sinking feeling that all ----of the bots would take the same path & make the same ----decisions because they all start at the same place and they ----all pass thru the same function... unless, lucius, do you ----have some sort of weighting or randomosity to your algorithm? ----something to ensure that (nearly) no 2 bots will travel the same? allbots = repeat({flag,pos},numbots) for i = 1 to numbots thisbot = allbots[i] thisbot = lucius(thisbot) flag = thisbot[1] pos = thisbot[2] and so on.... just like your other half of your email... so, was this what you had in mind? something vaguely similiar? cuz, if not, i'm not real sure i understand what you're say then... --Hawke'