Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 07-26-2017, 11:29 AM   #1751
leavesofliberty
self-banned
 
Join Date: Jul 2010
Location: probably busto
Posts: 6,146
Re: Programming homework and newbie help thread

Use Mono for C# on Linux?
leavesofliberty is offline   Reply With Quote
Old 07-26-2017, 12:28 PM   #1752
Loki
Formerly Noodle Wazlib
 
Loki's Avatar
 
Join Date: Nov 2015
Location: Gama Ovar
Posts: 11,244
Re: Programming homework and newbie help thread

I don't know what that means. Given the MS link shows the syntax as c++, I assumed that's what it's for. Is that not the case?
Loki is offline   Reply With Quote
Old 07-26-2017, 01:10 PM   #1753
leavesofliberty
self-banned
 
Join Date: Jul 2010
Location: probably busto
Posts: 6,146
Re: Programming homework and newbie help thread

Without VS, you can alernatively install Mono on Linux to compile your program as a *.exe. Though this would be C# not C++. Mono is tested.
leavesofliberty is offline   Reply With Quote
Old 07-26-2017, 01:13 PM   #1754
_dave_
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK (or what remains of it)
Posts: 12,347
Re: Programming homework and newbie help thread

This is the sort of task best done with AHK, imo.

edit: Oh wait, you're asking how to do this on Linux?
_dave_ is online now   Reply With Quote
Old 07-26-2017, 01:22 PM   #1755
_dave_
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK (or what remains of it)
Posts: 12,347
Re: Programming homework and newbie help thread

a quick google led me to xdotool: http://manpages.ubuntu.com/manpages/...xdotool.1.html
_dave_ is online now   Reply With Quote
Old 07-26-2017, 01:40 PM   #1756
Loki
Formerly Noodle Wazlib
 
Loki's Avatar
 
Join Date: Nov 2015
Location: Gama Ovar
Posts: 11,244
Re: Programming homework and newbie help thread

Quote:
Originally Posted by leavesofliberty View Post
Without VS, you can alernatively install Mono on Linux to compile your program as a *.exe. Though this would be C# not C++. Mono is tested.
Got it installed and the test program working. Thanks! Now to figure out the rest.

Quote:
Originally Posted by _dave_ View Post
This is the sort of task best done with AHK, imo.

edit: Oh wait, you're asking how to do this on Linux?
Well, sort of. I'm asking how to write and compile it properly in Linux so that it runs on windows. For the mono hello world test, you write a .cs file that has "using System", I'm just wondering what libraries if any I need to import/include to write the small looping program posted earlier (sans installing any other software on the windows environment)
Loki is offline   Reply With Quote
Old 07-26-2017, 02:39 PM   #1757
_dave_
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK (or what remains of it)
Posts: 12,347
Re: Programming homework and newbie help thread

more quick googling leads me to believe mouse_event is user32.dll (standard part of Windows), and you need
Code:
System.Runtime.InteropServices
https://stackoverflow.com/questions/...-using-c-sharp
_dave_ is online now   Reply With Quote
Old 07-26-2017, 03:45 PM   #1758
Loki
Formerly Noodle Wazlib
 
Loki's Avatar
 
Join Date: Nov 2015
Location: Gama Ovar
Posts: 11,244
Re: Programming homework and newbie help thread

Had to add "using static System.Threading.Thread" to get Sleep to work. Nothing I can find is working for mouse_event. :-/
Mind, I saved a quarter gig of hdd space by installing mono-dev instead of the full thing. Could that be the problem?
Loki is offline   Reply With Quote
Old 07-26-2017, 07:18 PM   #1759
ChrisV
Carpal \'Tunnel
 
ChrisV's Avatar
 
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 34,592
Re: Programming homework and newbie help thread

Warning, haven't tested this:

Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;

public static class Program
{
    public static void Main()
    {
		while(true) {
			Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y + 1);
			Thread.Sleep(60000);
		}
    }
}
This uses a managed method to move the mouse. We don't normally make direct Win32 API calls in .NET.

Should also be noted that moving the mouse is not really the right way to keep the screen on. Should instead call SetThreadExecutionState and set the ES_DISPLAY_REQUIRED flag.

Always interesting seeing what people come up with when they don't know a language. I had forgotten the "using static" construct existed. It's never used in practice because it's just syntactic sugar which obfuscates where you're getting the "Sleep" method from, making the code less readable.
ChrisV is offline   Reply With Quote
Old 07-26-2017, 09:06 PM   #1760
leavesofliberty
self-banned
 
Join Date: Jul 2010
Location: probably busto
Posts: 6,146
Re: Programming homework and newbie help thread

Haven't tried the Mono yet so can't add anything more. :/
leavesofliberty is offline   Reply With Quote
Old 07-27-2017, 05:22 AM   #1761
leavesofliberty
self-banned
 
Join Date: Jul 2010
Location: probably busto
Posts: 6,146
Re: Programming homework and newbie help thread

Also gl on your bot.
leavesofliberty is offline   Reply With Quote
Old 07-27-2017, 11:48 AM   #1762
Loki
Formerly Noodle Wazlib
 
Loki's Avatar
 
Join Date: Nov 2015
Location: Gama Ovar
Posts: 11,244
Re: Programming homework and newbie help thread

Not really a bot. Just an "I have to read long technical articles for work and I want to prevent my chat clients from routinely going to auto-away" tool.

Maybe I should check if there's a way to disable that in the programs themselves.

Quote:
Originally Posted by ChrisV View Post
Warning, haven't tested this:

Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;

public static class Program
{
    public static void Main()
    {
		while(true) {
			Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y + 1);
			Thread.Sleep(60000);
		}
    }
}
This uses a managed method to move the mouse. We don't normally make direct Win32 API calls in .NET.

Should also be noted that moving the mouse is not really the right way to keep the screen on. Should instead call SetThreadExecutionState and set the ES_DISPLAY_REQUIRED flag.

Always interesting seeing what people come up with when they don't know a language. I had forgotten the "using static" construct existed. It's never used in practice because it's just syntactic sugar which obfuscates where you're getting the "Sleep" method from, making the code less readable.
Tried this on mcs but compilation didn't work. Will have to fiddle around with some other compilers or something.
Loki is offline   Reply With Quote
Old 09-07-2017, 01:46 PM   #1763
jadorehardcore
stranger
 
Join Date: Sep 2017
Posts: 1
Re: Programming homework and newbie help thread

Hello all,

I need to programm something similar to pokerstove / equilab using the programming language python.
The programm only needs to be able to do the basic stuff like simulating all in situations or calculating equity in general. Userinterface is not important.

has this been done before with this language and is there already a source code out there to give me some inspiration / ideas on how to approach the task?

many thanks for help!
jadorehardcore is offline   Reply With Quote
Old 09-11-2017, 03:28 PM   #1764
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,201
Re: Programming homework and newbie help thread

I found this the other day, and will probably try it soon
https://www.periscopedata.com/blog/h...-pure-sql.html

It's a method to get fast approximate results for count-distinct type queries
RustyBrooks is offline   Reply With Quote
Old 09-13-2017, 03:23 PM   #1765
Maroel
centurion
 
Join Date: Jan 2017
Posts: 154
Re: Programming homework and newbie help thread

Hi there.

Any way to conect odds oracle to excel to do poker equity calculations in there?

I usually use excel to do simple poker things and was wondering if this was possible
Maroel is offline   Reply With Quote
Old 09-14-2017, 08:05 PM   #1766
just_grindin
Pooh-Bah
 
Join Date: Dec 2007
Posts: 4,342
Re: Programming homework and newbie help thread

Pretty good blog as far as I can tell for OO design with focus on unit testing. Plenty of concrete code examples to go with abstract design ideas.

http://misko.hevery.com/

Edit: Look for My Main method is better than your main method for a jumping off point for links to others. Also something with 3vi1 in the title it's a satire on what to do to write code that isn't designed well.
just_grindin is offline   Reply With Quote
Old 09-16-2017, 04:15 PM   #1767
LBloom
journeyman
 
Join Date: Mar 2011
Posts: 212
Re: Programming homework and newbie help thread

I'm having a problem with Visual Studio. I can not sign in. No matter what I do, it constantly says I need to "reenter my credentials." Most of the time when I attempt to sign in, basically nothing happens and the "reenter your credentials" message just remains. Other times I get a message that says "An error has occurred and we can no longer retrieve information for your account. Please reenter your credentials." My Microsoft account works perfectly fine everywhere else. I've been searching online for solutions but have come up with nothing to this point. Any idea of what is going on here and some potential fixes? This is driving me crazy.
LBloom is offline   Reply With Quote
Old 09-17-2017, 10:51 AM   #1768
Jeff W
Carpal \'Tunnel
 
Join Date: May 2004
Posts: 9,496
Re: Programming homework and newbie help thread

Can anyone spot what is causing segmentation fault in this C++ snippet:

http://dpaste.com/3ETY9XF

When I run
Code:
$ foo.x < input_file > output_file
through CL, it will process all the strings in input file and then seg faults before reaching "waypoint 1". This is homework so I'm required to use c-strings.

Last edited by Jeff W; 09-17-2017 at 11:08 AM.
Jeff W is offline   Reply With Quote
Old 09-17-2017, 12:59 PM   #1769
well named
poorly undertitled
 
well named's Avatar
 
Join Date: Jun 2007
Location: esse est coesse
Posts: 73,338
Re: Programming homework and newbie help thread

It seems likely the problem is either in CopyString() or in the way you've defined stringarray but neither is in the snippet so it's not clear which it is. The use of the buffer and std::setw() looks fine.
well named is offline   Reply With Quote
Old 09-17-2017, 04:22 PM   #1770
Jeff W
Carpal \'Tunnel
 
Join Date: May 2004
Posts: 9,496
Re: Programming homework and newbie help thread

Quote:
Originally Posted by well named View Post
It seems likely the problem is either in CopyString() or in the way you've defined stringarray but neither is in the snippet so it's not clear which it is. The use of the buffer and std::setw() looks fine.
Here is the code for these: http://dpaste.com/15WXRAN

That part of the code was provided by instructor. Only way I can see these causing a seg. fault is if strlen() or strcopy() but I thought that && (std::cin >> std::setw(buffsize) >> buffer) should terminate the while loop before CopyString() is called on a buffer that could trigger seg fault with those functions.
Jeff W is offline   Reply With Quote
Old 09-17-2017, 04:48 PM   #1771
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,201
Re: Programming homework and newbie help thread

I don't usually like to use cin, so I am unsure about something. Does setw() limit to strings of length N or N-1? Because in C strings, the end of a string is usually considered to be NULL. Your CopyString function does a strlen() on it's input which will try to find the first NULL in the input.

As an example, if you had
char mystr[5] = "foo"
then myrstr would literally look like
f o o NULL X
where X is somewhat undefined

If you said
char myrstr[5] = butts
then it would be
b u t t s
with no NULL
strlen()'s behavior is somewhat undefined in this case - but in all likelihood you'd get a segfault

(btw have you tried using a debugger?)
RustyBrooks is offline   Reply With Quote
Old 09-17-2017, 09:32 PM   #1772
well named
poorly undertitled
 
well named's Avatar
 
Join Date: Jun 2007
Location: esse est coesse
Posts: 73,338
Re: Programming homework and newbie help thread

Well, this runs for me without segfault: http://dpaste.com/1AWNTHW

So I'm not sure what the problem is.
well named is offline   Reply With Quote
Old 09-17-2017, 09:53 PM   #1773
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,201
Re: Programming homework and newbie help thread

Are you passing inputs that are the size of or greater than the allocated buffer space?
RustyBrooks is offline   Reply With Quote
Old 09-17-2017, 10:09 PM   #1774
well named
poorly undertitled
 
well named's Avatar
 
Join Date: Jun 2007
Location: esse est coesse
Posts: 73,338
Re: Programming homework and newbie help thread

Yeah.
well named is offline   Reply With Quote
Old 09-18-2017, 07:01 AM   #1775
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 20,894
Re: Programming homework and newbie help thread

This might work, not sure:

Code:
char* buffer = new char[buffsize+1];
adios is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 03:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online