Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Python or C?

 
Post new topic   Reply to topic Printable version
 View previous topic  Lots of segmentation faults? Post :: Post Staff Login  View next topic  
Author Message
Acer1001
Newbie


Joined: Jun 13 2008
Posts: 20
Offline

PostPosted: Fri Aug 14, 2009 8:46 am    Post subject: Python or C? Reply to topic Reply with quote

I'm just wondering what would probably be easier to learn? I know the basics of python, but that does not help me at all when it comes to making modules. I know a little c (A lot less c then python). I've been wanting to code a module for a while, but when I try to I get very confused after the 'from asss import *' in Python.

Fail, yes I know.

I would like some opinions from you guys since you guys are very good at coding, on what would probably be the easiest to make a module in for a nub like me.


Last edited by Acer1001 on Fri Aug 14, 2009 12:06 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Fri Aug 14, 2009 10:39 am    Post subject: Reply to topic Reply with quote

C++ or C?

For ASSS, I originally started off with Python because to me it was much easier to understand and simpler to modify. But at the time I started to use it, it had a number of shortcomings; there weren't enough examples, and the wiki tutorial felt incomplete. Later on I was passed Devastation's ASSS modules so that we could continue trying to make the transition, but everything was in C. Quite a few things available in C weren't possible in Python; at least, not without constantly making changes to pymod.c, which to me wasn't a feasible option. This was the final straw that made me switch to using C.

Personally, I think Python is a good starting point, with Python modules being easier to load/unload and make modifications in ASSS. In the long run though, you'll likely inevitably need to use or understand C. To someone who's new at coding, writing C modules for ASSS can be a little bit intimidating at first. But every trial and error will definitely help you learn and understand how things work over time.

So in all, Python gets my vote for ease of use, but I recommend also going for C. Once you learn one or the other, switching between either one isn't so difficult.
Back to top
View users profile Send private message Add User to Ignore List Send email
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Aug 14, 2009 11:07 am    Post subject: Reply to topic Reply with quote

Ultimately, it depends on what you want to do. If you're looking to do simple bot replacement on ASSS, then I'd suggest python.

If, on the other hand, you're looking to push boundaries on what can be done with ASSS and SubSpace, then you're going to need C.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Acer1001
Newbie


Joined: Jun 13 2008
Posts: 20
Offline

PostPosted: Fri Aug 14, 2009 12:03 pm    Post subject: Reply to topic Reply with quote

Alright, so in the end I'll really need C. So I guess I have to start learning that.

What do you guys suggest, online tutorials or school?

I learned the very basics from online. But that would help at all with creating modules for Asss.
Back to top
View users profile Send private message Add User to Ignore List
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Fri Aug 14, 2009 1:23 pm    Post subject: Reply to topic Reply with quote

To be honest, I had never learned C before diving into ASSS. I'm terrible with tutorials, so I learn by looking at what other people have done and by spending a lot of time searching for stuff (whether on google or this forum). Asking someone else the occasional question also helped.

It ultimately comes down to how you prefer to learn. If you're better at following tutorials, then go for it. School could be an interesting option, but note that your class may go at a slow pace and could possibly be more theory than hands-on depending on your teacher.

The ASSS wiki has a lot of good information on how to write a module and how to compile it. You should check it out. If you don't have one already, you should grab yourself a C IDE such as wxDev-C++ (any other will also do) to be able to compile a module. Start off with something simple like writing a module that sends an arena message when you type a ?command. Then slowly work your way around from there. Everything you learn at first will seem impractical and useless, but chances are you'll find a use for them sometime later on.
Back to top
View users profile Send private message Add User to Ignore List Send email
Acer1001
Newbie


Joined: Jun 13 2008
Posts: 20
Offline

PostPosted: Fri Aug 14, 2009 1:46 pm    Post subject: Reply to topic Reply with quote

Hm, I'm using Devcpp right now. I think I should probably switch to something else.

It's nice that there are templates but, it's very hard to understand. I guess it's just trial and error now.
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Fri Aug 14, 2009 1:51 pm    Post subject: Reply to topic Reply with quote

My first experiences with C came from building my own bots in C, then my own bot core. Most of that was spent looking at what others did, modifying some stuff compiling, seeing the errors, and trying again until it works.

In hindsight, it was an OK way to start, but I really picked up some bad habits. At the very least, check out the C Programming Language book. If you are lucky, it might be in your local library. It won't tell you how to be a good programmer, or how to implement algorithms, but it will explain the syntax so you won't spend your first week figuring out compile time errors.
Back to top
View users profile Send private message Add User to Ignore List Send email
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Fri Aug 14, 2009 1:52 pm    Post subject: Reply to topic Reply with quote

If you're using (wx)Dev-Cpp, don't forget this part. If it's highlighting asss.h, then this means it can't find the file. You need to tell it where to find the file (i.e. include directory). Check out Step #7 - make sure you put it in include directories, and not library directories.

Edit: woah I have no clue what I'm replying to anymore.
Back to top
View users profile Send private message Add User to Ignore List Send email
Acer1001
Newbie


Joined: Jun 13 2008
Posts: 20
Offline

PostPosted: Fri Aug 14, 2009 2:03 pm    Post subject: Reply to topic Reply with quote

Hakaku wrote:
If you're using (wx)Dev-Cpp, don't forget this part. If it's highlighting asss.h, then this means it can't find the file. You need to tell it where to find the file (i.e. include directory). Check out Step #7 - make sure you put it in include directories, and not library directories.

Edit: woah I have no clue what I'm replying to anymore.

Yeah I edited it, cause I thought I knew how to fix it. But, it didn't work, I'll look over the tutorial again.


I might just go out a buy a C book of I cannot get one for free some where. Just to give me even more background info. :/

Edit: I'm getting a little bit a head of my self but, I see chat = mm->GetInterface(I_CHAT,ALLARENAS). If I wanted to add bounty or something would it be cfg = mm->GetInterface(I_CONFIG, ALLARENAS) ?

Edit2: Also I have the asss.h in it and the directories. But it still says asss.h: No such file or directory.





Could it be that I'm suppose to be saving it in the asss folder?
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Aug 14, 2009 2:48 pm    Post subject: Reply to topic Reply with quote

you don't link with .h files, instead #include them from inside the source code (with a line that starts with #include)
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Fri Aug 14, 2009 2:52 pm    Post subject: Reply to topic Reply with quote

What Bak said. You just need to link the folder it's contained in (all of that info is already done in the tutorial). In your first screenshot, asides pthread, the rest should not be there. In your second screenshot, you did exactly what I told you not to tongue.gif You put it in the sub-tab called "Library Directories"; you really want to put all those links in the little tab named "Include Directories".
Back to top
View users profile Send private message Add User to Ignore List Send email
Acer1001
Newbie


Joined: Jun 13 2008
Posts: 20
Offline

PostPosted: Fri Aug 14, 2009 2:57 pm    Post subject: Reply to topic Reply with quote

Yeah, I got the asss.h to work now.

I don't know why I keep on getting errors with this code.

Code: Show/Hide
#include asss.h

// Interfaces
local Imodman *mm;
local Ichat *chat;

// Functions
local void ShipChange(Player *p,int newship, int newfreq)
{
   chat->SendMessage(p,"You have changed ships.");
}

// The entry point:
EXPORT int MM_template(int action, Imodman *mm_, Arena *arena)
{
   int rv = MM_FAIL; // return value

   if (action == MM_LOAD)
   {
      mm = mm_;

      chat = mm->GetInterface(I_CHAT,ALLARENAS);

      if (!chat) // check interfaces
         rv = MM_FAIL;
      else
      {
         mm->RegCallback(CB_SHIPCHANGE, ShipChange, ALLARENAS);
         rv = MM_OK;
      }
   }
   else if (action == MM_UNLOAD)
   {   
      mm->UnregCallback(CB_SHIPCHANGE, ShipChange, ALLARENAS);
      mm->ReleaseInterface(chat);
      rv = MM_OK;
   }

   return rv;
}


I got to go to work. I'll be back later and see what I can read up about syntax error before the Ichat
Back to top
View users profile Send private message Add User to Ignore List
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Fri Aug 14, 2009 3:14 pm    Post subject: Reply to topic Reply with quote

Post your error log. It may be that either you misconfigured something, or it could be a problem with Dev-Cpp itself.
Back to top
View users profile Send private message Add User to Ignore List Send email
Acer1001
Newbie


Joined: Jun 13 2008
Posts: 20
Offline

PostPosted: Fri Aug 14, 2009 3:21 pm    Post subject: Reply to topic Reply with quote

Compiler: Default GCC compiler
Building Makefile: "C:\Users\JP\Desktop\Makefile.win"
Executing make...
mingw32-make.exe -f "C:\Users\JP\Desktop\Makefile.win" all
gcc.exe -c Untitled1.c -o Output/MingW/Untitled1.o -I"C:/Program Files/Dev-Cpp/Include" -DBUILDING_DLL=1 -fexpensive-optimizations -O3

Untitled1.c:1:10: #include expects "FILENAME" or <FILENAME>
Untitled1.c:2: error: syntax error before '}' token

Untitled1.c:4: warning: data definition has no type or storage class
Untitled1.c:5: error: syntax error before "Ichat"
Untitled1.c:5: warning: data definition has no type or storage class
Untitled1.c:8: error: syntax error before "void"
Untitled1.c:8: error: syntax error before '*' token
Untitled1.c: In function `ShipChange':
Untitled1.c:10: error: request for member `SendMessage' in something not a structure or union
Untitled1.c:10: error: `p' undeclared (first use in this function)
Untitled1.c:10: error: (Each undeclared identifier is reported only once
Untitled1.c:10: error: for each function it appears in.)
Untitled1.c: At top level:
Untitled1.c:14: error: syntax error before "int"
Untitled1.c:14: error: syntax error before "Imodman"
Untitled1.c: In function `MM_template':
Untitled1.c:16: error: `MM_FAIL' undeclared (first use in this function)
Untitled1.c:18: error: `action' undeclared (first use in this function)
Untitled1.c:18: error: `MM_LOAD' undeclared (first use in this function)
Untitled1.c:20: error: `mm_' undeclared (first use in this function)
Untitled1.c:22: error: request for member `GetInterface' in something not a structure or union
Untitled1.c:22: error: `I_CHAT' undeclared (first use in this function)
Untitled1.c:22: error: `ALLARENAS' undeclared (first use in this function)
Untitled1.c:28: error: request for member `RegCallback' in something not a structure or union
Untitled1.c:28: error: `CB_SHIPCHANGE' undeclared (first use in this function)
Untitled1.c:29: error: `MM_OK' undeclared (first use in this function)
Untitled1.c:32: error: `MM_UNLOAD' undeclared (first use in this function)
Untitled1.c:34: error: request for member `UnregCallback' in something not a structure or union
Untitled1.c:35: error: request for member `ReleaseInterface' in something not a structure or union

mingw32-make.exe: *** [Output/MingW/Untitled1.o] Error 1

Execution terminated
Compilation Failed. Make returned 2


Alright, rides here, gotto go. Be back later.
Back to top
View users profile Send private message Add User to Ignore List
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Fri Aug 14, 2009 3:31 pm    Post subject: Reply to topic Reply with quote

Change your first line back to
Quote:
#include "asss.h"
Back to top
View users profile Send private message Add User to Ignore List Send email
Acer1001
Newbie


Joined: Jun 13 2008
Posts: 20
Offline

PostPosted: Fri Aug 14, 2009 5:33 pm    Post subject: Reply to topic Reply with quote

Alright. Well thanks, now it's working properly. =p Just miss read a few things.
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Aug 14, 2009 6:16 pm    Post subject: Reply to topic Reply with quote

yes, the line

"Untitled1.c:1:10: #include expects "FILENAME" or <FILENAME> "

is trying to tell you to put quotes around your filename(asss.h)

in general the first error is usually the cause of the problem (although there also may be multiple things wrong)
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Fri Aug 14, 2009 10:45 pm    Post subject: Reply to topic Reply with quote

yeah, with one error the compiler gets his syntax all messed up and is flailing blindly through the code, popping errors here and there.

That applies to pretty much every programming language too tongue.gif
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 653 page(s) served in previous 5 minutes.

phpBB Created this page in 0.561634 seconds : 43 queries executed (81.4%): GZIP compression disabled