Debug AI using XCode

AI discussion, ideas, and SDK help.
Post Reply
guest.

Debug AI using XCode

Post by guest. » Sun Dec 12, 2004 1:03 am

Anyone interested in knowing how to debug a LuxAgent using XCode?

Nothing like walking through pickCountry to realize why Chess is confusing your bot.

Guest

Post by Guest » Sun Dec 12, 2004 7:02 pm

Well since I'm not getting any responses i'll post what I did.

In the project add a new executable with path "/Applications/Lux.app"
Set the target Java Archive Settings to Class Hierarchy

copy class file <project>.class from
<project dir>/build/<project>.build/<project>.build/JavaClasses
to
/Library/Application\ Support/Lux/Agents

Debug away.

It wiped my preferences the first time I ran it. I think changing the working directory in the executable settings fixed it.

Unsolved issues:
It will step into BoardHelper function but the source is misaligned, same thing happened to the class file when copied the class file from <project dir>

User avatar
dustin
Lux Creator
Lux Creator
Posts: 10998
Joined: Thu May 15, 2003 2:01 am
Location: Cascadia
Contact:

Post by dustin » Sun Dec 12, 2004 10:39 pm

Cool, thanks for the info. There were some questions about how to do this a while ago.

Sometimes the xCode java debugger will not be lined up properly with the source when I use it. It's fecking annoying. I think Apple needs to spend a little more time on xCode's java support. Although if you find a solution I'd love to here it.

And why not register for the forums so we know who the lovely new agent daddy is?

User avatar
rip
Luxer
Posts: 352
Joined: Wed Mar 31, 2004 10:22 am
Location: Vienna Austria
Contact:

Re: Debug AI

Post by rip » Tue Dec 14, 2004 9:48 am

guest wrote:Anyone interested in knowing how to debug a LuxAgent using XCode?

Nothing like walking through pickCountry to realize why Chess is confusing your bot.
THANK YOU!
THANK YOU!
THANK YOU!

*maniacal cackle*
*rubs hands in glee*

I've been trying to get this working using eclipse but have been unsuccessful in that regard.

rip

guest

Post by guest » Tue Dec 14, 2004 10:22 pm

Your welcome.

Though I doubt the other will thank me in a few days/weeks.

How many lines of code is your AI? Though yours may be smaller if your using SmartAgentBase or making a derivative of cluster. I may end up grabbing parts of cluster well see when I get that far.

If I had to guess I'd say I was a sixth of the way done with my first version. Then theres all the tweaking to get it to behave how I want it to.
wc -l /Users/<name removed to protect the guilty>/Projects/<name removed to protect the inocent>/*.java
742 total
It can be amazing sometimes how even though I know exactly what it is going to do I will be powerless to prevent it from doing it to me :). It won't start to get unpredictable till later on in development when it has more choices as to what to do.

User avatar
rip
Luxer
Posts: 352
Joined: Wed Mar 31, 2004 10:22 am
Location: Vienna Austria
Contact:

Post by rip » Wed Dec 15, 2004 5:01 am

guest wrote:Though I doubt the other will thank me in a few days/weeks.
*more maniacal laughter*
How many lines of code is your AI?
Currently, Ravitar is 3890 (wc -l), however 20% of that is probably comments. So around 3200 lines I'd say.

But remember, Ravitar is a tech test bed. Goldy, which implements only Ravitar's "biggest" algorhythm (correctly, *heh*), is half that.

rip

User avatar
rip
Luxer
Posts: 352
Joined: Wed Mar 31, 2004 10:22 am
Location: Vienna Austria
Contact:

rats.

Post by rip » Wed Dec 15, 2004 6:43 am

Ok, I am defeated by the interface. Sadly, I can't figure out what is supposed to happen. I did what you suggested, but what I expect to happen (Lux to start when I click the 'Run and Debug' icon) doesn't. Everything compiles, I get 'Succeeded', and then nothing.

Are you on skype?

What do I need to do to get Lux to launch from XCode, or do I launch Lux externally? (that doesn't seem to get me to the debugger though)

Help?

rip

User avatar
Preacherman
Semiholy Priest
Posts: 4496
Joined: Tue Feb 24, 2004 3:52 am
Location: Sweden (capital of Denmark, an island in Norway, southern Europe)
Contact:

Post by Preacherman » Wed Dec 15, 2004 8:50 am

Nef is currently about 1400 lines. She no longer extends SmartAgentBase (some functions have been lifted and modified), and v2 is about 80% complete.

The problem is that the standard bots were built at a time where there were no custom maps. They play well on Classic, but if you really want to see how smart your bot is, put her in Hex Cubed, Snakes & Ladders, ScaLuxtric, or other maps that have non-standard playing styles... :lol:

guest

Post by guest » Wed Dec 15, 2004 12:53 pm

Did you make sure that the Lux executable you added is the one that selected to run? When you select Executables it should have the blue button.

User avatar
rip
Luxer
Posts: 352
Joined: Wed Mar 31, 2004 10:22 am
Location: Vienna Austria
Contact:

Post by rip » Thu Dec 16, 2004 4:19 pm

(MacOS X.3.7, XCode 1.1 Core 300)

Ok so this is what I did.

Started XCode.
File->New Project...
-- Empty Project -> Next
---- Project Name: ZRavitar
---- Project Location: ~/Bots/ZRavitar
-- --> Finish

In project window 'ZRavitar',
-- Ctrl+Click Executables
---- -> Add -> New Custom Executable
------ Executable Name: Lux
------ Executable Path: /Applications/Lux.app
------ Add To Project: ZRavitar
---- --> Finish

In project window 'ZRavitar',
-- Ctrl+Click Targets
---- -> Add -> New Target
------ Java Package
------ -> Next
------ Target Name: Lux
------ Ad To Project: ZRavitar
---- -> Finish

In project window 'ZRavitar',
-- Ctrl+Click ZRavitar
---- -> Add -> Existing Files
{navigated to, added all the necessary files, including Ravitar.java)

Debug -> Show Debugger
Debug - ZRavitar (Lux)
-- Build and Debug
(Shows... 'Building' and 'Succeeded', then 'Building...' goes away)

There is a simlink in my Library/.../Agents/ that points at the built Ravitar.class

So what did I miss.

TIA,
rip

guest

Post by guest » Thu Dec 16, 2004 7:37 pm

Well that way you only have one executable option.
I created my project as Java Tool
And I Set the java compiler to target v1.4

here is how I have my executable set up, don't know if it will help.
http://blazemkiv.dyndns.org/Files/executable.tiff

guest

Post by guest » Thu Dec 16, 2004 7:40 pm

I'm using Xcode 1.5

User avatar
rip
Luxer
Posts: 352
Joined: Wed Mar 31, 2004 10:22 am
Location: Vienna Austria
Contact:

Post by rip » Fri Dec 17, 2004 5:13 am

guest wrote:I'm using Xcode 1.5
I've now upgraded Xcode to 1.5, and verified that I'm using Java 1.4.2 update 1.

When I try and launch the debugger, I get:

Run session cancelled: No launchable executable present to run.

Please run through every single step. Assume I'm not a regular user of the XCode development tools.

rip

Guest

Post by Guest » Fri Dec 17, 2004 1:44 pm

I'll walk through what I did, step by step.

1. Create new Project type:Java Tool
2. Add SDK files to project
3. edited Project.java so "class Project implememnts LuxAgent"
3. built
4. Tested to see if Lux would load the jar from the Agents directory
5. Added new executable "Lux" with path "/Applications/Lux.app"
6. Changed Java Archiver to output class heirarchy.
7. built.
8. Copied Project.class from Project/Build to Agents directory.
9. Launched Lux agent appeared in list.
10. Debugged source file and code were out of alignment
11. Copied Project/build/Project.build/Project.build/JavaClasses to Agents directory
12. Debugged and source was lined up.
13. Added Shell Script Files to Target to cp class files to Agents dir.

User avatar
rip
Luxer
Posts: 352
Joined: Wed Mar 31, 2004 10:22 am
Location: Vienna Austria
Contact:

Post by rip » Fri Dec 17, 2004 5:17 pm

Sorry, but we're still making assumptions about what I know.

Here's a hint: I am a real-time C programmer with a background in operating systems. My secondary skills are assembler for the Arc Core (a configurable processor. No fixed instruction set.). I'm also an ex tech support weeny for Wind River Systems, otherwise known as 'Tech Support for Rocket Scientists'. NASA, ESA, people like that.

I. am. not. a. Java. Programmer. I can fake it, izall.
I. am. not. an. XCode. User. It seems I can't fake that, at all.

1. Create new Project type:Java Tool
--- A. Launch XCode, ver. 1.5
--- B. File->New Project...
--- C. Selected Java Tool from the list, clicked next.
--- D. Set 'Project Name' to MyProj
--- E. Set 'Project Directory' to ~/Bots/MyProj

2. Add SDK files to project
--- A. In Groups&Files, ctrl+clicked on MyProj and then Add->Existing Files...
--- B. Selected the LuxAgentSDK/sources directory

2.1 Added existing bot code, try one
--- A. Opened existing bot code and hilite/copy
--- B. Opened MyProj.java and hilite/paste
--- C. Changed project name from existing (Ravitar) to MyProj

2.2 Added existing bot code, try two
--- A. Opened existing bot code and hilite/copy
--- B. Opened MyProj.java and inserted all code just after 'public static void main...' closure brace

3. edited Project.java so "class Project implememnts LuxAgent"
--- A. At the moment, MyProj.java is 'class MyProj extends SmartAgentBase'. SAB in turns 'implements LuxAgent'. That should work, right, if I understand that much. but keep in mind: I am not a java programmer.

3. built
4. Tested to see if Lux would load the jar from the Agents directory

(I'm assuming it didn't? or did it?)

5. Added new executable "Lux" with path "/Applications/Lux.app"
--- In Files&Groups, ctrl+click and Add->New Custom Executable
--- Set Executable Name: Lux
--- Set Executable Path: /Applications/Lux.app
--- clicked Finish.
--- double-clicked 'Lux' in list of executables
--- changed settings to agree with the tiff image that you posted, link elsewhere in this thread.

6. Changed Java Archiver to output class heirarchy.
--- How?
??? Double-clicked on the Targets entry 'MyProj'
??? Clicked 'Java Archive Settings'
??? Set Product Type to 'Class heirarchy'

7. built.
--- Clicked on Targets entry 'MyProj'
--- Clicked the Build icon in the toolbar

8. Copied Project.class from Project/Build to Agents directory.

9. Launched Lux agent appeared in list.
--- HOW? From inside Xcode? From the finder?
if launched from Finder, MyProj is available, but no break points are hit.
if attempted from XCode, (Build&Go, Build&Debug, etc) I just get 'Debug session canceled: no launchable executable present to debug'. The executable 'Lux' has a blue bullet next to it, MyProj is the selected Target.

So did I screw something above up? What have we missed?

rip

Guest

Post by Guest » Fri Dec 17, 2004 9:09 pm

Ok I think I found the problem.

On the Debugging tab of the Executable info dialog. Switch from GDB to Java Debugger.

User avatar
rip
Luxer
Posts: 352
Joined: Wed Mar 31, 2004 10:22 am
Location: Vienna Austria
Contact:

Post by rip » Sun Dec 19, 2004 6:33 pm

Anonymous wrote:Ok I think I found the problem.

On the Debugging tab of the Executable info dialog. Switch from GDB to Java Debugger.
Done that.

I'm obviously missing something. Does XCode start Lux, or do I?

Guest

Post by Guest » Sun Dec 19, 2004 6:37 pm

I tried going through it a second time and it worked for me, after I caught that java debugger problem. When I debug it takes a minute and then Lux starts. The time issue may be due to the fact that my smurf is getting long in th tooth.

User avatar
guest
Luxer
Posts: 189
Joined: Fri Dec 17, 2004 9:17 pm
Location: Southern NH

Post by guest » Sun Dec 19, 2004 6:58 pm

-cut

User avatar
guest
Luxer
Posts: 189
Joined: Fri Dec 17, 2004 9:17 pm
Location: Southern NH

Post by guest » Sun Dec 19, 2004 7:01 pm

I just updated to 4.4 and now it won't debug for me either. I was using 3.8 or something.

The package has changed somewhat and its confusing the debugger use this path instead of /Applications/Lux.app

/Applications/Lux.app/Contents/MacOS/LuxDelux

User avatar
rip
Luxer
Posts: 352
Joined: Wed Mar 31, 2004 10:22 am
Location: Vienna Austria
Contact:

Post by rip » Mon Dec 20, 2004 1:15 am

guest wrote:I just updated to 4.4 and now it won't debug for me either. I was using 3.8 or something.

The package has changed somewhat and its confusing the debugger use this path instead of /Applications/Lux.app

/Applications/Lux.app/Contents/MacOS/LuxDelux
Ok.. so /that/ is what is supposed to happen.

queue maniacal laughter.

*cackle*

Thanks! And I mean that. Of course, everyone else on this board probably won't be thanking you :>

rip

raccoon
Lux Newbie
Posts: 5
Joined: Sun Jan 21, 2007 4:17 pm
Location: USA

Post by raccoon » Sun Jan 21, 2007 4:20 pm

Sorry for renewing this thread.

Since Lux has obviously been updated since the last post in this thread, the new path is

/Applications/Lux.app/Contents/MacOS/LuxDelux

User avatar
guest
Luxer
Posts: 189
Joined: Fri Dec 17, 2004 9:17 pm
Location: Southern NH

Post by guest » Tue Jan 23, 2007 12:03 pm

I'm just content to know that people are still finding it useful.

Post Reply

Who is online

Users browsing this forum: No registered users and 50 guests