|
soo im gonna try this once again
i have a job which is called "a dungeon"
The game assumes the existence of a map of the dungeon where the hero / heroine is, and
you want to escape from. The map is created by the programmer and the player does not know the
map.
It is known that the dungeon has 5 divisions. On the map, each of the dungeon divisions is
encoded by a sequence of 5 integers (INSWE) and a String.
The first of the five integers, I, is the numerical identifier of the division.
The remaining four integers N S W E represent the identifier of the division you are going to
the hero / heroine when advancing in one of the four cardinal directions (North, South, West, East).
If the value is zero it means that this direction has no output; 99 indicates the
dungeon (and game over)
after looking at it carefully and suggestion from my colleagues and teacher is the use of a mtraix to make the map (but not show it to the player) and some of my problems atm is kinda of connecting the matrix i have generated/choose and the change of room indidcationg that for example "on this room there is 2 exist one to the east and the other to the north"
in case you need some code to understand im not asking without even trying
s1 = {1,0,0,2, 3}
s2 = {2,0,0,0,1}
s3 = {3,0,4,1,5}
s4 = {4, 3,0,99,0}
s5 = {5,0,0,3,0}
this is the technicall map of the dungeon where you start in S1 which would be room 1 and would have the warning of a exit to the west(s2) and to the east(s3) as in the whole thing is
5 integers (INSWE)
I indicator - in this case it would be 1
N - north which in this situation is 0 indicating there is no pathway in that direction and its just a wall
S- south and see commentray above
W-west where they move from S1 to room 2 S2 where they will be presented with a new number of directions
------------------------------------------------------------------------------
if (S1[1] =/= 0) => "north"
if (S1[2] =/= 0) => "sul"
this is a system i considered for the case of making it easy on myself for the map like
in matrix S1[1] or matrix [1][1] if the value is not 0 well you can move in that direction
and of course i would most likelly put a else on the end of each just so in case it was a 0 they would give the same message saying to the player you cnat go in that direciton pls choose another option
---------------------------------------------------
so this is my basic ideas and hope any of you can help me/understand what i want to do
|
|
|
|
|
Posting the same thing in multiple places wastes our effort and that annoys people. You have this lack-of-a-question in QA so repeating here is not a good idea.
Particularly when you don't ask a question!
Quote: this is my basic ideas and hope any of you can help me/understand what i want to do
You have shown how you think you might solve it, but you haven't explained what problem you are having with that - we don't know what help you need.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
What is your question?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I'm setting up an app that uses a FileSystemWatcher. When a file is added, modified, or removed, some processing has to be done. This processing includes saving a copy of the file in a secure folder and logging it to a database. It's possible for multiple users to access the same folder at the same time.
What I need is to be able to handle EVERY change to a file, no matter how quickly they happen. So if 3 different users drop a file called MyFile.doc into the folder, I need to handle that as 3 different versions of the same file. The problem is how to handle multiple people manipulating the file at the same time.
So, I'm looking for ideas on how to handle the concurrency issues that are going to arise.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 28-Jan-20 12:34pm.
|
|
|
|
|
Kevin Marois wrote: So if 3 different users drop a file called MyFile.doc into the folder, I need to handle that as 3 different versions of the same file. Regardless of the FileSystemWatchers' capabilites, I don't think the FileSystem supports that.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
modified 28-Jan-20 13:46pm.
|
|
|
|
|
Set up File Watcher to queue every change / event; have a separate thread process the queue (BG worker).
File Watcher starts the "queue watcher" any time it queues and the queue watcher is not active.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi,
I have used FileSystemWatcher a long time ago, and wasn't impressed by it. IIRC, when a file is being created, you get an event, after an unpredictable delay that is; and I saw no way to detect the end of the file writing, e.g. there is no close event.
So my apps ended up using one of two techniques:
- either use a delay after the create event to make somewhat sure the new file had entirely been written, not elegant at all;
- or, when I was in control of the file creation, simply create the file, then create a very small second file, and use FSW to only track the latter.
|
|
|
|
|
Quote: I have used FileSystemWatcher a long time ago
Things change.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I think you might be stuck with a polling mechanism rather than a watcher. If extensive security isn't a concern you can run a nice quick file hash (like MD5) periodically.
Really the only other thing I can think of is forcing users to manipulate the files in question through a specific pipeline that you can attach hooks to. I suppose you could do it as an Office extension and process changes through a queuing system, maybe going through something like RabbitMQ, redis, or Kafka. That'd be low-hanging fruit if you already use one of those services in your environment.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
dynamic returnObject = new ExpandoObject() as IDictionary<string, object>;
var EnterData = (IDictionary<string, object>)returnObject
EnterData.Add("myColumn", typeof(int));
Now when I debug a test that I have created I can see the value type has been set to int.
but I would like to add a test to this, purely for my own learning
var keypair = EnterData.FirstOrDefault(p=> p.Key == "myColumn");
var properties = keypair.GetType().GetGenericArguments();
var ValueType = properties[1];
which always returns a type object, is there a way to get the type that I have assigned to the keyvaluepair?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Maybe I'm doing or reading it wrong, but wouldn't that be
string myValueType = keypair.Value.ToString();
That should return "System.Int32", and the first part of the pair is always a string.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks Eddie, it worked..
Silly me, while looking my brain thought everything must complicated so I ignored all the easy stuff.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
You're welcome, and happens to us all
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi
I have this Pcre Regex .{1,15}\K(\s{1,2}|$) that I use in my Autoit code to split a text at a N length, but the split is at the last space within the N length.
Now I'm trying to convert it to C#, but C# don't understand the \K and my RegEx understanding is very basic, I had some on helping me with this one I'm now trying to convert.
My hope is that some one here could help me achieve the same with C#.
My code from Autoit
This splits a large text up into cunks at N lengt, at the last space within the nLength specified, and seperated with a @CRLF
eg. 'A child asked his father, "How were people born?" So his father said, "Adam and Eve made babies, then their babies became adults and made babies, and so on."
Would be formated as this:
A child asked his father, "How were people born?" So his father said, "Adam and Eve
made babies, then their babies became adults and made babies, and so on."
#ce
Local $sResult = StringRegExpReplace($sString, ".{1," & $nLenght - 1 & "}\K(\s{1,2}|$)", @CRLF)
return $sResult
Cheers
/LR
|
|
|
|
|
If you get the match Groups, you should be able to get the values after \K by using match.Groups[1].Value; (not forgetting to get rid of the \K section).
|
|
|
|
|
Hi Peter
Using this:
string pattern = @".{1,30}(\s{1,2}|$)";
RegexOptions regexOptions = RegexOptions.None;
Regex regex = new Regex(pattern, regexOptions);
string inputData = @"A child asked his father, ""How were people born?"" So his father said, ""Adam and Eve made babies, then their babies became adults and made babies, and so on.";
string replacement = "\n\r";
string result = regex.Replace(inputData, replacement);
Console.WriteLine(result);
I only gets the replacements not the splitted text.
/LR
|
|
|
|
|
What happens if the first "word" is greater than length N?
If you're just trying to "wrap text", use a text block / box with "text wrapping" set to "on". It will even split words, add ellipses if you want.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi Gerry
Well my guess is that the word would be either Finish or Polish which is the only two languages I know of, who can use up a pencil writing "Hello how are you"
But I get your point Normally I do split at about 60 chars, and it's in 99% of the cases english language I split, so I newer gave it any thought what would happen if the first word was longer than N, but clearly the regex would fail and just return the whole word without splitting.
No I'm not trying to wrap text, I use the splitter to ad text to documents with a max width.
And I could just use split at N, but doing that could split a word in the middle, and that I don't want.
/LR
|
|
|
|
|
I do a lot of "splitting", using ".IndexOf" and ".LastIndexOf", with or without starting offsets. My "brutish" techniques have shown no performance issues, even when splitting (and presenting) thousands of (query) results at a time.
The splitting usually involves chopping off and rereading the chopped item while length > 0. Sounds inefficient but isn't.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi Gerry
That could be another way of doing it.
/LR
|
|
|
|
|
Hmm
So I came up with this
string splittSet = "";
string test_pattern = @"(.{1,60})(\s{1,2}|$)";
RegexOptions regexOptions = RegexOptions.None;
Regex splitText = new Regex(test_pattern, regexOptions);
string inputData = @"The wolf is thought to be an ice age survivor, dating wolves around 300,000 years ago. The wolf is accepted to be the ancestor of the domestic dog as the wolf is thought to have selectively bred in order to breed appealing traits typical of puppies and to eliminate the not so appealing traits of adult wolves.";
foreach (Match match in splitText.Matches(inputData))
{
if (match.Success)
{
splittSet += match.Groups[0].Value + "\n\r";
}
}
Definitely not not as elegant as my original regex, but it seems to work :/ though I do hope that someone have a better/more elegant way of doing it
/LR
|
|
|
|
|
splittSet += match.Groups[0].Value + "\n\r";
Use a StringBuilder class ... one of the most obvious things they ask in interviews.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi Gerry
Some thing like this?
string splitPatteren = @"(.{1," + count + @"})(\s{1,2}|$)";
RegexOptions regexOptions = RegexOptions.IgnoreCase;
Regex splitText = new Regex(splitPatteren, regexOptions);
StringBuilder result = new StringBuilder();
foreach (Match match in splitText.Matches(input))
{
if (match.Success)
{
result.Append(match.Groups[0].Value + delm);
}
}
|
|
|
|
|
Use .AppendLine([...]) if you want to add a (OS independent) "line feed".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi Gerry
I made the method so the "split delimitre" can be changed at call, default is \n\r but if I should had use for a long string separated by | or some thing else I now have the option to do that.
But else the AppendLine would had been my choice also
/LR
|
|
|
|
|