Topic: Good programming language to learn?

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
Quote from: Bell;1335722
my pseudo code here is some weird mix between C and lua :p

Oh, I C xD


Quote from: `Kayne;1335692
Just got home from work experience.

I understand what you all have explained, But I don't understand why you would need to, apart from doing something to the whole array of items at once. Why not just make...

string cubbyholebox1;
string cubbyholebox2;
string cubbyholebox3;

if user says so and so, cubbyhole1= shoes

I'm just confused by how its different. It kinda just seems tidier D:

I thought of another use, which really might only apply to gmod, which could add a new line in the array each time it finds a specific object.

Hmm.
Time for another analogy.
Probably a bad one, because if you're anything like me, you don't. But the concept is there.





Do you put your clothes in a drawer to keep them tidy?
All t-shirts in one draw, all shorts in another...
You know where they all are. You probalby know what order they're in, since you put them in there. So you can just go grab the one you want.

Or, you can keep them strewn all around your bedroom like I do and spend 10 minutes in the morning trying to find a freak'n clean shirt to wear.




Lets say you had a pile of shirts you need to iron.
You can't manipulate variable names on the fly, so you can't go:

(shirt + i).iron();

You'll forever be going:
shirt1.iron()
shirt2.iron()
shirt3.iron()

etc.

With an array, you can iron the lot easily with a loop.

It's a much cleaner, neater, easier to maintain piece of code.

Reply #175 Posted: November 25, 2010, 07:19:07 pm
Everyone needs more Bruce Campbell.

Offline toofast

  • Addicted
  • toofast barely matters.toofast barely matters.
  • Posts: 3,697
Quote from: Pyromanik;1335604
Quote from: toofast;1335471
Cheers for that, it does sound like gtk. I will have a look today.

GTK is C, not C++.


Well there seems to be references to gtk in creating the menus etc. Maybe its a c++ file with c code in it.
Code: [Select]

//the menu:
m_refActionGroup = Gtk::ActionGroup::create();
//file menu:
m_refActionGroup->add(Gtk::Action::create("FileMenu", "File"));
m_refActionGroup->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), sigc::mem_fun(*this, &Gui::on_quit));
//view menu
m_refActionGroup->add(Gtk::Action::create("ViewMenu", "View"));
m_refActionGroup->add(Gtk::Action::create("ShowGraphs", "Graphs"), sigc::mem_fun(&graphs_window, &GraphsWindow::Show));
m_refActionGroup->add(Gtk::Action::create("ShowGPS", "GPS Plot"), sigc::mem_fun(&gpswindow, &GPSWindow::Show));
m_refActionGroup->add(Gtk::Action::create("Options", "Program Options"), sigc::mem_fun(&parameterswindow, &ParametersWindow::Show));
m_refActionGroup->add(Gtk::Action::create("StageWindow", "Create Stage Window"), sigc::mem_fun(*this, &Gui::on_create_laser_display));

//datalogging menu:
m_refActionGroup->add(Gtk::Action::create("LogMenu", "Logging"));
m_reflog_data = Gtk::ToggleAction::create("EnableLog", "Log Data?");
m_reflog_data->set_active(true);
m_refActionGroup->add(m_reflog_data, sigc::mem_fun(*this, &Gui::on_log_data_clicked));
m_refstart_new_log = Gtk::Action::create("RestartLog", "Start New Logfile");
m_refActionGroup->add(m_refstart_new_log, sigc::mem_fun(*this, &Gui::on_log_data_clicked));
//help menu:
m_refActionGroup->add(Gtk::Action::create("HelpMenu", "Help") );
m_refActionGroup->add(Gtk::Action::create("HelpAbout", Gtk::Stock::HELP), sigc::mem_fun(*this, &Gui::on_help) );

m_refUIManager = Gtk::UIManager::create();

I can handle some of the code, but i am sure he didn't create the whole thing from some text editor.

I mean heres some text box code
Code: [Select]
TextBox::TextBox(string name) : m_clearbutton("Clear") {
set_label(name);
set_size_request(270,1);
add(m_box);
m_box.pack_start(m_scrolledwindow);
m_box.pack_start(m_clearbox, PACK_SHRINK);
m_clearbox.pack_start(m_clearbutton, PACK_SHRINK);
m_clearbutton.signal_clicked().connect(sigc::mem_fun(*this, &TextBox::on_clearbutton));

//only show the scrollbars when they are necessary:
m_scrolledwindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC);
m_textview.set_editable(false);
m_scrolledwindow.add(m_textview);
m_reftextbuffer = TextBuffer::create();
m_textview.set_buffer(m_reftextbuffer);
//for scrolling to the bottom:
m_mark = m_reftextbuffer->create_mark(m_reftextbuffer->end(), false);
}

void TextBox::AddText(string const& text) {
m_reftextbuffer->insert(m_reftextbuffer->end(), text);
m_textview.scroll_to(m_mark);
}
void TextBox::on_clearbutton() {
m_reftextbuffer->set_text("");
}

While i can figure out what is doing, I am not sure how I will add more things to this structure in a text editor without spending a lot of time. So hopefully someone here can make some head way into this.

Reply #176 Posted: November 25, 2010, 07:49:37 pm

Offline Kayne

  • Addicted
  • Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!
  • Posts: 3,298
is tic tac toe meant to be 2 player or have a computer ai

Reply #177 Posted: November 25, 2010, 07:51:20 pm
Quote
Top Geary - 27th May 2016 at 12:10 AM
I've learnt to ignore when you say derogatory things to me

Offline Bell

  • Addicted
  • Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.
  • Posts: 4,263
tic tac toe is a good wee project to first do some ai on since the search space is so small.

Reply #178 Posted: November 25, 2010, 07:56:24 pm

Offline Kayne

  • Addicted
  • Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!
  • Posts: 3,298
/friendrequest

Anyone that I can add to friendlist to get 24/7 help? :P

Reply #179 Posted: November 25, 2010, 08:37:26 pm
Quote
Top Geary - 27th May 2016 at 12:10 AM
I've learnt to ignore when you say derogatory things to me

Offline Spoonguard

  • Addicted
  • Spoonguard has no influence.
  • Posts: 2,327
You are right that arrays are a abstraction. But without them, the language syntax would be much less flexible. In most languages your cubbyhole example would require some sort of for loop with some string concatenation to query every cubbyhole in whatever set, which is much harder than using a numbered array.

The most common application of Arrays is bitmaps. Lets consider a 16x16 picture, with colour, an icon if you will. To store this, we can use a array like int icon [16][16] for instance. We can then draw a icon with 3 small squares in red, green and blue by defining each pixel in code:

Code: [Select]
#DEFINE white 0xFFFFFF
#DEFINE red 0xFF0000
#DEFINE green 0x00FFF0
#DEFINE blue 0x0000FF

icon[1],[1] = white; icon[2][1] = white ; icon[3][1] = white ; icon[4][1] = white ; icon[5][1] = white ; icon[6][1] = white ; icon[7][1] = white ; icon[8][1] = white ; icon[9][1] = white ; icon[10][1] = white ; icon[11][1] = white ; icon[12][1] = white ; icon[13][1] = white ; icon[14][1] = white ; icon[15][1] = white ; icon[16][1] = white ;
icon[2][2] = red ; icon[3][2] = red ; icon[4][2] = white ; icon[5][2] = white ; icon[6][2] = white ; icon[7][2] = white ; icon[8][2] = white ; icon[9][2] = white ; icon[10][2] = white ; icon[11][2] = white ; icon[12][2] = white ; icon[13][2] = white ; icon[14][2] = white ; icon[15][2] = white ; icon[16][2] = white ;
icon[2][3] = red ; icon[3][3] = red ; icon[4][3] = white ; icon[5][3] = white ; icon[6][3] = white ; icon[7][3] = white ; icon[8][3] = white ; icon[9][3] = white ; icon[10][3] = white ; icon[11][3] = white ; icon[12][3] = white ; icon[13][3] = white ; icon[14][3] = white ; icon[15][3] = white ; icon[16][3] = white ;
icon[2][4] = white ; icon[3][4] = white ; icon[4][4] = green ; icon[5][4] = green ; icon[6][4] = white ; icon[7][4] = white ; icon[8][4] = white ; icon[9][4] = white ; icon[10][4] = white ; icon[11][4] = white ; icon[12][4] = white ; icon[13][4] = white ; icon[14][4] = white ; icon[15][4] = white ; icon[16][4] = white ;
icon[2][5] = white ; icon[3][5] = white ; icon[4][5] = green ; icon[5][5] = green ; icon[6][5] = white ; icon[7][5] = white ; icon[8][5] = white ; icon[9][5] = white ; icon[10][5] = white ; icon[11][5] = white ; icon[12][5] = white ; icon[13][5] = white ; icon[14][5] = white ; icon[15][5] = white ; icon[16][5] = white ;
icon[2][6] = white ; icon[3][6] = white ; icon[4][6] = white ; icon[5][6] = white ; icon[6][6] = blue ; icon[7][6] = blue ; icon[8][6] = white ; icon[9][6] = white ; icon[10][6] = white ; icon[11][6] = white ; icon[12][6] = white ; icon[13][6] = white ; icon[14][6] = white ; icon[15][6] = white ; icon[16][6] = white ;
icon[2][7] = white ; icon[3][7] = white ; icon[4][7] = white ; icon[5][7] = white ; icon[6][7] = blue ; icon[7][7] = blue ; icon[8][7] = white ; icon[9][7] = white ; icon[10][7] = white ; icon[11][7] = white ; icon[12][7] = white ; icon[13][7] = white ; icon[14][7] = white ; icon[15][7] = white ; icon[16][7] = white ;
icon[2][8] = white ; icon[3][8] = white ; icon[4][8] = white ; icon[5][8] = white ; icon[6][8] = white ; icon[7][8] = white ; icon[8][8] = white ; icon[9][8] = white ; icon[10][8] = white ; icon[11][8] = white ; icon[12][8] = white ; icon[13][8] = white ; icon[14][8] = white ; icon[15][8] = white ; icon[16][8] = white ;
icon[2][9] = white ; icon[3][9] = white ; icon[4][9] = white ; icon[5][9] = white ; icon[6][9] = white ; icon[7][9] = white ; icon[8][9] = white ; icon[9][9] = white ; icon[10][9] = white ; icon[11][9] = white ; icon[12][9] = white ; icon[13][9] = white ; icon[14][9] = white ; icon[15][9] = white ; icon[16][9] = white ;
icon[2][10] = white ; icon[3][10] = white ; icon[4][10] = white ; icon[5][10] = white ; icon[6][10] = white ; icon[7][10] = white ; icon[8][10] = white ; icon[9][10] = white ; icon[10][10] = white ; icon[11][10] = white ; icon[12][10] = white ; icon[13][10] = white ; icon[14][10] = white ; icon[15][10] = white ; icon[16][10] = white ;
icon[2][11] = white ; icon[3][11] = white ; icon[4][11] = white ; icon[5][11] = white ; icon[6][11] = white ; icon[7][11] = white ; icon[8][11] = white ; icon[9][11] = white ; icon[10][11] = white ; icon[11][11] = white ; icon[12][11] = white ; icon[13][11] = white ; icon[14][11] = white ; icon[15][11] = white ; icon[16][11] = white ;
icon[2][12] = white ; icon[3][12] = white ; icon[4][12] = white ; icon[5][12] = white ; icon[6][12] = white ; icon[7][12] = white ; icon[8][12] = white ; icon[9][12] = white ; icon[10][12] = white ; icon[11][12] = white ; icon[12][12] = white ; icon[13][12] = white ; icon[14][12] = white ; icon[15][12] = white ; icon[16][12] = white ;
icon[2][13] = white ; icon[3][13] = white ; icon[4][13] = white ; icon[5][13] = white ; icon[6][13] = white ; icon[7][13] = white ; icon[8][13] = white ; icon[9][13] = white ; icon[10][13] = white ; icon[11][13] = white ; icon[12][13] = white ; icon[13][13] = white ; icon[14][13] = white ; icon[15][13] = white ; icon[16][13] = white ;
icon[2][14] = white ; icon[3][14] = white ; icon[4][14] = white ; icon[5][14] = white ; icon[6][14] = white ; icon[7][14] = white ; icon[8][14] = white ; icon[9][14] = white ; icon[10][14] = white ; icon[11][14] = white ; icon[12][14] = white ; icon[13][14] = white ; icon[14][14] = white ; icon[15][14] = white ; icon[16][14] = white ;
icon[2][15] = white ; icon[3][15] = white ; icon[4][15] = white ; icon[5][15] = white ; icon[6][15] = white ; icon[7][15] = white ; icon[8][15] = white ; icon[9][15] = white ; icon[10][15] = white ; icon[11][15] = white ; icon[12][15] = white ; icon[13][15] = white ; icon[14][15] = white ; icon[15][15] = white ; icon[16][15] = white ;
icon[2][16] = white ; icon[3][16] = white ; icon[4][16] = white ; icon[5][16] = white ; icon[6][16] = white ; icon[7][16] = white ; icon[8][16] = white ; icon[9][16] = white ; icon[10][16] = white ; icon[11][16] = white ; icon[12][16] = white ; icon[13][16] = white ; icon[14][16] = white ; icon[15][16] = white ; icon[16][16] = white ;

Now, if we only need 8x8 of the 16x16 icon, we can manipulate the array thus:

Code: [Select]
for (int x=1, int y=1, x<8, y<8, x++, y++)
{
print(x,y)
return 0;
}

Reply #180 Posted: November 25, 2010, 08:46:33 pm
        and nothing of value was lost.

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
You should be able to do both (2p & ai) really easy Kayne.

Reply #181 Posted: November 25, 2010, 08:49:05 pm
Everyone needs more Bruce Campbell.

Offline Kayne

  • Addicted
  • Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!
  • Posts: 3,298
Quote from: Pyromanik;1335750
You should be able to do both (2p & ai) really easy Kayne.

Both are easy if my idea of arrays is correct. But I want to talk to someone about this lol, so virus can't steal my ideas. :P

Fine. I'll work out arrays myself then :<

I can't :<

Reply #182 Posted: November 25, 2010, 08:50:40 pm
Quote
Top Geary - 27th May 2016 at 12:10 AM
I've learnt to ignore when you say derogatory things to me

Offline Kayne

  • Addicted
  • Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!
  • Posts: 3,298
FUCK YOU MULTI DIMENSIONAL ARRAYS.

Reply #183 Posted: November 25, 2010, 09:27:29 pm
Quote
Top Geary - 27th May 2016 at 12:10 AM
I've learnt to ignore when you say derogatory things to me

Offline Tiwaking!

  • Hero Member
  • Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!
  • Posts: 12,583
Quote from: `Kayne;1335762
FUCK YOU MULTI DIMENSIONAL ARRAYS.
Quote from: Tiwaking!;1333600
Five dimensional arrays are your friend

I'll give you some help with the tic tac toe thing, not alot of help since it is in java.
Code: [Select]
JPanel&#91;]squares=new JPanel[9];

for(int i=0;i&lt;squares.length;i++){
squares[i]=new JPanel();
}
Normally I would EXTEND the JPanel to hold a custom picture and call the JPanel's "GamePanel". That way you can use them to hold the player as well so when you check through the played tiles you just need to do a simpley for loop thingy.

Tic tac toe is hard to write, despite what the huge nerds say in this thread. You can give this a go. It was an old alpha version of my flat mates "Keith n Crosses" game so it has alot of bugs the finished version does not.

See if you can figure out how it was made.

http://tiwaking.hostzi.com/keithncrosses/index.html

Reply #184 Posted: November 25, 2010, 10:32:13 pm
I am now banned from GetSome

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
Quote from: `Kayne;1335762
FUCK YOU MULTI DIMENSIONAL ARRAYS.


You can figure them out.
Virus ragequit and played TF2 instead of studying last night, so you've got time (apart from the fact it's not a race... and he's using a different language).

Assuming the language is similar to C, you can access a multidimension array with two (or more) []'s.
Code: [Select]
board[horizontal-index][vertical-index]
Hopefully that helps you visualise it in your head :)





Quote from: Tiwaking!;1335782
Quote from: `Kayne;1335762
FUCK YOU MULTI DIMENSIONAL ARRAYS.
Quote from: Tiwaking!;1333600
Five dimensional arrays are your friend

I'll give you some help with the tic tac toe thing, not alot of help since it is in java.
Code: [Select]
JPanel[]squares=new JPanel[9];

for(int i=0;i<squares.length;i++){
squares[i]=new JPanel();
}
Normally I would EXTEND the JPanel to hold a custom picture and call the JPanel's "GamePanel". That way you can use them to hold the player as well so when you check through the played tiles you just need to do a simpley for loop thingy.

Tic tac toe is hard to write, despite what the huge nerds say in this thread. You can give this a go. It was an old alpha version of my flat mates "Keith n Crosses" game so it has alot of bugs the finished version does not.

See if you can figure out how it was made.

http://tiwaking.hostzi.com/keithncrosses/index.html


JPanel sounds awfully non-console...
And that's a single dimension array!

Noughts and crosses isn't hard to write. It's more about having the commitment to see it through.

Reply #185 Posted: November 26, 2010, 10:34:04 am
Everyone needs more Bruce Campbell.

Offline AintNoMeInTeam

  • Devoted Member
  • AintNoMeInTeam has no influence.
  • Posts: 1,792
lol, this has made me want to write a naughts and crosses AI that plays optimally *pulls out notes on minimax algorithm*

Reply #186 Posted: November 26, 2010, 11:41:47 am
Quote
Nobody will ever win the battle of the sexes...there\'s too much fraternizing with the enemy.
-Henry Kissinger

Offline Apostrophe Spacemonkey

  • Fuck this title in particular.

  • Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!
  • Posts: 19,050
Quote from: Xenolightning;1335680
Also, how is the game strange?

lol, it was a quote from Wargames, awesome movie.

Reply #187 Posted: November 26, 2010, 12:03:31 pm

Offline Xenolightning

  • Moderator
  • Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!Xenolightning is awe-inspiring!
  • Posts: 3,485
Quote from: Spacemonkey;1335865
Quote from: Xenolightning;1335680
Also, how is the game strange?
lol, it was a quote from Wargames, awesome movie.
Whooooosh, over and gone for six!

Reply #188 Posted: November 26, 2010, 03:18:39 pm
-= Sad pug is sad =-

Offline Anaraith

  • Addicted
  • Anaraith has no influence.
  • Posts: 2,813
Haha you guys are doing my first trimester assignment for scripting. I learnt a bit but not as much as I would have liked cos the tutor didn't know how to teach and instead of explaining what we had to do he would take our keyboards and just write it himself :<

I made it in the end tho :D

Reply #189 Posted: November 26, 2010, 04:01:57 pm
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :
Spoiler :

Pokemon arent real but they should be.

Offline Spoonguard

  • Addicted
  • Spoonguard has no influence.
  • Posts: 2,327
a most strange thread. the only way to win is not to post

Reply #190 Posted: November 26, 2010, 04:49:46 pm
        and nothing of value was lost.

Offline Bell

  • Addicted
  • Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.Bell is on the verge of being accepted.
  • Posts: 4,263
Sums up internet forums really well.

Reply #191 Posted: November 26, 2010, 05:33:04 pm

Offline Kayne

  • Addicted
  • Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!
  • Posts: 3,298
okay So i'm trying to work out how to make it that the program will realise strings regardless of their case's (i'm meaning case - sensitive)

But it keeps saying the multi dimensional array is wrong...

people.. just yell at me what i'm doing wrong here :P

Code: [Select]
 public class Variables
  {
    public static string[, , ,] Easy; {{&quot;E&quot;,&quot;A&quot;,&quot;S&quot;,&quot;Y&quot;},{&quot;e&quot;,&quot;a&quot;,&quot;s&quot;,&quot;y&quot;}}
  }


I'm not quite sure how i'ld access this. I was just hoping it would look like this.

Code: [Select]
[E] [A] [S] [Y]
[e] [a] [s] [y]

And I could tell it to look at either the top or bottom lines, and try and match up the word.

btw, I was watching the hitch hikers guide to the universe / galaxy last night, And there was a part that made me think about computers having thoughts. Then I became super keen to program. Does that make me nerdy? :P



EDIT : for some reason, it has a problem with the first curly bracket "{" after "...[, , ,] Easy;..."




Changing the code around abit after some googling, Everything is fine except for each letter, regardless of it being in quotes, gives the error "a nested array initialiser is expected"

Code: [Select]
   {

      public static string[, , ,] Easy = { {E,A,S,Y},{e,a,s,y} };
    }

But, I thought string[, , ,] Easy = WAS the initialiser?

Reply #192 Posted: November 26, 2010, 05:43:31 pm
Quote
Top Geary - 27th May 2016 at 12:10 AM
I've learnt to ignore when you say derogatory things to me

Offline Apostrophe Spacemonkey

  • Fuck this title in particular.

  • Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!
  • Posts: 19,050
Just do a string.ToLowerCase();

Then match the result of that.


string name = "SpAcEMONkey";

string lowerCaseName = name.ToLowerCase();


Reply #193 Posted: November 26, 2010, 06:47:22 pm

Offline Apostrophe Spacemonkey

  • Fuck this title in particular.

  • Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!
  • Posts: 19,050
Quote from: `Kayne;1335973
Code: [Select]
 public class Variables
  {
    public static string[, , ,] Easy; {{&quot;E&quot;,&quot;A&quot;,&quot;S&quot;,&quot;Y&quot;},{&quot;e&quot;,&quot;a&quot;,&quot;s&quot;,&quot;y&quot;}}
  }

You only want a 2d array, i.e string[,]

string[, , ,] is a 4d array.

Reply #194 Posted: November 26, 2010, 06:51:08 pm

Offline Tiwaking!

  • Hero Member
  • Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!Tiwaking! is awe-inspiring!
  • Posts: 12,583
Quote from: Pyromanik;1335849
JPanel sounds awfully non-console...
And that's a single dimension array!
JPanel is a good example since you can put an array on it, so if you want to put, say, 'power-ups' on the squares which are random you can have it calculate that all for you.

Because I have trouble telling left/right and up/down with two dimensional arrays in Java (but not Commodore BASIC), I usually stick with one dimensional arrays of objects, which contain an array. So for tic-tac-toe:
Code: [Select]
public class BoardRow extends JPanel{

JPanel&#91;]lines=new JPanel[3];

}//class
Then have:

BoardRow row1=new BoardRow();
BoardRow row2=new BoardRow();
BoardRow row3=new BoardRow();

OR

Code: [Select]
public class Board extends JPanel{
BoardRow[]rows=new BoardRow[3];
}//class
This way you can keep all the relevant code for working out stuff in the Board and BoardRows.

This isnt how I would personally do it, but its a simple concept.

Quote from: Pyromanik;1335849
Noughts and crosses isn't hard to write. It's more about having the commitment to see it through.
Commitment is the last refuge of the learner and the first stop for huge nerds.


I'd like to help `Kayne, but I spent two hours in class crying, cursing and gnashing my teeth at Visual Studio and C# in general. It took forever to get my cow to shoot milk bottles at a baby.

A huge downgrade from 8-Bit Starcraft.

Reply #195 Posted: November 26, 2010, 06:59:16 pm
I am now banned from GetSome

Offline Kayne

  • Addicted
  • Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!
  • Posts: 3,298
Cheers but i'm still not out of the woods yet, based off dificulty i was planning to use an array to list the possible moves that the bot would do...

I can't see how to make the player win.. If i'm going to make a bot I want it to never lose lol

Reply #196 Posted: November 26, 2010, 07:01:02 pm
Quote
Top Geary - 27th May 2016 at 12:10 AM
I've learnt to ignore when you say derogatory things to me

Offline Apostrophe Spacemonkey

  • Fuck this title in particular.

  • Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!Apostrophe Spacemonkey is awe-inspiring!
  • Posts: 19,050
Quote from: `Kayne;1336005

I can't see how to make the player win.. If i'm going to make a bot I want it to never lose lol

Um, you know it's Tic-Tac-Toe right?


It always ends in a draw, unless one player does a stupid mistake.

[video]NHWjlCaIrQo[/video]

Reply #197 Posted: November 26, 2010, 07:04:12 pm

Offline Kayne

  • Addicted
  • Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!Kayne is awe-inspiring!
  • Posts: 3,298
Quote from: Spacemonkey;1336008
Quote from: `Kayne;1336005

I can't see how to make the player win.. If i'm going to make a bot I want it to never lose lol

Um, you know it's Tic-Tac-Toe right?


It always ends in a draw, unless one player does a stupid mistake.

Yeah I know. lol
Quote from: Spacemonkey;1336002
Just do a string.ToLowerCase();

Then match the result of that.


string name = "SpAcEMONkey";

string lowerCaseName = name.ToLowerCase();



Also thanks :)

Reply #198 Posted: November 26, 2010, 07:15:16 pm
Quote
Top Geary - 27th May 2016 at 12:10 AM
I've learnt to ignore when you say derogatory things to me

Offline Pyromanik

  • Hero Member
  • Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!Pyromanik is awe-inspiring!
  • Posts: 28,834
where an inbuilt switch for case insensitive comparison doesn't exist I'd use a regex, but that's because I'm a huge nerd apparently.

Reply #199 Posted: November 27, 2010, 12:24:35 am
Everyone needs more Bruce Campbell.