|
V. wrote: You can pass your labels array
Not if you need to do a search to find your best next move. I'd use an int.
|
|
|
|
|
First of all, I'd ask you whether or not optimisation is really necessary. Quite often you'll spend a lot of time looking for optimisations which, strictly speaking, aren't necessary. You may save a clock cycle here or a clock cycle there, but it's not noticeable.
As for optimisations, the most obvious one that I see lies here:
if (Action[i, j] && !IsEmpty[sdx, sdy] && sdx == ftx && sdy == fty)
return true; Please though give your variables better names, and use { } to wrap code sections; I had real trouble wading through the logic.
|
|
|
|
|
I don't see very much there to optimize while keeping the same data structures.
Using an array of arrays can be faster than a 2D array. Using a BitArray instead of an array of bools is usually faster. If the array is sufficiently small, using the bits in an ulong directly is even faster, and you should probably look up bitboards if this is about a game board (and that's what it is, isn't it?)
edit: if you explain what the code is supposed to do, maybe I can help you sort out bitboard functions.
|
|
|
|
|
I have square 5*5.(Labels array) some of them Empty. other have symbols. bool IsEmpty 5*5 contains true if Lable is Empty or false if label has symbol.
first function:
When i do click on label first function cheks Label[x,y] is empty or not. if it is empty then it checks labels which near it if they have a symbol function return true;
second functions:
for select a word when i do click on labels.
I click on labels programm write cordinats label;
then i click next label function need to check if it has a symb and near first label then return true;
fx,fy are first label
sx,sy are second label
|
|
|
|
|
I'm sorry to say it, but your English wasn't very good so I can easily misunderstand what you mean, so please correct me if I'm wrong.
First function:
bool IsOpenForLetter(int x, int y, ulong isempty)
{
int index = x + 8 * y;
ulong isnotempty = ~isempty;
return ((isempty >> index) &
(isnotempty >> (index + 1)) &
(isnotempty >> (index - 1)) &
(isnotempty >> (index + 8)) &
(isnotempty >> (index - 8)))
!= 0;
}
edit: it doesn't check whether it would go out of bounds, because it isn't needed thanks to the padding.
Second function: I'll try this one later
|
|
|
|
|
Hi,
I have been developing add-ins for MS Word for quite some time now. I usually track bind failures using Fusion Logs and it used to work for all applications. But suddenly, the fusion logs fail to catch any load events for WINWORD.exe. I do not get any entries in my "C:\fusionlog\DEFAULT" folder for WINWORD.exe. It works fine for EXCEL.exe, POWERPNT.exe. I wanted to check fusion logs because my addins did not load in MS Word but the addins loaded in Excel and PowerPoint. Could anyone please help?
Thanks,
Ram
|
|
|
|
|
Hi,
I've the following XML-
<MessageParts xmlns="http://www.address.com">
<Status xmlns="">
.
.
.
.
<Data>
<PersonsMin xmlns="some attribute">
.
.
.
<Parts>
.
.
.
</Parts>
</PersonsMin>
</Data>
</Status>
</MessageParts>
I'me trying to get all the elements in PersonsMin.
var query = from response in xmlDoc.Elements("PersonsMin")<br />
select response;
But i'm getting "Sequence contains no elements".
What i'm doing wrong?
|
|
|
|
|
treuveni wrote: What i'm doing wrong?
That's fairly simple, you've forgotten to add the XML namespace to the query. Typically you would do this using
XNamespace myNamespace = "some namespace";
var query = from response in xmlDoc.Elements(myNamespace + "PersonsMin")
select response;
|
|
|
|
|
Pete O'Hanlon wrote: you've forgotten to add the XML namespace to the query
Like this?
XNamespace myNamespace = "some attribute";<br />
var query = from response in xmlDoc.Elements(myNamespace + "PersonsMin")<br />
select response;
XNamespace is the XAttribute?
|
|
|
|
|
Whereever you see xmlns in your XML, that's the namespace that you need to include to pick it up.
|
|
|
|
|
Pete O'Hanlon wrote: Whereever you see xmlns in your XML, that's the namespace that you need to
include to pick it up.
Still same error
"Sequence contains no elements"
|
|
|
|
|
Try this:
var query = from response in xDoc.Descendants(ns + "PersonsMin")
select response;
|
|
|
|
|
Hi ,
Is there anyway to find a set of words together on visual studio ?.For eg. I need to find 'egg' and 'chicken' together.Could you please let me know .
With regards.
|
|
|
|
|
If you mean the occurrence of these words in your source code then use one of the Edit->Find and Replace ... options from the menu.
If you mean in your resulting program then you will have to write the code yourself.
The best things in life are not things.
|
|
|
|
|
So I didn't have time to look into this exception in detail today. If no one can answer due to the vague nature that's okay. I just thought I could ask and possibly receive some general guidance for in the morning.
Anyhow, I am using C# (.NET 4.0, VS2010) to connect to a MS Access 2007 (.accdb) database. The database includes two tables, "Repairs" and "Scrap Codes". The Repairs table includes a field, "Scrap Code", which does a look-up for values using the Scrap Codes table. All works well within Access. I can successfully insert records (through my software) including a value for the Scrap Code field. I have checked the data in Access to verify proper data is inserted; success.
However, when I execute a simple statement within my software:
<br />
---- To retrieve the most common Scrap Code ----<br />
<br />
SELECT TOP 1 [Scrap Code] FROM Repairs<br />
WHERE [Failure Code]=13<br />
GROUP BY [Scrap Code]<br />
ORDER BY Count(*) DESC<br />
where "Failure Code" is another look-up column in the Repairs table, I receive an exception. In the exception dialog that I receive (the JIT box), instead of displaying a description above the Details button, it simply says "Scrap Codes.", the table name. If the possibilities are not too vague could you please provide a few likely culprits?
Now, if the "Scrap Code" field for EVERY record in Repairs is empty, however, I do not run into this issue at all. But if I set a value for "Scrap Code" on any number of records I get this error.
I will have time to look at it in depth tomorrow morning. But I felt the need to ask because it is going to bother me all night. Haha.
Thanks in advance,
Matt U.
[SOLUTION]
There was a typo in the statement. I had an extra letter at the end of the "Scrap Code" field, in the "Repairs" table. Problem solved.
modified on Thursday, June 16, 2011 6:18 PM
|
|
|
|
|
You don't seem to be joining the two tables, so try this:
SELECT TOP 1 Count(*) AS Expr1, ScrapCodeID
FROM ScrapCodes
INNER JOIN Repairs ON ScrapCodes.ID = Repairs.ScrapCodeID
WHERE FailureCode = 13
GROUP BY Repairs.ScrapCodeID
ORDER BY Count(*) DESC;
The Scrap Codes to Repairs tables above assume a one-to-many relationship - I presume that is what you have.
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
|
|
|
|
|
I could give this a try. But I have other fields in the Repairs table which are linked to other tables (the "Failure Code" field, for example, links to the table "Failure Codes"). And I can work with that data without any issue.
I'm not very strong at all on JOIN's yet. It's a subject which I have been reading a lot into lately though.
|
|
|
|
|
|
It is customary and courteous to use a clicky link when posting a URL so people don't have copy and paste the URL, which most will not do and thus you will not receive any positive responses.
Please edit your post and use the link[^] toolbar item.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
It's a command line interface, so you can start the program with Process.Start and talk to it through its redirected stdin/stdout streams (they are available from Process). Obviously to do that it needs to be on the same machine as you are – if it is a *nix-only app then that will mean you will have to run your C# app under Mono.
I didn't investigate in any detail but assuming the app has a sensible command line interface you should be able to write code to talk to it.
|
|
|
|
|
Hi, thank you for the response.
Which program would I want to start, a bash client, in a hidden window?
I will be local on the box, they link gives command lines to return values, but the unix portion of it is what has me confused.
|
|
|
|
|
If it is a tool which takes a command line, executes and closes, then for each 'command' you should start a new process, with the command line you want to send, and capture the output. You can do that with Process.Start (set the ProcessStartInfo up to redirect the console streams). The fact it's on Unix shouldn't matter as long as Mono supports that part of the framework, and I'd be astonished if it doesn't.
|
|
|
|
|
|
I'm not sure, I will have to see if that is possible.
It is a Unix/Solaris SAN server connected to a fiber card of the windows server.
|
|
|
|