Barbarrosa 0 Light Poster

Hello,

I am currently attempting to write some code in Matlab which will allow me to output information to a USB port (which is changed into a PPM signal however this part is already accomplished by some hardware). I have an example of how to use the PCTx-PC to transmitter interface in Windows but I am working in Linux. http://www.endurance-rc.com/pctx.html I have what may be a relatively simple question. In the example code it has this:

//Send new channel data to the PCTx/Servo Controller

bool controller::send(int delay1, int delay2, int delay3, int delay4, int delay5, int delay6, int delay7, int delay8, int delay9){

	OutputReport[0] = 0;  //do not remove, must be 0



	OutputReport[1] = delay1; //ch1

	OutputReport[2] = delay2; //ch2

	OutputReport[3] = delay3; //ch3



	OutputReport[4] = delay4; //ch4

	OutputReport[5] = delay5; //ch5

	OutputReport[6] = delay6; //ch6



	OutputReport[7] = delay7; //ch7

	OutputReport[8] = delay8; //ch8

	OutputReport[9] = delay9; //ch9



	if(!WriteFile(DeviceHandle, OutputReport, Capabilities.OutputReportByteLength, &BytesWritten, NULL)) {

		CloseHandle(DeviceHandle);

		connected = false;

		return false;

	}



	return true;

}

OutputReport[ ] is a char type and delay is int... So my first question is how does this really work without converting int (4 bytes) into char(1 byte)? The values for int vary between 0 and 255 so does the program simply knock off everything else?

Now in order to output this to the device in Linux/matlab all I need to do is open a handle on the device and simply use the write(handle,value...) and all the hand shaking will be …

Barbarrosa 0 Light Poster

OK. So basically I am creating a website and I would like add a feature where I can access websites from my own websites. If you don't know where I'm going then its basically simple. I would like to get onto blocked websites on my school network whenever I want to. Could you guys please help me out a bit... All I want is a point in the right direction (but preferebly some ready-to-use code that I can just throw onto my website and me done with it).

Anyways thanks for your help

Regards

Barbarrosa

Barbarrosa 0 Light Poster

its the tif that i cant delete after I've saved it and used it for MODI. basically look at the bitonalImage.Save line

Barbarrosa 0 Light Poster

Sorry, should have posted that as well...

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at BitonalConverter.Form1.OCRProcess(Int32 StartX, Int32 StartY, Int32 EndX, Int32 EndY, String file) in C:\Documents and Settings\user\Desktop\Bitonal\BitonalImageConverter_src\Bitonal\Bitonal.cs:line 58
at BitonalConverter.Form1.Process_Click(Object sender, EventArgs e) in C:\Documents and Settings\user\Desktop\Bitonal\BitonalImageConverter_src\Bitonal\Bitonal.cs:line 111
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Maybe this will help... I tried to delete the Bitmap after and was getting a "File used in another process error" which i also posted on another thread

Barbarrosa 0 Light Poster

oo wait your going to have to modify it a little.. i was playing around with it so your going to have to add a string parameter to the OCRprocess and delete the string file already in place.

Barbarrosa 0 Light Poster

Dont work... heres the rest of the code that will allow you to run the program.

private static Bitmap bmpScreenshot;
        private static Graphics gfxScreenshot;

        public Form1()
        {
            InitializeComponent();
        }

private void convert_Click(object sender, EventArgs e)
        {
            string file = @"c:\Temp.tif";
            this.Hide();
            bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
            gfxScreenshot = Graphics.FromImage(bmpScreenshot);
            gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
            this.Show();

            label1.Text = OCRProcess(807, 74, 947, 92,file);
            label2.Text = OCRProcess(807, 92, 947, 110,file);
        }

        private static ImageCodecInfo GetEncoderInfo(String mimeType)
        {
            int j;
            ImageCodecInfo[] encoders;
            encoders = ImageCodecInfo.GetImageEncoders();
            for (j = 0; j < encoders.Length; ++j)
            {
                if (encoders[j].MimeType == mimeType)
                    return encoders[j];
            }
            return null;
        }
Barbarrosa 0 Light Poster

I am fairly new to C# lol so can you please write down in code by what you mean. I've been trying to chase down the source of this "generic error in GDI+" for over a week. I tried to delete the file after I saved it which is when i get the "file being used...". this is the code that I am using:

string OCRProcess(int StartX, int StartY, int EndX, int EndY)
        {
            
            string file = @"c:\Bitonal-Out.tif";            
            Bitmap CutImage = new Bitmap(EndX - StartX, EndY - StartY);       

            for (int x = StartX; x < EndX; x++)
            {
                for (int i = StartY; i < EndY; i++)
                    CutImage.SetPixel(x - StartX, i - StartY, bmpScreenshot.GetPixel(x, i));
            }

            Bitmap rgbBitmap = Converter.ConvertToRGB(CutImage);

            Bitmap bitonalBitmap = Converter.ConvertToBitonal(rgbBitmap);

            ImageCodecInfo imageCodecInfo = GetEncoderInfo("image/tiff");
            System.Drawing.Imaging.Encoder encoder = System.Drawing.Imaging.Encoder.Compression;
            EncoderParameters encoderParameters = new EncoderParameters(1);

            EncoderParameter encoderParameter = new EncoderParameter(encoder, (long)EncoderValue.CompressionCCITT4);
            encoderParameters.Param[0] = encoderParameter;
            
            bitonalBitmap.Save(file, imageCodecInfo, encoderParameters);

            MODI.Document doc = new MODI.Document();
            doc.Create(file);

            doc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, false, false);

            MODI.Image img = (MODI.Image)doc.Images[0];

            doc.Close(false);
            encoderParameter.Dispose();
            CutImage.Dispose();
            bitonalBitmap.Dispose();

            return img.Layout.Text;
        }

The above function simply simply cuts an image from the screenshot, converts it to tiff, and does OCR on it. when i try to delete the file "bitonal-out.tif" i get the error message being use... Your help is greatly appreciated...

Barbarrosa 0 Light Poster

Does anyone know how to close a file? I saved an image... then when i try and save the image to the same filename.. or delete the file after i saved it... i get an error which states that the file is being used by another process. Has anyone come across a problem like this and if so how could I get around it?

Barbarrosa 0 Light Poster

I added a
try
{
code
}
catch...
Im finding that every second time I click the button, it works... if that helps anyone to understand this better...

Barbarrosa 0 Light Poster

Hello,
I am getting a General GDI+ Error according to the Visual C# debugger. i have no idea as to how to handle this problem. I have a button which i click and a section of the screen is cut and put into a bitmap. This is converted into tiff format which is sent for OCR using MODI. The first time I click the button it works, however, when i click the button again, I get a the error. Here is the line it is being pointed to:

bitonalBitmap.Save(@"c:\Bitonal-Out.tif", imageCodecInfo, encoderParameters);

Can anyone help me please.
Thanks in advance.

Barbarrosa 0 Light Poster

Can someone please explain to me how to use CopyFromScreen. I'm trying to cut out a piece of the screenshot and then convert to tiff using the encoder tiffbitmapencoder. This will later be passed on to the OCR MODI function to get the text from the image. However, as always, I have no clue as to what I am doing. I looked on the msdn site and am left in confusion as to what the parameters actually mean. (http://msdn2.microsoft.com/en-us/library/fw1kt6f9.aspx). Im guessing the coordinates of the source rectangle mean the bottom right corner and destination means top left corner. I found some sample code on the internet (forget where) and it looks like this to take the screenshot:

private static Bitmap bmpScreenshot;
private static Graphics gfxScreenshot;

bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);           gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);

Is it even possible to use this to get a portion of the screenimage? My best guess as of now is it would look like this:

gfxScreenshot.CopyFromScreen(bottomrightX,bottomrightY,topleftX,topleftY,SIZE. Copy...)

SIZE would be simply the BPMIMAGE.Size where BMPIMAGE is the portion I want to cut out. If I've got this all wrong could someone please explain how to do this properly? I know one method of doing it which is by copying pixel for pixel the image but im hoping there is a more direct method of doing this. As well, if you could give a few pointers on converting to tiff if you've got any. I …

Barbarrosa 0 Light Poster

My errors are:
Newline in Constant.
} expected
; expected
All these errors are being pointed at the end of the array.
Thanks a lot though.

Barbarrosa 0 Light Poster

Aight well i decided to manually make an array but now I am getting a few errors and I have no clue as to what i should do/am doing. could someone take a look at this lol

string[] StringLib = new string[90] { "0", "1", "2", "3", "4", "5", 
            "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i",
            "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
            "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I",
            "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
            "W", "X", "Y", "Z", "~", "`", "!", "@", "#", "$", "%", "^", "&", 
            "*", "(", ")", "-", "=", "_", "+", "[", "]", ";", "'", "<",
            ">", "/", ".", ";", ":","\","|" };

Im getting a few errors and im not sure if im missing something.. i dunno ive been staring at this with a blank face for a while now too. if you spot something please give me a shout.
Thanks in advance again.

Barbarrosa 0 Light Poster

Hey, I am currently trying to read a text file, which looks something like this:
1
2
3
4
.
.
a
b
c
.
.
.
I would like to read the integers and characters into the same array. I tried using a char, string.. hoping that it would be recognized as a string or something but I continuously get the compiling error "cannot implicity convert 'int' to 'string'. Does anyone know what im talking about and if so how could i get around this problem.
Thanks in advance.

Barbarrosa 0 Light Poster

Aight well I figured that the simplest way of getting the text would be to directly check bit for bit if its the same letter. What I got so far is I am trying to seperate each letter from an image. Then I go letter to letter line to line searching for the letter. Heres what i got

private void button2_Click(object sender, EventArgs e)
        {
            int[,] ImageArray = new int [13,13];
            int index = 0;
            bool First = false;

            Form1 Method = new Form1();
            StreamWriter SW = File.CreateText("Array.txt"); ;
            

            Method.InitializeArray(ImageArray);

            this.Hide();
            bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
            gfxScreenshot = Graphics.FromImage(bmpScreenshot);
            gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
            this.Show();

            for (int x = 158; x <= 684; x++)
            {
                for (int i = 710; i <= 826; i++)
                {
                    CutImage.SetPixel(x - 158, i - 710, bmpScreenshot.GetPixel(x, i));
                }
            }

            for (int x = 0; x < 527; x++)
            {
                for (int y = 0; y < 13; y++)
                {
                    if (CutImage.GetPixel(x, y) == CutImage.GetPixel(2, 3))
                    {
                        goto copy;
                    }
                }
                goto newletter;

            copy:
                for (int y = 0; y < 13; y++)
                {
                    if (CutImage.GetPixel(x, y) == CutImage.GetPixel(1, 2) && index<13)
                        ImageArray[index, y] = 1;
                }
                index++;
                continue;

            newletter:
                if (First == false)
                {
                    for(int y=0; y < 13; y++)
                    {
                        for(int a = 0; a < 13; a++)
                        {
                            SW.Write(ImageArray[a, y]);
                        }
                        SW.WriteLine();

                    }
                    First = true;
                }
                Method.InitializeArray(ImageArray);
                index = 0;
            }
            SW.Close();
        }

Im just trying to get the first letter as a test. Where InitializeArray just sets …

Barbarrosa 0 Light Poster

Hello,

I am fairly new to GDI+ and I am trying to make a DLL file in visual C++ which uses a basic neural network for OCR. My question is this: How can I manipulate bitmap images in visual c++? I know how to do it in Visual C# and I have also read that in the .NET framework I am able to use DLL files from any syntax in any other syntax?!?! (Or am i mistaken) Anyway, is it possible to pass a bitmap from VC# to a VC++ DLL file? If it is, could you please write down the starting out code or show me some links that describe what I'm looking for.

Thanks in advance,

Barbarrosa 0 Light Poster

Hello, I am new to C#. What i am trying to do is this: I am taking a screenshot of my desktop (which i have done and stored in a file). Now all I need is to be able to define the parts of the image which I wish to extract from the larger picture. So for example, I have a screenshot. I would like to click my mouse in the top left corner of the part of the screen shot and then the bottom right. After this i just need to store that in a file... Can anyone help me????

Thanks in advance.

Barbarrosa 0 Light Poster

Thanks for replying. All my double arrays are suppose to start at index 1... and i have 14 columns in my cards[4][14] because i have a position for an A at the beginning and the end so I can search for straights etc. i dunno ill have to polish up my code a bit lol. My shuffled_deck and all 1 dimensional arrays start at 0. How can I change the index or starting point so to speak to 1? Thanks a lot for your help/input.

Barbarrosa 0 Light Poster

and thanks in advance

Barbarrosa 0 Light Poster

how do i add numbers to my lines too if someone knows that

Barbarrosa 0 Light Poster

Hey guys,
I've been working on a poker hand recognition assignment and ive been playing around with it for a week getting one problem after the next. Below is my code I have so far.

#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>

#define iteration_max 10000000

using std::cin;
using std::cout;
using std::string;
using std::endl;

int cards[4][14];
int player_cards[2][2];   
int shuffled_deck [51];
int board_cards[4];
int player_hand[5];

int card;
int i;int x;
int showing;
   
void shuffle_deck(){
   int dealt_cards[51];int equal;
   srand((unsigned)time(0));
   
   for (i=0;i<52;i++)dealt_cards[i] = -1;

   for (i=0;i<52;i++)
   {  equal = 0;
      while(equal!=1)
      {  shuffled_deck[i] = rand()%52;
         if (dealt_cards[shuffled_deck[i]]!=0)
         {  dealt_cards[shuffled_deck[i]]++;equal=1;}}}
}  

void update(int start){
   for (i=start;i<showing;i++)
   {  if(board_cards[i]<13)cards[1][board_cards[i]+1]++; 
      else if((board_cards[i])<26)cards[2][board_cards[i]%13+1]++;
      else if(board_cards[i]<39)cards[3][board_cards[i]%26+1]++;
      else cards[4][board_cards[i]%39+1]++;
         
      if((board_cards[i]%39)==0)cards[4][14]++;
      else if((board_cards[i]%26)==0)cards[3][14]++;
      else if((board_cards[i]%13)==0)cards[2][14]++; 
      else if(board_cards[i]==0)cards[1][14]++;}
} 

void deal_cards(){
   card = 0;   
   for (i=1;i<3;i++)
   {  for (x=1;x<3;x++){player_cards[x][i] = shuffled_deck[card];card++;}} 
}

void flop(){
   for (i=0;i<3;i++){board_cards[i]=shuffled_deck[card];card++;}
   showing = 3;update(0);  
}

void turn(){
   board_cards[3]=shuffled_deck[card];
   showing++;update(3);card++; 
}

void river(){
   board_cards[4]=shuffled_deck[card];
   showing++;update(4);card++; 
}

void add_subtract(int player,int NUM){
   for(i=1;i<3;i++){  
      if(player_cards[player][i]<13)cards[1][player_cards[player][i]+1]+=NUM; 
      else if((player_cards[player][i])<26)cards[2][player_cards[player][i]%13+1]+=NUM;
      else if(board_cards[i]<39)cards[3][player_cards[player][i]%26+1]+=NUM;
      else cards[4][player_cards[player][i]%39+1]+=NUM;
      
      if((player_cards[player][i]%39)==0)cards[4][14]+=NUM;
      else if((player_cards[player][i]%26)==0)cards[3][14]+=NUM;
      else if((player_cards[player][i]%13)==0)cards[2][14]+=NUM; 
      else if(player_cards[player][i]==0)cards[1][14]+=NUM;}
}

bool check_pair(int player_hand[]){
   int pair=0;int temp=0;int cardpos=5;int seccardpos=3; 
   for(i=14;i>1;i--)
   {  temp=0;
      for(x=1;x<5;x++)
      {  temp+=cards[x][i];}
      if(temp!=2)
         temp=0;
      else if(temp!=2&&player_hand[cardpos]%13<cards[x][i]%13&&seccardpos>0)
         {  for(x=1;x<5;x++)
            if(cards[x][i]!=0)player_hand[seccardpos]=cards[x][i];
          seccardpos--;}
      else if(pair=0)
      {  for(x=1;x<5;x++)
            if(cards[x][i]!=0)player_hand[cardpos]=cards[x][i];cardpos--;}
         pair=1;}
   if(pair=1)return true;
}

void find_poker_hand(int player,int player_hand[]){   
   add_subtract(player,1);
   check_pair(player_hand);
   add_subtract(player,-1);
}

void initialize_hands(){
   for (i=1;i<3;i++)
   {  for (x=1;x<3;x++)
        player_cards[x][i] = -1;}

   for (i=0;i<5;i++) board_cards[i] = -1; 
     
   showing=0; 
   
   for (i=1;i<15;i++)
   {  for (x=1;x<5;x++)
         cards[x][i]=0;}   
}

int main(){
   int poker_hand[5];
   for(i=0;i<6;i++)poker_hand[i]=-1;

   string cardletter[52] = {"AH","2H","3H","4H","5H","6H","7H","8H","9H","TH","JH",
                 "QH","KH","AD","2D","3D","4D","5D","6D","7D","8D","9D","TD",
                 "JD","QD","KD","AC","2C","3C","4C","5C","6C","7C","8C","9C",
                 "TC","JC","QC","KC","AS","2S","3S","4S","5S","6S","7S","8S",
                 "9S","TS","JS","QS","KS",};
   
   initialize_hands();

   shuffle_deck();
   deal_cards(); …
Barbarrosa 0 Light Poster

Alright well heres the whole program minus a few things. Some parts are incompleted I am simply trying to debug my problems. As of now the ones previuosly mentioned are my only ones.

#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int flush[4][14];
int player_cards[2][2];   
int shuffled_deck [51];
int board_cards[4];
int player_hand[5];

int total[13];

int card;
int i;int x;
int showing;
   
void shuffle_deck(){
   int dealt_cards[51];int equal;
   
   for (i=0;i<52;i++)dealt_cards[i] = -1;

   for (i=0;i<52;i++)
   {  equal = 0;
      while(equal!=1)
      {  shuffled_deck[i] = rand()%52;
         if (dealt_cards[shuffled_deck[i]]!=0)
         {  dealt_cards[shuffled_deck[i]]++;equal=1;}}}
}  

void update(int start){
   for (i=start;i<showing;i++)
   {  if(board_cards[i]<13)
         {flush[1][board_cards[i]+1]++;total[board_cards[i]]++;} 
      else if((board_cards[i])<26)
         {flush[2][board_cards[i]%13+1]++;total[board_cards[i]%13]++;}
      else if(board_cards[i]<39)
         {flush[3][board_cards[i]%26+1]++;total[board_cards[i]%26]++;}
      else
         {flush[4][board_cards[i]%39+1]++;total[board_cards[i]%39]++;}
         
      if((board_cards[i]%39)==0)
         {flush[4][14]++;total[13]++;}
      else if((board_cards[i]%26)==0)
         {flush[3][14]++;total[13]++;}
      else if((board_cards[i]%13)==0)
         {flush[2][14]++;total[13]++;} 
      else if(board_cards[i]==0)
         {flush[1][14]++;total[13]++;}}
} 

void deal_cards(){
   card = 0;   
   for (i=1;i<3;i++)
   {  for (x=1;x<3;x++)
         player_cards[x][i] = shuffled_deck[card++];}    
}

void flop(){
   for (i=0;i<3;i++)board_cards[i]=shuffled_deck[card++];
   showing = 3;update(0);  
}

void turn(){
   board_cards[3]=shuffled_deck[++card];
   showing++;update(3); 
}

void river(){
   board_cards[4]=shuffled_deck[++card];
   showing++;update(4); 
}

void add_subtract(int player,int NUM){
   for(i=1;i<3;i++){  
      if(player_cards[player][i]<13)
         {flush[1][player_cards[player][i]+1]+=NUM;total[player_cards[player][i]]+=NUM;} /*PROBLEM*//*PROBLEM*//*PROBLEM*/
      else if((player_cards[player][i])<26)
         {flush[2][player_cards[player][i]%13+1]+=NUM;total[player_cards[player][i]%13]+=NUM;}
      else if(board_cards[i]<39)
         {flush[3][player_cards[player][i]%26+1]+=NUM;total[player_cards[player][i]%26]+=NUM;}
      else
         {flush[4][player_cards[player][i]%39+1]+=NUM;total[player_cards[player][i]%39]+=NUM;}
      
      if((player_cards[player][i]%39)==0)
         {flush[4][14]+=NUM;total[13]+=NUM;}
      else if((player_cards[player][i]%26)==0)
         {flush[3][14]+=NUM;total[13]+=NUM;}
      else if((player_cards[player][i]%13)==0)
         {flush[2][14]+=NUM;total[13]+=NUM;} 
      else if(player_cards[player][i]==0)
         {flush[1][14]+=NUM;total[13]+=NUM;}}
}

bool check_straight(int temp[],int player_hand[]){
   int straight=0;
   for(i=14;i>0;i--)
   {  if(temp[i]!=0&&temp[i-1]!=0)straight++;
      else straight=0;
      if(straight==5)break;}
   
   if(straight==5)
   {  player_hand[5]=temp[i+3];
      player_hand[4]=temp[i+2];
      player_hand[3]=temp[i+1];
      player_hand[2]=temp[i];
      player_hand[1]=temp[i-1];
      return true;}
}

bool check_two_pair(int temp[],int player_hand[]){
   int pair=0;
   for(i=13;i>-1;i--)
   {  if(temp[i]==1&&temp[i]>player_hand[1])
      {  player_hand[1]=i;}
      else if(temp[i]==2&&pair==0)
      {  player_hand[5]=i;
         player_hand[4]=i;
         pair++;}
      else if(temp[i]==2&&pair==1)
      {  player_hand[3]=i;
         player_hand[2]=i;
         pair++;}} 
   if(pair==2)return true;
}

bool check_trips(int temp[],int player_hand[]){

}

bool check_pair(int temp[],int player_hand[]){

}

bool check_full_house(int temp[],int player_hand[]){

}

void poker_hand(int player,int player_hand[]){
   int check[13];int checkf[3];int suit=-1;int temp[13];
   
   bool straight_flush=false; …
Barbarrosa 0 Light Poster

To add another number to an average you need to know 2 things. The Average and the Number of Values. The Average is calculated as such: SUM/NUMBERofVAL=AVERAGE. So when you multiply AVERAGE by NUMBERofVAL you will get the sum. Then to add another number you simply add the next number then divide by the new number of values computed in the average. Know what I'm saying. Think of it like this.

9+3+4+4=20
20/4=5 which is your average. Now you dont need to know that there was a 9 3 4 4. All you need to know is there there were 4 numbers. So 5 (average) * 4 (numberofvalues) = 20 your sum. Now add your new number lets say 5 and divide by the new numberofvalues which is 5. So your average is 5!

Barbarrosa 0 Light Poster

Why dont you just remember two things: your average and the number of values in the average. So when you need to add another number you do this:

average*number + yournewnumber divided by number+1

Is that what your looking for?

Barbarrosa 0 Light Poster

Aight, here is it is. I am basically writing a poker hand recognition program that basically tells me what hand I have. You can make out what the variables mean for yourself as they are straight forward.

int flush[4][14];
int player_cards[2][2];
int board_cards[4];   

int i;int x;

void update(int start, int showing){
   for (i=start;i<showing;i++)
   {  if(board_cards[i]<13)
         {flush[1][board_cards[i]+1]++;/*<---PROBLEM*/
           total[board_cards[i]]++;}
.
.
.
}

I am trying to keep track of what cards are showing so I can later analyze the possible hands. The flush array is set to 0 so if this functino is called then whatever card is showing is marked in the flush array by adding 1. This is updated as cards are shown (flop... turn... river).

Later on in my code when I am checking for a flush possiblity I receive the invalid type error even:

int checkf[3]

for(i=1;i<5;i++)
   {  for(x=1;x<14;x++)
         checkf[i-1]+=flush[x][i];} /*<---PROBLEM*/

I hope this is enough information!! Thanks again.

Barbarrosa 0 Light Poster

Hello, I've been having a problem with my arrays. The error that I am receiving says "[my array] undeclared (first use this function)" and "invalid types 'bool[int]' for array subscripts". My code has the following setup:

int array1[some size][some size];

int main(){
int array2[somesize];int array3[somesize][somesize];
int NUM; /*This number is assigned some value*/
int i;int x; /*some integers that is within the sizes of the arrays*/
.
.
.
array2[i-1]+=array1[i][x]; "invalid types 'bool[int]' for array subscripts" MY ERRORS
array1[1][array3[x][i]+1]+=NUM; "array1 undeclared (first use this function)". MY ERRORS
.
.
.
}

Thanks in advance for your time,

Barbarrosa 0 Light Poster

Hello, I've been trying to figure out this problem for a while now and cant figure it out. What im trying to do is assign a value to a location in an array. SIMPLE! isnt it. well heres my problem.
int main(){
int array[1][1];
.
.
.
array[0][1]=-1;
array[1][0]=-2;

cout<<array[0][1]<<" "<<array[1][0];
.
.
.
}
the output is -2 -2. I have no clue as to whats going on. Ive tried changing it to array[1,0] but i got some errors. Does anyone know whats going on?

Thanks in advance.