Robot Battle: Zer's venture into artificial intelligence.

Recommended Videos

Zer_

Rocket Scientist
Feb 7, 2008
2,682
0
0
Robot Battle: As seen by SuperFriendBFG



I came across this game a few days back, and ever since then I've been working on my little bot in my spare time. First let me explain what Robot Battle is. In Robot Battle your robot faces other bots head to head in an arena. It is a challenging but rewarding game where the fruits of your labor are shown only an hour or two after you've picked up the game and started on your robot. What sets your robot apart from others is how you programmed it. That's right, you program the AI of your robot. Unlike most programming languages; with this game you can see the fruits of your labor rather quickly. In this review I'll explore the many aspects of this game from the point of view of someone who has never learned to program. I did have a basic understanding of how code works prior to getting this game, but I was not (and still aren't) an expert in the logic behind coding.

So I have to program a robot myself?! o_O

The bread and butter of this game is the language you program your robot's AI in. It's a proprietary language exclusive to this game. The language is known as Robotbattle Scripting Language (RSL). The language has similarities to C/C++, Javascript and Python. You have your usual functions (also known as commands), parameters, logical operators, arithmetic/algebra, and of course variables. The game provides variables known as ?System Variables? that your robot can read and use to help it within the game. One good example of a system variable is ?_ypos? and ?_xpos?, which together will give you your robot's current location within the arena. Even though this isn't a common programming language it still makes for a fantastic learning tool. The game comes with a rather complete beginners guide that should get you started. The code is very intuitive and you will start seeing your little robot scanning and shooting targets in no time.

Bots that are included in the game have all their functions properly commented so you can see read what the code is actually doing. This helps a lot when learning to code. You can also download some robots that other users have created in the Robot Battle Registry ( http://www.robotbattle.com/registry/ ). One bot that I found particularly helpful in learning was known as the ?tutor bot?. The commenting in tutor bot is rather descriptive and gives you a very good idea at how the code works. Throughout the course of your learning experience you will come to realize that the code is very flexible and there are many ways to achieve the same thing. Some are cleaner then others, but for a beginner that doesn't really matter. The only thing that matters in the end is how your robot fares against its opponents. As you gain experience your robots will evolve in complexity. Eventually you could have a robot that will adapt to its opponents. Some users have even created learning robots. There are a few proof of concept robots out there that fiddle with some neat concepts like Artificial Neural Nets ( http://en.wikipedia.org/wiki/Artificial_neural_network ).

Getting my robot to work as I wanted it to was a fun and insightful experience. I was well rewarded with my efforts with a rather cute robot that shows at least some signs of self-preservation. My preferred programming suite is Notepad++ with a custom syntax file made specifically for RSL. There is also a program made specifically for programming RSL robots known as ARDUS. ARDUS is pretty simple, although I personally prefer Notepad++ with the custom syntax file. You can even program your bot in notepad and save it as a .prg file if you must. You can find out about other editors for making robots as well as their associated syntax files on the Robot Battle Wiki ( http://robotbattle.wikia.com/wiki/FAQs ).

Okay, so what if I wanted my robot to dance to Rick Astley?

Robot Battle provides you with a rather robust array of built-in functions that your robot can perform. You can even get your robot to do a sort of dance, but that usually results in a terrible combat performance. The robot itself is made of three components; the body, the turret and the radar. Each can move independantly to each other, or you can have the radar and turret locked so they move together. The body's rotational speed is the slowest followed by the turret and finally the radar dish, which can turn the fastest. That means that if you lock your radar to your gun, the radar will turn at the same speed as your turret. Basically there are often some consequences to consider when using features that help your robot in combat. Locking your radar to your turret has the distinct advantage of allowing your robot to fire as soon as it detects an opponent. You can have your robot react to being detected (by a radar ping). Your robot can react to being shot. Dodging enemy detection and fire doesn't always work but it can help your robot survive longer in the battlefield. Advnaced users are capable of making robots that will learn and change its tactics based on its current situation. Robots can retain data from one Game to the next. Robot Battle supports team games and that means that there are also team-based functions and variables. Robots can be programmed with the ability to distinguish friend from foe. Some of the more advanced robots can even communicate information with each other via private channel. The game has a total of 9 channels available for private communication between robots (1-9). A few robots are programmed to infiltrate enemy channels and read any data that is being transmitted. These "hackerbots" can also send out false data to confuse enemy robots. There are certain measures you can take to help prevent your team's channel from being breached. Some users have set up an encryption algorithm that is used to encrypt transmitted data so that it cannot be read by robots who do not have the approprate key. There are many other functions that your robot can perform. All the functions are detailed in a convenient reference section in the help file. Basically, if it's programmed into your robot, it will do it.

I have a robot, let the battle begin!

Robot supremacy in Robot Battle is determined by Matches. Each Match consists of a pre-set amount of Games. Each Game is where robots will actively duke it out against each other in the Arena. The user has absolutely no control over their robot within a Match. Matches have several configuration options that lets you modify many aspects of the Match. You can set the number of Games per Match. You can also set the size of the Arena as well as the frequency of Mine/Cookie spawns. Mines and Cookies are objects that will spawn within the Arena throughout a Game. A mine will damage your robot's energy while Cookies will replenish your robot's energy. Both Mines and Cookies can be detected, and shot. You can also tell your robot to seek out cookies within its code to help it survive.There is no health within the game, only Energy. Your robot's Energy is its health, and running out of Energy means your robot is dead. Shooting costs your Robot Energy. Fortunately when your Energy Missile hits an enemy, the damage is always 4x the amount of energy within the Missile. You can also specify how much Energy the robot will use for each Energy Missile. The winner of each Match is the robot who places highest overall.

Do other people actually play this game?

The Robot Battle community isn't all that large. There are tournaments that are hosted here and there. Each tournament may have a set of specific rules that your robot must follow. There are a lot of resources to assist someone in learning how to program in RSL and the community is rather helpful to newbies. Apart from the Wiki ( http://robotbattle.wikia.com/wiki/Main_Page ) there is a forum ( http://www.robotbattle.com/registry/ ), and there is also an unnoficial IRC channel ( Server: irc.zuh.net Port: 6667 Channel: #robotbattle ). These three resources can provide you with an answer to most of your questions. The community may be small but it is mature and very helpful. You can also post your own robot on the registry for other people to see and test.

My lord, this isn't a game, it's just a job with no pay!

Robot Battle is not a very active game. You have no direct control over your robot. The fun comes in coding your own robot and watching that code executed right in front of your eyes. Robot Battle is also a very rewarding game because it allows you to create your own Artificial Intelligence and watch it do its thing. This game obviously won't appeal to everyone. Someone who isn't willing to learn a new scripting language will have trouble enjoying this game. If you're willing to take the time to learn how to code your own robot, then you'll find yourself liking this game a lot. Once you get yourself to the point where your robot actually does something, you'll find it much easier to set yourself a new goal for your robot and achieve it. You can always go back and add new features to your robot. You can tweak and refine current features and ultimately end up with a more efficient killing machine (or dancing machine: http://robotbattle.wikia.com/wiki/List_of_Dancing_Robots ).

The Robot Battle's homepage can be found here: http://www.robotbattle.com

And for the curious, I will post my robot below.

WARNING!!! Wall of text WARNING!!!

Code:
Init

{

	name("T-1")
	version("0.50b")
	author("Zer")
	regcore(NetCore)
	regdtcrobot(FoundTarget,1)
	regcldcookie(AcquireBattery,9)
	regcldmine(RecordMine,9)
	regcldmissile(EvasiveAction,1)
	regcldrobot(Collision,2)
	regdtccookie(FoundBattery,3)
	regdtcmine(DetectMine,4)
	regping(LocCompromised,2)
	regdtcwall(MovementRoutines,3)
	regcldwall(WallCollision,1)
	regdtcwall(detectwall,5)
		lockgun(true)
		gosub(Boot)

}


Boot

{

	if(_gamenbr == 1)
		mines = 0
		batteries = 0
		ping_count = 0
		collisions = 0
			r = 0
			trk = 0
			rt = 0
		    mode = 1
	endif
	
}



NetCore

{

	if(mode == 1)
	scan()
	    if( _bodyaim % 90 != 0 )
       		 bodyleft( _bodyaim % 90 )
    	endif
		     gosub(Movementroutines)
	else()
		gosub(TrackTarget)
	endif
		
}


DetectWall

{

	gosub(FindTargets)

}


WallCollision

{
	stop()
	bodyleft(90)
		gosub(Movementroutines)

}


FoundTarget

{
	
	if(_dtcteamid == 0 or _dtcteamid ! == _teamid)
		r = 1
		mode = 0
		gosub(Terminate)
	endif
}


AcquireBattery

{

	batteries = batteries + 1

}


RecordMine

{	
	mines = mines + 1

}


EvasiveAction

{
	
	ahead(-25)	
		mode = 1

}


Collision

{

	back(25)
	bodyright(45)
		collisions = collisions + 1
		
}


FoundBattery

{

	if(_energy > 200)
		fire(1)
		clear(_dtccookie)
	else()
			syncall()
		waitfor(_bodyrmn == 0)
			ahead(_scandist + 10)
		waitfor(_movermn == 0)
	endif
	
}


DetectMine

{

	if(_scandist < 500)
		fire(1)
	endif

}


LocCompromised

{
	
	if(_pingfreindly)
		print("Pinged by SkyNet")
	else
		gosub(EvasiveAction)
	endif

}


Terminate

{

	if(mode == 0)
			stop()
		if(_scandist > 400 or _energy < 30)
			fire(1)
		elseif (_scandist > 400)
			fire(3)
		elseif (_scandist > 200)
			fire(5)
		else()
			fire(7)
		endif
			gosub(TrackTarget)
	else()
		gosub(MovementRoutines)
	endif
	
}


Dead

{
	
	gosub(Terminated)

}


Terminated

{

	store(mines)
	store(batteries)
	store(collisions)
		print("----------------")
		print("Combat Operation")
		print(_gamenbr)
		print(batteries)
		print(mines)
		print(collisions)

}


Movementroutines

{
	rt = 0
			db = _arenawidth - _xpos    		// establish distance to east wall
			dd = _arenawidth - db       		// establish distance to west wall
			dc = _arenaheight - _ypos  			// establish distance to north wall
			da = _arenaheight - dc     	     	// establish distance to south wall
		if(_heading > 315 or _heading < 45)		// Determines if the robot is facing North
			distance = dc						// Sets the robot's distance from the North wall
		elseif(_heading < 135)					// Determines if the robot is facing East
			distance = db						// Sets the robot's distance from the East wall
		elseif(_heading < 225)					// Determines if the robot is facing South
			distance = da						// Sets the robot's distance from the South wall
		elseif(_heading < 315)					// Determines if the robot is facing West
			distance = dd						// Sets the robot's distance from the West wall
		endif									
			if( _bodyaim % 90 != 0 )			// Makes sure the robot is facing a right angle
				bodyleft( _bodyaim % 90 )		// If not, then turn body left to compensate
			endif							
		if(distance < 25)						// If distance to wall is under 28 units
			bodyleft(90)						// Turn left 90 degrees
				gosub(FindTargets)				// Go to subprogram "FindTargets"
			ahead(75)							// Ahead 28 units
			scan()								// Redundant scan call
		else()									// Else (If distance to wall is over 25 units
			ahead(distance - 25)				// Distance - 25 units
			scan()								// Redundant scan call
		endif
				
}


TrackTarget

{

	if(mode == 0)
		if(r == 1)
				waitfor(_radarrmn == 0)
				radarleft(30)
				scan()
					r = 0
		else()
				gosub(findtargets)
		endif
	else()
		gosub(FindTargets)
	endif

}


FindTargets

{

	radarright(5)
	scan()
		rt = rt + 5
			if(rt == 360)
				gosub(MovementRoutines)
				rt = 0
			else()
				gosub(FindTargets)
			endif

}

Well as you can see my robot's code is not fully commented on, therefore you may not understand all its functions. Anyways it looks rather messy since the forum does not properly display the formatting.
 

megapenguinx

New member
Jan 8, 2009
3,865
0
0
That sounds intense. I think I would just end up having my bot run into a wall constantly due to botched programming on my part.
 

Zer_

Rocket Scientist
Feb 7, 2008
2,682
0
0
Updated original post and made some random corrections here and there. Posted the code for my current robot. I also fixed the links so they can actually be clicked!