Programmers: script help required

Both kinds of script. I’m currently writing a short animated film and I need a character to say something in a generic programming language. The gist is that he’s a robot bounty hunter looking to kill or capture a murderous cannibal forest witch, who is the protagonist of the film. He only appears in one shot and it’s just one short line, but if I decide to use it you get a credit: either in the ‘special thanks to’ section or with a puffed-up ‘Programming consultant’ title.
Basically, I need him to say something like “Seek (character’s name). If (character’s name) is found execute ‘terminate’ program” - sort of like that, but feel free to spice it up with repeating loops or whatever. I’m a complete rube when it comes to this sort of stuff and I’d really appreciate some assistance. Thanx!

The death robots of the future will be programmed in C++.

void hunt( const std::vector<std::string>& names )
{
	for( std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i )
	{
		Location loc = seek( *i );
		if( loc.found == true )
		{
			execute( *i, loc );
		}
	}
}


int main()
{
	std::vector< std::string > names;
	names.push_back( "Theodore Rex DX" );
	hunt( names );
	return 0;
}

The definitions of seek() and execute() are left as exercises to the reader.

C++? How about PASCAL?

Repeat
   {
   located := Search(witch)
   }
   Until (located=True)
destroy(witch);

“For each NameString in AllNamesSet, if NameString equals Bob call self.Kill(Bob)”

pseudocode! It should also be in giant writing on a hollywood pseudoOS!

While seekingm just do:

seek (charactername);

It must blink and be in the 70s computer/checkbook font.

Occasionally flash up:

if (charactername == located) {

expunge (charactername);

}

And when the character is found, have everything disappear except the “Expunge” line, which must increase in size and flash insistently while an internal alarm sounds.

Dammit, I don’t remember enough GW-BASIC to do something fun. Any LISPers want to take a shot, that should be amusing. Or if you want to be hardcore, some Forth or APL.

XPav’s post is a reminder why I hate C++ with an undying fury.

Basically, I need him to say something like “Seek (character’s name). If (character’s name) is found execute ‘terminate’ program” - sort of like that, but feel free to spice it up with repeating loops or whatever. I’m a complete rube when it comes to this sort of stuff and I’d really appreciate some assistance. Thanx!


if (Witch_Season) or (whichWitch.Wanted==True) {
        while (charname.IsAlive) and (whichWitch.Friends.Local.Armed.Present==False){                shoot_mash_shoveoven_poison_splashwater_drophouse(charname)
        }

        Take_flight.setEqualTrue()        
}


blah blah


if (Witch_Season) or (whichWitch.Wanted==True) {
        while (charname.IsAlive) and (whichWitch.Friends.Local.Armed.Present==False){
                shoot_mash_shoveoven_poison_splashwater_drophouse(charname)
        }

        # witch friends armed code added after alpha LV426's 'toad in nozzle' incident
        Take_flight.SetEqualTrue()          
}


It’d be amusing to try and get the old Looking Glass test cases in there:
“Spot player, Nearby Friends, Reacquire True.”

  • Alan

Give me a few minutes tonight and I’ll pull out functors and std::foreach!

With C++, typedefs are your friends. Yeah, that code I wrote is scary.

But…


typedef std::vector<std::string> Names;

void hunt( const Names& names )
{
	for( Names::const_iterator i = names.begin(); i != names.end(); ++i )
	{
		Location loc = seek( *i );
		if( loc.found == true )
		{
			execute( *i, loc );
		}
	}
}


int main()
{
	Names names;
	names.push_back( "Theodore Rex DX" );
	hunt( names );
	return 0;
}

I’ll also write one in Ruby. That should be fun.

You know, if you want to go all high-tech, you need to do a bunch of scrolling binary crap, ideally in the matrix style of ‘individual columns scroll at different rates’. Or random 6502 monitor output from an Apple II^H^H][, that shit was always impressive looking.

For the love of God, don’t try to be clever by putting in some hee-hee BSOD somewhere.


while cannibal_witch.alive:
    self.location = locations.next()
    if cannibal_witch in self.location.population:
        self.kill(cannibal_witch)


[robot.execute(i) for i in locations if robot.seek(i)]

Mwahaha!

kill -9 ps -ef | grep "<char name>" | awk '{print $2 }'

?

Lars sez: REAL robot bounty hunters run 32-bit 8086 assembly:


origin:
	xor eax, eax
main_loop:
	push eax
	movsq edx, [current_location_buffer]
	add edx, ebx
	call forest_location_check
	test eax, forest_bit	
	jne not_witch
	mov esi,target_input_buffer
	push ecx
	mov ecx, target_input_cnt
target_check_loop:
	lodsb	
	test [eax],person_bit
	jne not_correct_target
	mov edx, eax
	add eax, mass_offset
	cmp [eax], duck_mass
	jne not_correct_target
	call target_magic_check
	test eax, magic_bit_set
	jne not_correct_target
	mov eax, edx
	mov ebx, edx
	push eax
	add eax, food_intake_type					
	mov edx,[eax]
	pop eax
	add eax, own_type
	cmp [eax], edx
	jne not_correct_target
	mov eax, ebx
	add eax, has_killed_register
	or eax,eax
	jz not_correct_target
	mov eax, ebx
	mov ebx, kill_flag
	or ebx, capture_flag
	call DoTargetAction
	test eax, success_flag
	pop eax
	jne main_loop
	jmp witch_found
not_correct_target:
	loop target_check_loop
	pop cx
not_witch:
	pop eax
	outp 2232h,eax
	inc eax
	xor eax, random_rotation_mask
	jnz main_loop
	mov eax, turn_qty
	outp 1762h, eax
	jmp main_loop
witch_found:
	nop
	jmp witch_found

Yikes! Not sure I can compete with Assembly, but here’s my event driven take. Pardon the nasty inlined style, and the few liberties I’ve taken with Python.


#!/usr/bin/python

import knowledgeBase

from behaviors  import KillOnSight
from heuristics import shortestCircuit
from tasks      import ReturnToBase, Task, SeekHideouts, StakeOut
from triggers   import Found

def contract( agent, target ):
    def hunt( locations ):
        if knowledgeBase[target]['confirmedDead']:
            agent.clearBehaviors( KillOnSight )
            task = Task( ReturnToBase() )
        elif locations:
            task = Task( StakeOut( locations ),  callback=hunt )
        else:
            task = Task( SeekHideouts( target ), callback=hunt )
        agent.registerTask( task, priority=1 )

    agent.registerBehavior( Found, target, KillOnSight( target ) )

    hideouts = knowledgeBase[target]['hideouts']
    hideouts.sort( shortestCircuit )
    hunt( hideouts )

contract( 'Sarah Connor' )

Or, a bit more inline with what Theodore asked for:


#!/usr/bin/python
from behaviors import Hunt, KillOnSight

def contract( agent, target ):
    agent.registerTask( Hunt( target ), priority=1, callback=KillOnSight( target ) )

contract( 'Baba Yaga' )

or even just


target = 'Baba Yaga'
agent.registerTask( Hunt( target ), priority=1, callback=KillOnSight( target ) )

[Edit]one last one!


target = 'Baba Yaga'
agent.registerTaskChain( Hunt(target), NefariousMonologue(target), Kill(target) )

Everybody knows LISP is the language for AIs.


(defun hunt (cannibal-forest-witch)
   (cond
      ((found cannibal-forest-witch)
         (terminate cannibal-forest-witch))
      (t
         (hunt (next-location cannibal-forest-witch)))))

OH COME ON PEOPLE!



10 FIND SARAH CONNOR
20 TERMINATE SARAH CONNOR
30 GOTO 10

run 



What? No Fortran? Sheesh!



12     IF (WITCH.EQ.DEAD) GOTO 20
15     CALL SEEK(WITCH)
       IF (WITCH.EQ.FOUND) THEN
       CALL TERMINATE(WITCH)
       ELSE
       GOTO 15
       ENDIF
       GOTO 12
20     CONTINUE