Author Topic: [QUESTION] BBeans  (Read 2178 times)

Offline nightcracker

  • *
  • Posts: 505
  • Rep: 7
  • Script kiddo
    • View Profile
    • NC Labs
    • Awards
  • Skype: orsonpeters
[QUESTION] BBeans
« on: June 10, 2011, 05:56:44 AM »
Do you create your own custom AI with BBeans using Python?

If yes, where can I find some specs/info on the API?

Sorry if this is some noob question that could be answered by one google or something.

Offline Squirrel_Monkey

  • Squirrel_Monkeyweight
  • *
  • Posts: 7587
  • Rep: 7
  • [Insert clever and witty comment here]
    • 0SquirrelMonkey0
    • View Profile
    • Awards
Re: [QUESTION] BBeans
« Reply #1 on: June 10, 2011, 06:00:14 AM »
You could but pre-made ones are usually fine for most bots.
Better than GK since 2009.
I think SM is a pretty cool guy, eh builds unicycle-bots and doesn't afraid of anything

Offline nightcracker

  • *
  • Posts: 505
  • Rep: 7
  • Script kiddo
    • View Profile
    • NC Labs
    • Awards
  • Skype: orsonpeters
Re: [QUESTION] BBeans
« Reply #2 on: June 10, 2011, 06:30:05 AM »
And my second question? Are there any specs/info about the API?

Offline Squirrel_Monkey

  • Squirrel_Monkeyweight
  • *
  • Posts: 7587
  • Rep: 7
  • [Insert clever and witty comment here]
    • 0SquirrelMonkey0
    • View Profile
    • Awards
Re: [QUESTION] BBeans
« Reply #3 on: June 10, 2011, 06:32:36 AM »
No idea what an API is. I'm sure this can't be the right section.
Better than GK since 2009.
I think SM is a pretty cool guy, eh builds unicycle-bots and doesn't afraid of anything

Offline nightcracker

  • *
  • Posts: 505
  • Rep: 7
  • Script kiddo
    • View Profile
    • NC Labs
    • Awards
  • Skype: orsonpeters
Re: [QUESTION] BBeans
« Reply #4 on: June 10, 2011, 06:53:37 AM »
An API is the Application Programming Interface.

In short it provides a programmer a way of communicating with your program using code without exposing the internals. Just like a coffee-machine, you operate it through it's interface (the buttons), but you don't know it's internals (and most likely you don't want to know).

An example, RA2 can provide the function get_position_of_bot() which returns an x and y coordinate without showing the internals of the code.

Offline Pwnator

  • *
  • Posts: 6676
  • Rep: 15
  • Awards BOTM Winner
    • View Profile
    • http://pwnator.tumblr.com
    • Awards
  • See profile for gamer tags: Yes
Re: [QUESTION] BBeans
« Reply #5 on: June 10, 2011, 08:05:51 AM »
Have you tried toying around with the F9 window? BBros' cheat mode pack might give you some other stuff that piques your interest:

http://beetlebros.gametechmods.com/robotarena.htm
Clash Cubes 1 - Grey Matter (Runner-Up)
King of Karnage - Sideshow Freak (Runner-Up, Best Engineered)
Rust In Pieces - Paper Cut 3 (Grand Champion, Most Dangerous Bot)
Wheely Tag Tournament - Ion Thruster (Grand Champion, along with Ounces' DiSemboweLment)
UK vs USA - Dark Striker (Grand Champion)
Rust In Pieces 2 - Claymore (Runner-Up, Favourite Bot)
BBEANS 6 - Infection 4 (Runner-Up)
RA2 Team Championships - Serious Business, Skeksis (Runner-Up, along with Scrappy, S_M, and Badnik)
RA2 Team Championships 2 - The Other Stig (Runner-Up, along with Scrappy, S_M, Badnik, 090901, and R1885)
Replica Wars 3 - Abaddon (Runner-Up, Luckiest Bot)
BroBots - wheebot & yaybot (Runner-Up)
Robo Zone 2 - Dipper (4th place, Survival Champion, & Best Axle Bot)
ARBBC - The Covenant (3rd place, BW Rumble Winner, Most Feared BW)

Offline Naryar

  • Posts: 23283
  • Rep: 21
  • hybrids oui oui
    • http://www.youtube.com/us
  • Awards BOTM Winner
    • View Profile
    • Awards
  • Skype: TheMightyNaryar
Re: [QUESTION] BBeans
« Reply #6 on: June 10, 2011, 09:03:36 AM »
BBEANS is just THE AI tournament, but 95% of people don't provide their own AI.

You sound like a Python-fluent person (HSSSSSS SSSSSSSSS SHHHHHHH /badpun), I guess you have tried tinkering with the AI.py's a bit ?

The programming interface we use in general for AIing is Notepad++. Dunno if it is an API or not.

Offline nightcracker

  • *
  • Posts: 505
  • Rep: 7
  • Script kiddo
    • View Profile
    • NC Labs
    • Awards
  • Skype: orsonpeters
Re: [QUESTION] BBeans
« Reply #7 on: June 10, 2011, 12:29:30 PM »
Yes, I am a "Python-fluent person". And no, Notepad++ is NOT an API. Notepad++ is not an API, it is an editor. An API is the set of functions you call in Python itself (like print(), and movebot()).

I haven't tried to tinker with the AI.py's yet, I wasn't aware that I could edit them right away without modding the game to the point where it will accept my scripts.

Offline Sage

  • *
  • Posts: 6182
  • Rep: 11
  • RA2 Wizard & GTM's Favorite Stock Builder 2015
  • Awards Sage's Favorite BOTM Winner
    • View Profile
    • Awards
Re: [QUESTION] BBeans
« Reply #8 on: June 10, 2011, 01:10:22 PM »
Check out what Pwnator is talking about, it's pretty sweet. Scroll down that page he linked to till you get to RA2 Cheat Mode Pack, see if that's what you're talking about.
You got my vote for RA2 Wizard. Always and forever.

Offline Clickbeetle

  • *
  • Posts: 3375
  • Rep: 21
  • In Soviet Russia, bugs stomp YOU!
  • Awards BOTM Winner
    • View Profile
    • Beetle Bros site
    • Awards
Re: [QUESTION] BBeans
« Reply #9 on: June 16, 2011, 12:43:40 AM »
Trovaner has a really handy list of most of the Python functions in RA2.  I'll repost it here.



# PLUS Module Codes
#----------------- Generic Codes: ------------------
#plus.cleanup() - not sure yet
#plus.cls() - clears FPS window
#plus.damage(BotID, ComponentID, Damage, Location) - inflicts the specified amount of damage to the specified component
#plus.describe(BotID) - gives all component IDs and general types
#plus.disable(BotID, Power) - turns the controls on or off for the designated bot (1 is off, 0 is on)
#plus.force(BotID, X, Y, Z) - forces bot in a direction depending on arena
#plus.gravity(X, Y, Z) - changes the arena gravity
#plus.practice(Power) - turns time on or off (1 is on, 0 is off)
#plus.push(BotID, X, Y, Z) - pushes bot in a direction depending on current heading
#plus.show(?, ?, ?) - not sure yet
#plus.zap(BotID, Sparks, Duration) - makes harmless sparks that flow across the chasssis surface
#plus.Arena(?) - not sure yet (expects something in quotes)
#plus.AI - loads funtionality from the AI.py and more... (I'm not sure what yet)
#plus.Compile(?) - not sure yet


#----------------- Question Codes: ------------------
#plus.areHazardsOn() - returns 1 if hazards are enabled
#plus.isDebugMode() - returns 1 if Debug Mode is in progress
#plus.isDefeated(BotID) - returns 1 if the bot has been defeated
#plus.isEliminated(BotID) - returns 1 if the bot has been eliminated
#plus.isHuman(BotID) - returns 1 if the bot is human controlled
#plus.isMatchOver() - returns 1 if match is over
#plus.isMatchPaused() - returns 1 if the Pause/Break button is activated
#plus.isStandard(BotID) - returns 1 if the bot has 100% stock components
#plus.isUpsideDown(BotID) - returns 1 if the bot is inverted


#----------------- Info Codes: ------------------
#plus.getContacts(BotID) - returns 0 or 1 for each wheel, 0 if traction zone is not contacting anything and 1 if it is, in a list.  Ex: [1,1,1,1] is a four-wheeled bot with all four wheels on the ground.
#plus.getDirection(BotID, NoseOffset) - returns vector pointing in the forward direction for this player's bot with botlab nose offset
#plus.getFPS() - returns the current FPS
#plus.getGameType() - returns the name of the arena type (ex: "TABLETOP")
#plus.getHeading(BotID) - returns up axis heading for this player
#plus.getHealth(BotID, ComponentID) - returnsf the amount of health remaining (ex: 1.0 is 100% health, .5 is 50% health, ect.)
#plus.getHitpoints(BotID, ComponentID) - returns the amount of remaining hitpoints for the component
#plus.getLocation(BotID) - returns tuple for location of the designated bot
#plus.getPlayers() - returns the number of players (will not change when bots are disabled, destroyed, or eliminated)
#plus.getScreenSize() - returns the screen size setting
#plus.getSpeed(BotID) - returns the current speed of the designated bot
#plus.getTimeElapsed() - returns the amount of time that has passed since the start of the battle
#plus.getWeight(BotID) - returns the weight of the designated ID (changes when components fall off)


#----------------- Setting Codes: ------------------
#plus.setArena(ArenaObject) - not sure yet
#plus.setBackColor(Red, Green, Blue) - changes the background color
#plus.setSubsteps(Number) -  determines processing time and affects the ingame countdown clock (0 causes the game to quick responding)(1 is the fastest but causes lag because there isn't enough process time)(I think 100 is default)
#plus.setTimestep(Number) - 0 is default and everything above that causes something similar to lag (affects the bots and camera), 1 causes the camera to lag into the corner while the bots fly into oblivion when they touch the ground and 100 causes them to fly into oblivion even while they are in the air
#plus.SetCompileFilename(?) - not sure yet (it either requires something in quotes or compileFilename)


#----------------- Status Codes: ------------------
#plus.AddParticleEmitter((x, y, z), (vex, vey, vez), (vax, vay, vaz)) - creates a ParticleEmitter object
#plus.addPoints(BotID, Points) - increase the score of a selected bot by a selected number of points
#plus.addText(guiWindowObject, x, y, w, h) - not sure yet
#plus.addWindow(name, x, y, w, h) - creates a guiWindow object
#plus.add_method(0,0) - not sure yet
#plus.caughtError(?, ?, ?) - not sure yet
#plus.closeWindow(?) - not sure yet
#plus.compileFilename() - not sure yet
#plus.dispatchEvent(?,?) - not sure yet
#plus.elecZoneEvent() - not sure yet
#plus.eliminatePlayer(BotID) - eliminates the designated bot ID
#plus.emitSmoke(Value, String, String, String) - not sure yet
#plus.enumArena(?) - not sure yet (requires an ArenaDetail object)
#plus.introComplete() - activates starting countdown with comment
#plus.magicMobility(Power) - turns traction on or off (1 is on, 0 is off)
#plus.rayTest(self.adjustedLoc.asTuple(), flamepos.asTuple()) - not sure yet
#plus.refreshAI(?, ?) - not sure yet
#plus.removeWindow(?) - not sure yet
#plus.showFPS(Power) - turns on or off the built-in python interpreter for the FPS window (1 in off, 0 is on)
#plus.usePower(BotID, Power) - turns on or off the need for power sources (air tanks and batteries) for the designated bot (0 means that it uses power, 1 means it doesn't)


#----------------- Sound Codes: ------------------
#plus.createSequence(?, ?, ?, ?, ?) - not sure yet
#plus.createSound(Sound File, False, (0,0,0)) -  Adds the selected sound file to memory but doesn't play it
#plus.fadeIn(?, ?, ?) - not sure yet
#plus.fadeInToLoop(Sound File, -100, 800) - Fades into the specified sound file to the specified volume at the specifed rate
#plus.fadeOut(?, ?) - not sure yet
#plus.fadeOutLoop(Sound File, Rate) - Fades out of specified looped sound file at specified the rate
#plus.loopSound(Sound File) - Repeats the selected sound file until it is told otherwise
#plus.playFile(?, ?) - not sure yet
#plus.playOnce(Sound File) - not sure yet
#plus.playSequence(Sound File) - not sure yet
#plus.playSound(Sound File) - plays the selected sound file until it is told otherwise
#plus.removeSequence(Sound File) - not sure yet
#plus.removeSound(Sound File) -  removes the selected sound file from memory to reduce lag
#plus.setMaxDistance(?, ?) - not sure yet
#plus.setMinDistance(?, ?) - not sure yet
#plus.setVolume(Sound File, 0, 0) - not sure yet
#plus.stopAllSounds() - stops all sounds that are playing (the crowd seems to be reloaded after its activated so it doesn't go away in the Combat Arena)
#plus.stopSequence(Sound File) - not sure yet
#plus.stopSound(Sound File) - stops the selected sound file but doesn't remove it from memory


#----------------- Camera Codes: ------------------
#plus.animateCamera((X, Y, Z), (V-Swing, H-Swing), Start Zoom, (X, Y, Z), (V-Swing, H-Swing), End Zoom, Speed, Duration) - camera movement (the first set of X Y Z cordinates is for the starting position while the second set is for the ending position, V-Swing and H-Swing determine the direction of the camera as it moves, and speed can be negative numbers but that just causes it to go slow then quickly get to the end of the sequence in the last tick) (cannot change due to a variable once it is started)
#plus.fadeFromBlack(Duration) - darkens screen then fades back in
#plus.setCameraFOV(0.675) - creates an orbit cam at the selected distance from the chassis
#plus.setCameraFOVRange(self.range[0], self.range[1], self.range[2], self.range[3]) - <from __init__.py> not sure yet
#plus.setCameraPosition(X, Y, Z) - places a camera at the specified coordinates
#plus.setCameraRotation(0.266024,-0.472956) - changes the direction of the current camera's facing (works on all camera types)


#----------------- Object Codes: ------------------
#plus.ArenaDetail() - returns an ArenaDetail object
#plus.HingeController() - returns a HingeController object
#plus.ParticleEmitter() - returns a ParticleEmitter object
#plus.PrismaticController() - returns a PrismaticController object
#plus.SWHandle() - returns a SWHandle object
#plus.guiTextBox() - returns a guiTextBox object
#plus.guiWindow() - returns a guiWindow object


#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


# SELF Module Codes
# (The self module can't be loaded inside of the FPS window to my knowledge)


#self.IsIntact(BotID) - returns 1 if intact (I'm not sure what this means in RA2 yet...) and 0 if not intact
#self.GetHealth(ID) - not sure yet if the ID is a bot or comp but it returns a value to the nearest tenth (1 being 100% health)
#self.IsDisabled() - returns 0 if it is not disabled and 1 if it is
#self.IsUpsideDown() - returns 0 if it isn't upsidedown and 1 if it is
#self.GetCriticalHits() - not sure yet
#self.IsEnemy(BotID) - returns 1 if the designated bot is an enemy and 0 if it is an ally
#self.GetLocation - returns the coordinates of the bot loading this
#self.GetStartPointLocation
#self.RayTest
#self.setText
#self.hide
#self.setPosition
#self.GetEnemies() #returns the IDs of all opposing bots
#self.GetLastDamageReceived() -
#self.GetLastDamageDone() -
#self.GetPistonPosition(CompID) - returns the current position of the designated piston shaft
#self.GetMotorAngle(ComponentID) - returns the angle of the motor in radians
#self.GetHeading
#self.GetDirection
#self.GetDistanceToID(BotID) - returns the distance to the designated bot ID
#self.GetDistanceTo
#self.GetHeadingToID
#self.GetHeadingTo
#self.GetSpeed() - returns the speed of the bot loading this
#self.GetTurning() - returns the turning of the bot loading this
#self.GetID() - returns the ID number of the bot loading this
#self.Input(ControlName, ControlNumber, Amount) - controls the movement of objects and components
#self.GetInputStatus(ControlName,ControlNumber) - returns 1 if moving 0 if not (I've only tested this with servos so I think it might be different for spin motors)
#self.RegisterSmartZone
#self.ResetComponents() - restores the hitpoints of all of this bots components (will not reconnect components that fall of but will still restore their HP)
#self.GetZoneContents
#self.GetNumComponents() - returns the number of components
#self.GetComponentType
#self.GetComponentHealth
#self.AddXtra
#self.AddXtraSound
#self.RemoveXtra
#self.AddShadowReceivers (def ?)
#self.SetShadowSource
#self.SetShadowPrimitive
#self.AddShadowTriangle
#self.GetHinge
#self.AddPOV(id, x, y, id, id2) - where "id" is the ID number of that POV, x and y are the position, and "id2" is the ID number of the POV that this POV connects to.  Basically you string them together with that second ID to make a path. (explained by Clickbeetle)
#self.AddCollisionLine((x, y), (x2, y2)) - where x and y are the position of one end of the line and x2 and y2 are the position of the other end.  The line between the two points acts as an "obstacle" to the AI that they will try not to cross. (explained by Clickbeetle)
#self.RegisterZone
#self.SetPinned
#self.SetActive
#self.CreateLightning
#self.SetLightningStartEnd
#self.SetLightningVisible
#self.SetSubMaterial
#self.SetSubMaterialSound
#self.AddPrismatic
#self.GetHinge
#self.SetPinned
#self.SetActive
#self.HazardsOn
#self.AddShadowReceivers
#self.SetShadowSource
#self.SetShadowPrimitive
#self.SetPhantom
#self.GetRobotsInPhantom
#self.RegisterDamageCallback
#self.DisconnectDamageCallback
#self.ParticleEmitter
#self.SetEmitting
#self.NextStaticCamera
#self.NextWatchCamera
#self.NextAutoCamera
#self.ClearCameraBlockers
#self.AddCameraBlocker
#self.tickInterval - returns the current tick interval
#self.bHazardsOn

To lack feeling is to be dead, but to act on every feeling is to be a child.
-Brandon Sanderson, The Way of Kings

Offline JoeBlo

Re: [QUESTION] BBeans
« Reply #10 on: June 16, 2011, 01:22:30 AM »
Trovaner has a really handy list of most of the Python functions in RA2.  I'll repost it here.

Thats awesome

Thanks Trov and Click for the repost.

Madiaba gave me a python file some time ago with a huge supply of python codes too..

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: [QUESTION] BBeans
« Reply #11 on: June 16, 2011, 05:23:08 AM »
How do you activate them in the F9 window? I've tried Enter, Tab, Space, CTRL, =, but none of them work.
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline Trovaner

  • *
  • Posts: 1222
  • Rep: 32
    • View Profile
    • Awards
Re: [QUESTION] BBeans
« Reply #12 on: June 16, 2011, 09:03:09 PM »
That list is actually pretty outdated now. There are only 13 plus codes and the self codes have been sorted (although obvious in terms of use, most of them still need descriptions). When I have time, I'll post up the newest version.

After importing the proper modules/instances, you merely need to type it in and hit enter (obviously removing my comments and replacing the parameter names with values/strings). If you were already doing this, what code are you trying to use? Depending on the code, you may need to do some additional work.

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: [QUESTION] BBeans
« Reply #13 on: June 17, 2011, 03:50:59 AM »
#self.GetComponentHealth, and I then put the figures in, as per the python file Joe referred to.
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline Trovaner

  • *
  • Posts: 1222
  • Rep: 32
    • View Profile
    • Awards
Re: [QUESTION] BBeans
« Reply #14 on: June 17, 2011, 09:47:52 PM »
In the FPS window: (requires the edits found in FB's cheat mod)
1. Open the FPS window and make sure the FPS updating is turned off (by either pressing the ~ button to open it or type "showFPS(True)" and hit enter (the plus functions have already been imported so you don't need the "plus.")).
2. Since that is an AI code, you need to gain access to the AI from the FPS window. To do this, one way of doing this is by typing "b=AI.running_ai[0]" (AI is already loaded so no need to import anything) (I'm using AIID 0 so this is looking at the first AI bot (results in an error if it doesn't exist)).
3. Since b is now an AI object, you will want to use it instead of typing self (which is python's way of calling things within a specific class (read AI.py example)). Entering "print b.GetComponentHealth(0)" will now return a fraction representing the health of the chassis (CompID 0)

In an AI.py, you would use self.GetComponentHealth(CompID) as you would any other method (if you used print here, you would need to have done step 1 of the FPS window example (unless you are printing more than once)).

The AI and Arena self commands are mixed together in that version of "Code Cuts.py".

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: [QUESTION] BBeans
« Reply #15 on: June 18, 2011, 02:25:32 AM »
Ah, it'd be lack of cheat mode on the game I was trying it with.
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)