Search Results

Search found 17977 results on 720 pages for 'someone smiley'.

Page 11/720 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Where can someone store >100GB of pictures online? [closed]

    - by sbi
    A person who is not very computer-savvy needs to store 130GB of photos. The key parameters are: an non-negligible probability that the company selling the storage will be existing, and the data accessible, for at least five years data should be considered safe once uploaded reasonable terms of service: google drive reserving the right to literally do anything they want with their user's data is not acceptable; the possibility that the CIA might look at those pictures is not considered a threat easy to use from Windows, preferably as a drive no nerve-wracking limitations ("cannot upload 10GB/day" or "files 500MB" etc.) that serve no purpose other than pushing the user to the next-higher price plan some upgrade plan: there's currently 10-30GB of new photos per year, with a tendency to increase, which might bust a 150GB limit next January ability to somehow sort the pictures: currently they are sorted into folders, but something alike (tags) would be just as good, if easy enough to apply of course, the pricing is important (although there's a reason this is the last bullet; reasonable data safety is considered more important) Nice to have, but not necessary features would be: additional features related to photos (thumbnail generation, album sharing etc.) access from web and other platforms than Windows (smart phones) Let me stress this again: The person in need of that is able to copy pictures from the camera to the computer, can copy files in the explorer, and uses a web email service. That's about it, there's almost no understanding of what happens under the hood.

    Read the article

  • Access logs show someone "GET"ing a random ip, why does this return 200?

    - by Wilduck
    I have a small linux box set up with Apache as a way to teach myself Apache. I've set up port forwarding on my router so it's accessible from the outside world, and I've gotten a few strange requests for pages that don't exist from an ip address in China. Looking at my access_log shows that most of these return 404 errors, which I'm guessing is a good thing. However, there is one request that looks like this: 58.218.204.110 - - [25/Dec/2010:19:05:25 -600] "GET http://173.201.161.57/ HTTP/1.1" 200 3895 I'm curious what this request means... That ip address is unconnected to my server as far as I know, and visiting it simply tells me information about my uid. So, my questions are: How is it that this request is showing up in my access_log, why is it returning 200, and is this a bad thing (do I need to set up more security)?

    Read the article

  • Can someone please explain these Network Activity entries are? (resource monitor windows 7)

    - by Keyes
    The first one is the address microsoftword.com.br. What is this? I noticed when I connected windows to the internet briefly, and it went away soon after. when I typed the address into my tablet, it redirected to bing with the search "microsoftword com" with MSSRPD at the end of the address. The other unknowns seemed to appear when my brothers laptop was connected to the network. Is that normal? Usually if I disconnected and reconnected they would appear, but I noticed when I had disconnected and reconnected to try it didn't happen as he wasn't connected. I'm concerned about the microsoftword one is. Is it legitimate? The svchost that associated with is a legit svchost image.

    Read the article

  • Someone to clarify /tags and /branches in SVN (subversion)?

    - by JoeM
    I created folders /tags, /branches and /trunk on SVN server. I put initial project file into /trunk. But other folders confuses me. What should I put in /tags? I see most people do not ever use this folder. Is this like a temp folder or so? As I understood, the purpose of branches is to host a different versions. So I will have /branches/myapp_v1.0.0, /branches/myapp_v1.0.1, etc. Right? If this is true, how do I "tell" subversion tool (tortoise on windows, svn on linux) to upload project files into such and such folder?

    Read the article

  • How to deal with author rights when building a website

    - by user393381
    I was thinking about developing a website that would involved photos and was wondering how to deal with the legal/author rights aspects. If someone could direct me to some resources to find out, I would appreciate. If I take Flicker as an example, people can upload pictures and share them. What if someone a picture that belong to someone else, like a professional photographer? Or what if someone upload a picture of someone and that person does not agree to that? Same question if someone put a picture in there that is not acceptable? Can a Disclaimer or Terms of Use avoid the Website (or the person managing a Website) to get in trouble when someone violate the law? Thanks.

    Read the article

  • Replace HTML entities in a string avoiding <img> tags

    - by Xeos
    I have the following input: Hi! How are you? <script>//NOT EVIL!</script> Wassup? :P LOOOL!!! :D :D :D Which is then run through emoticon library and it become this: Hi! How are you? <script>//NOT EVIL!</script> Wassup? <img class="smiley" alt="" title="tongue, :P" src="ui/emoticons/15.gif"> LOOOL!!! <img class="smiley" alt="" title="big grin, :D" src="ui/emoticons/5.gif"> <img class="smiley" alt="" title="big grin, :P" src="ui/emoticons/5.gif"> <img class="smiley" alt="" title="big grin, :P" src="ui/emoticons/5.gif"> I have a function that escapes HTML entites to prevent XSS. So running it on raw input for the first line would produce: Hi! How are you? &lt;script&gt;//NOT EVIL!&lt;/script&gt; Now I need to escape all the input, but at the same time I need to preserve emoticons in their initial state. So when there is <:-P emoticon, it stays like that and does not become &lt;:-P. I was thinking of running a regex split on the emotified text. Then processing each part on its own and then concatenating the string together, but I am not sure how easily can Regex be bypassed? I know the format will always be this: [<img class="smiley" alt="] [empty string] [" title="] [one of the values from a big list] [, ] [another value from the list (may be matching original emoticon)] [" src="ui/emoticons/] [integer from Y to X] [.gif">] Using the list MAY be slow, since I need to run that regex on text that may have 20-30-40 emoticons. Plus there may be 5-10-15 text messages to process. What could be an elegant solution to this? I am ready to use third-party library or jQuery for this. PHP preprocessing is possible as well.

    Read the article

  • Wire the homepage so that it fires off a Push notification message to my iPhone every time someone l

    - by fwd4
    I looking for a simple way to wire the homepage of my website so that it fires off a Push notification message to my iPhone every time someone lands on the page (just visiting in their browser). I'm aware this could become annoying! I currently send regular notifications to my iPhone using cron and curl to check sites / RSS feeds for change and then fire to to the Prowl API who in turn send it to my iPhone - like so: curl https://prowl.weks.net/publicapi/add -F apikey=$apikey -F priority=$priority -F application="$app" -F event="$eventname" -F description="$description" Could I do something similar from with the HTML of the homepage - call a script on my server which in turn fires a similar curl request above? Maybe with Javascript or PHP? Ideally I'd like the loading and rendering of me webpage to be uninterrupted by the call. Hat tip to Prowl - http://prowl.weks.net/api.php and to flx.me Both of which I use to make what I have already working.

    Read the article

  • What C#/SQL Server feature did someone show you that made you say Wow!

    - by Randy Minder
    It's late Friday afternoon, and my mind is checking out for the week. So I thought I'd ask a light-hearted, interesting, question. Yesterday a co-worker showed me how he managed to save quite a bit of code and improve code reuse through the use of an anonymous delegate and the use of the Action function. My first thought was, "Wow, I had no idea you could do that!". I'm curious what sort of things someone showed you, either in c# or SQL Server, that made you stop and think, "Wow!". Randy

    Read the article

  • File input javascript event, is there an event fire when someone click okay on the dialog box?

    - by Mickey Cheong
    Hi, When someone click on Browse for the input file below: <input type="file" name="blah" /> A dialog box will appear. The user will then select a file and click 'Ok'. The dialog box will close. Is there an event fire because of that? I tried onfocus and onblur, it didnt work out. The only way is, i start a timer to check the value content when it is onfocus. Not that elegant. Any solution? Cheers, Mickey

    Read the article

  • Someone explain to me the meanings behind the naming conventions used in .net?

    - by IbrarMumtaz
    I need someone to explain the following names; Asynchronous Delegates. Asynchronous methods. Asynchronous events. I'm currently going over this for my 70-536 exam and I am covering all my bases so far. The threading chapter and online resources have been good to me on my second read through. Still though, the names used above mean absolutely nothing to me? I would really appreciate the meaning behind the word 'Asynchronous' and its relevance to Delegates, methods and events. Feel free to go into as much detail as you like. Thanks, Ibrar

    Read the article

  • Android - How to tell is someone has pressed a SPINNER but not changed the visible item in it.

    - by andy_spoo
    I have a spinner, which mostly works. If a user selects one of the items in it, the 'onItemSelected' routine catches it just fine. But if a user clicks the same spinner, but does not change from the already visible item that it's currently displaying, the 'onItemSelected' routine just ignores it, and the logs show:- WARN/InputManagerService(577): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@437948b0 I there anyway to capture someone doing this? The idea is that my spinner contains a list of names, and when a user selects one from the spinner, it gets added to a listview. I could just add another button to get the name from the spinner, but, screen-space is already lacking and I'd rather not add anymore content.

    Read the article

  • I need someone for explain this ASP function to me.

    - by Ronnie Chester Lynwood
    Hello! I've got an ASP document that 5 years old. Actually I'm working with PHP but I must use ASP for a Windows Application. So I need someone to explain this function to me. Thanks anyway. //DNS SETTINGS ARE INCLUDED ALREADY. function Check_Is_Web_Locked() dim cmdDB , Ret OpenDatabase Set cmdDB = Server.CreateObject("ADODB.Command") With cmdDB .ActiveConnection = DBCon .CommandText = "TICT_CHECK_WEB_STATUS" .CommandType = adCmdStoredProc .Parameters.Append .CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue, 0) .Execute,,adExecuteNoRecords Ret = Trim(.Parameters("RETURN_VALUE")) End With Set cmdDB = Nothing CloseDatabase Check_Is_Web_Locked = Ret end function What does this functions do? Is "TICT_CHECK_WEB_STATUS" a StoredProcedure? If it's what are the coulumns that function looking for?

    Read the article

  • Can someone please explain to me the basic function of Intents in the Android OS?

    - by K-RAN
    I'm new to programming applications for the Android OS. As far as general architecture of the OS goes, I understand that processes are implemented as Linux processes and that each one is sandboxed. However, I'm utterly confused on the IPCs and syscalls (if any) used. I know that the IBinder is a form of this; parcels are sent back and forth between processes and Bundles are array forms of parcels (?). But even that is still unfamiliar to me. Same with Intents. All in all, I don't understand what kinds of IPCs are implemented and how. Could someone briefly explain to me the specific methods used by user level applications in Android OS to communicate with each other and the OS? I've done kernel programming and played with various IPCs in Linux (Ubuntu and Debian) so it would help immensely if this was all explained in relation to what I'm familiar with... Thanks in advance!

    Read the article

  • Why might someone say R is *NOT* a programming language? [closed]

    - by Tal Galili
    I came by the following comment today on twitter "R is not a programming language, it's a statistics package with the GUI missing." And I am wondering - Why not? What is "missing" in R to make it a "programming language" ? Update: For the protocol, I am a big fan of R, use it daily, and support it's existence. I now changed the name of this thread from "Why is R NOT a programming language?" to "Why might someone say R is NOT a programming language?" Which better reflects my motivation for this thread (which is, to know if R has any programmatical disadvantages that I might have not heard about).

    Read the article

  • When is someone else's code I use from the internet "mine"?

    - by robault
    I'm building a library from methods that I've found on the internet. Some are free to use or modify with no requirements, others say that if I leave a comment in the code it's okay to use, others say when I use the code I have to attribute the use of someone's code in my application (in the credits for my app I guess). What I've been doing is reorganizing classes, renaming methods, adding descriptions (code comments), renaming the parameters and names inside the methods to something meaningful, optimizing loops if applicable, changing return types, adding try/catch/throw blocks, adding parameter checks and cleaning up resources in the methods. For example; I didn't come up with the algorithm for blurring a Bitmap but I've taken the basic example of iterating through the pixels and turned it into a decent library method (applying the aforementioned modifications). I understand how to go about building it now myself but I didn't actually hit the keystrokes to make it and I couldn't have come up with it before learning from their example. What about code people get in answers on Stackoverflow or examples from Codeproject? At what point can I drop their requirements because at n% their code became mine? FWIW I intend on using the libraries to create products that I will sell.

    Read the article

  • How can someone with no experience learn how to program?

    - by Mugatu
    A friend and I have been coming up with website ideas for a couple years, mostly just jotting them down whenever we come up with a good, useful idea when browsing the web. For the past 6 months we've hired a couple different programmers to make a couple of the sites for us, but have been disappointed with how it's gone. Been too slow and too many miscommunications for our liking. So like the saying goes if you want something done right do it yourself, we're going to do it ourselves. I know nothing about programming, I've never written a line of code in my life. I consider myself very good with math and about as logical as you can get, but I have zero real-life programming knowledge. The sites we want to make are all pretty 'Web 2.0'ish', meaning user-generated content, commenting on posts, pages that change on the fly, etc. So here are some of my questions for anyone who's been there before: Is there a language you'd recommend learning first? Something that is a good indicator how most other languages work? What web programming languages do you recommend learning first based on popularity both now and the future. I don't want to learn a language that's going to be outdated by the time I'm an expert at it. Any specific books you'd recommend? Any general advice you'd give to someone literally starting at square zero for coding who plans on being in it for the long haul?

    Read the article

  • Hi I am facing a fragmentation error while executing this code? Can someone explain why?

    - by aks
    #include<stdio.h> struct table { char *ipAddress; char *domainName; struct table *next; }; struct table *head = NULL; void add_rec(); void show_rec(); int main() { add_rec(); show_rec(); return 0; } void add_rec() { struct table * temp = head; struct table * temp1 = (struct table *)malloc(sizeof(struct table)); if(!temp1) printf("\n Unable to allocate memory \n"); printf("Enter the ip address you want \n"); scanf("%s",temp1->ipAddress); printf("\nEnter the domain name you want \n"); scanf("%s",temp1->domainName); if(!temp) { head = temp; } else { while(temp->next!=NULL) temp = temp->next; temp->next = temp1; } } void show_rec() { struct table * temp = head; if(!temp) printf("\n No entry exists \n"); while(temp!=NULL) { printf("ipAddress = %s\t domainName = %s\n",temp->ipAddress,temp->domainName); temp = temp->next; } } When i execute this code and enters the IP address for the first node, i am facing fragmentation error. The code crashed. Can someone enlighten?

    Read the article

  • Can someone please clarify my understanding of a mock's Verify concept?

    - by Pure.Krome
    Hi folks, I'm playing around with some unit tests and mocking. I'm trying to verify that some code, in my method, has been called. I don't think I understand the Verify part of mocking right, because I can only ever Verify main method .. which is silly because that is what I Act upon anyways. I'm trying to test that my logic is working - so I thought I use Verify to see that certain steps in the method have been reached and enacted upon. Lets use this example to highlight what I am doing wrong. public interface IAuthenticationService { bool Authenticate(string username, string password); SignOut(); } public class FormsAuthenticationService : IAuthenticationService { public bool Authenticate(string username, string password) { var user = _userService.FindSingle(x => x.UserName == username); if (user == null) return false; // Hash their password. var hashedPassword = EncodePassword(password, user.PasswordSalt); if (!hashedPassword.Equals(password, StringComparison.InvariantCulture)) return false; FormsAuthentication.SetAuthCookie(userName, true); return true; } } So now, I wish to verify that EncodePassword was called. FormsAuthentication.SetAuthCookie(..) was called. Now, I don't care about the implimentations of both of those. And more importantly, I do not want to test those methods. That has to be handled elsewhere. What I though I should do is Verify that those methods were called and .. if possible ... an expected result was returned. Is this the correct understanding of what 'Verify' means with mocking? If so, can someone show me how I can do this. Preferable with moq but i'm happy with anything. Cheers :)

    Read the article

  • Can someone tell me what this Java class does? I/O related

    - by anon
    I am relatively new to Java and trying to learn the I/O syntax. Could someone give me a general overview of what this code does? Thanks!! import java.io.*; public class FileReader { private String openFile=""; private String saveFile=""; FileReader(openFile, saveFile) { this.openFile=openFile; this.saveFile=saveFile; } public String process(){ System.out.println(this.openFile); System.out.println(this.saveFile); BufferedReader open=null; FileReader openFR=null; FileWriter save=null; int counter=0; String output=""; if(openFile.equals("")){ return "No open file specifified\n"; } if(this.saveFile.equals("")){ return "No save file specified\n"; } try { openFR = new FileReader(this.openFile); open = new BufferedReader(openFR); } catch (FileNotFoundException e) { return ("Open file no longer exists\n"); } try { save = new FileWriter(saveFile); } catch (IOException e){ return ("Error saving the file\n"); } try{ String temp = open.readLine(); while(temp != null){ temp = open.readLine(); counter++; save.write(output + "\n"); } } catch (IOException e){ e.getStackTrace(); return ("Error reading open file"); } try { save.flush(); } catch (IOException e) { e.printStackTrace(); return ("Error writing save file"); } return "Operation completed successfully"; } }

    Read the article

  • Can someone tell me why I'm seg faulting in this simple C program?

    - by user299648
    I keep on getting seg faulted, and for the life of me I dont why. The file I'm scanning is just 18 strings in 18 lines. I thinks the problem is the way I'm mallocing the double pointer called picks, but I dont know exactly why. I'm am only trying to scanf strings that are less than 15 chars long, so I don't see the problem. Can someone please help. #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LENGTH 100 int main( int argc,char *argv[] ) { char* string = malloc( sizeof(char) ); char** picks = malloc(15*sizeof(char)); FILE* pick_file = fopen( argv[l], "r" ); int num_picks; for( num_picks=0 ; fgets( string, MAX_LENGTH, pick_file ) != NULL ; num_picks++ ) { printf("pick a/an %s ", string ); scanf( "%s", picks+num_picks ); } int x; for(x=0; x<num_picks;x++) printf("s\n", picks+x); }

    Read the article

  • jQuery - Can someone help stitching jQuery code with .ajaxComplete()?

    - by Kenny Bones
    Hi, so I've got this content loader that replaces content within a div with content from a separate page. But the content that arrives contains a menu that uses jQuery and this is not working. Someone told me I need to reinitialize the code. But how do I do that? I've looked into .ajaxComplete(), but I don't really get how I'm supposed to stitch that together with my existing code? $('.dynload').live('click', function(){ var toLoad = $(this).attr('href')+' #content'; $('#content').fadeOut('fast',loadContent); $('#ajaxloader').fadeIn('normal'); function loadContent() { $('#content').load(toLoad,'',showNewContent()) } function showNewContent() { $('#content').fadeIn('fast',hideLoader()); //Cufon.replace('h1, h2, h3, h4, .menuwrapper', { fontFamily: 'advent'}); } function hideLoader() { $('#ajaxloader').fadeOut('normal'); } return false; }); This is the code I'm using for the jQuery menu: $().ready(function() { $('#kontrollpanel .slidepanels').kwicks({ min : 42, spacing : 3, isVertical : true, sticky : true, event : 'click' }); }); Also, notice how I try to call Cufon as well within the first function? That doesn't really work either, could that be reinitialized as well? Would really appreciate any help at all..

    Read the article

  • Can someone who understands C code help me understand this code?

    - by Benjamin
    INT GetTree (HWND hWnd, HTREEITEM hItem, HKEY *pRoot, TCHAR *pszKey, INT nMax) { TV_ITEM tvi; TCHAR szName[256]; HTREEITEM hParent; HWND hwndTV = GetDlgItem (hWnd, ID_TREEV); memset (&tvi, 0, sizeof (tvi)); hParent = TreeView_GetParent (hwndTV, hItem); if (hParent) { // Get the parent of the parent of the... GetTree (hWnd, hParent, pRoot, pszKey, nMax); // Get the name of the item. tvi.mask = TVIF_TEXT; tvi.hItem = hItem; tvi.pszText = szName; tvi.cchTextMax = dim(szName); TreeView_GetItem (hwndTV, &tvi); //send the TVM_GETITEM message? lstrcat (pszKey, TEXT ("\\")); lstrcat (pszKey, szName); } else { *pszKey = TEXT ('\0'); szName[0] = TEXT ('\0'); // Get the name of the item. tvi.mask = TVIF_TEXT | TVIF_PARAM; tvi.hItem = hItem; tvi.pszText = szName; tvi.cchTextMax = dim(szName); if (TreeView_GetItem (hwndTV, &tvi)) //*pRoot = (HTREEITEM)tvi.lParam; //original hItem = (HTREEITEM)tvi.lParam; else { INT rc = GetLastError(); } } return 0; } The block of code that begins with the comment "Get the name of the item" does not make sense to me. If you are getting the listview item why does the code set the parameters of the item being retrieved, because if you already had the values there would be no need to retrieve them. Secondly near the comment "original" is the original line of code which will compile with a varning under embedded visual c++, but if you copy the exact same code into visual studio 2008 it will not compile. Since I did not write any of this code and am trying to learn is it possible the original author made a mistake on this line, since the *pRoot should point to and HKEY type yet he is casting to an HTREEITEM type which should never work since the data types don't match? (Side note someone with a better reputation should add a windows ce tag to SO since windows mobile is not the same as windows ce.)

    Read the article

  • Can someone help me with this Java Chess game please?

    - by Chris Edwards
    Hey guys, Please can someone have a look at this code and let me know whether I am on the right track with the "check_somefigure_move"s and the "check_black/white_promotion"s please? And also any other help you can give would be greatly appreciated! Thanks! P.S. I know the code is not the best implementation, but its a template I have to follow :( Code: class Moves { private final Board B; private boolean regular; public Moves(final Board b) { B = b; regular = regular_position(); } public boolean get_regular_position() { return regular; } public void set_regular_position(final boolean new_reg) { regular = new_reg; } // checking whether B represents a "normal" position or not; // if not, then only simple checks regarding move-correctness should // be performed, only checking the direct characteristics of the figure // moved; // checks whether there is exactly one king of each colour, there are // no more figures than promotions allow, and there are no pawns on the // first or last rank; public boolean regular_position() { int[] counts = new int[256]; for (char file = 'a'; file <= 'h'; ++file) for (char rank = '1'; rank <= '8'; ++rank) ++counts[(int) B.get(file,rank)]; if (counts[Board.white_king] != 1 || counts[Board.black_king] != 1) return false; if (counts[Board.white_pawn] > 8 || counts[Board.black_pawn] > 8) return false; int count_w_promotions = 0; count_w_promotions += Math.max(counts[Board.white_queen]-1,0); count_w_promotions += Math.max(counts[Board.white_rook]-2,0); count_w_promotions += Math.max(counts[Board.white_bishop]-2,0); count_w_promotions += Math.max(counts[Board.white_knight]-2,0); if (count_w_promotions > 8 - counts[Board.white_pawn]) return false; int count_b_promotions = 0; count_b_promotions += Math.max(counts[Board.black_queen]-1,0); count_b_promotions += Math.max(counts[Board.black_rook]-2,0); count_b_promotions += Math.max(counts[Board.black_bishop]-2,0); count_b_promotions += Math.max(counts[Board.black_knight]-2,0); if (count_b_promotions > 8 - counts[Board.black_pawn]) return false; for (char file = 'a'; file <= 'h'; ++file) { final char fig1 = B.get(file,'1'); if (fig1 == Board.white_pawn || fig1 == Board.black_pawn) return false; final char fig8 = B.get(file,'8'); if (fig8 == Board.white_pawn || fig8 == Board.black_pawn) return false; } return true; } public boolean check_normal_white_move(final char file0, final char rank0, final char file1, final char rank1) { if (! Board.is_valid_white_figure(B.get(file0,rank0))) return false; if (! B.is_empty(file1,rank1) && ! Board.is_valid_black_figure(B.get(file1,rank1))) return false; if (B.get_active_colour() != 'w') return false; if (! check_move_simple(file0,rank0,file1,rank1)) return false; if (! regular) return true; final Board test_board = new Board(B); test_board.normal_white_move_0(file0,rank0,file1,rank1); final Moves test_move = new Moves(test_board); final char[] king_pos = test_move.white_king_position(); assert(king_pos.length == 2); return test_move.black_not_attacking(king_pos[0],king_pos[1]); } public boolean check_normal_black_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED THE CHECK NORMAL BLACK MOVE BASED ON THE CHECK NORMAL WHITE MOVE if (! Board.is_valid_black_figure(B.get(file0,rank0))) return false; if (! B.is_empty(file1,rank1) && ! Board.is_valid_white_figure(B.get(file1,rank1))) return false; if (B.get_active_colour() != 'b') return false; if (! check_move_simple(file0,rank0,file1,rank1)) return false; if (! regular) return true; final Board test_board = new Board(B); test_board.normal_black_move_0(file0,rank0,file1,rank1); final Moves test_move = new Moves(test_board); final char[] king_pos = test_move.black_king_position(); assert(king_pos.length == 2); return test_move.white_not_attacking(king_pos[0],king_pos[1]); } // for checking a normal move by just applying the move-rules private boolean check_move_simple(final char file0, final char rank0, final char file1, final char rank1) { final char fig = B.get(file0,rank0); if (fig == Board.white_king || fig == Board.black_king) return check_king_move(file0,rank0,file1,rank1); if (fig == Board.white_queen || fig == Board.black_queen) return check_queen_move(file0,rank0,file1,rank1); if (fig == Board.white_rook || fig == Board.black_rook) return check_rook_move(file0,rank0,file1,rank1); if (fig == Board.white_bishop || fig == Board.black_bishop) return check_bishop_move(file0,rank0,file1,rank1); if (fig == Board.white_knight || fig == Board.black_knight) return check_knight_move(file0,rank0,file1,rank1); if (fig == Board.white_pawn) return check_white_pawn_move(file0,rank0,file1,rank1); else return check_black_pawn_move(file0,rank0,file1,rank1); } private boolean check_king_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED KING MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange <= 1 && fileChange >= -1 && rankChange <= 1 && rankChange >= -1; } private boolean check_queen_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED QUEEN MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange <=8 && fileChange >= -8 && rankChange <= 8 && rankChange >= -8; } private boolean check_rook_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED ROOK MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange <=8 || fileChange >= -8 || rankChange <= 8 || rankChange >= -8; } private boolean check_bishop_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED BISHOP MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange <= 8 && rankChange <= 8 || fileChange <= 8 && rankChange >= -8 || fileChange >= -8 && rankChange >= -8 || fileChange >= -8 && rankChange <= 8; } private boolean check_knight_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED KNIGHT MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; /* IS THIS THE CORRECT WAY? * return fileChange <= 1 && rankChange <= 2 || fileChange <= 1 && rankChange >= -2 || fileChange <= 2 && rankChange <= 1 || fileChange <= 2 && rankChange >= -1 || fileChange >= -1 && rankChange <= 2 || fileChange >= -1 && rankChange >= -2 || fileChange >= -2 && rankChange <= 1 || fileChange >= -2 && rankChange >= -1;*/ // OR IS THIS? return fileChange <= 1 || fileChange >= -1 || fileChange <= 2 || fileChange >= -2 && rankChange <= 1 || rankChange >= - 1 || rankChange <= 2 || rankChange >= -2; } private boolean check_white_pawn_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED PAWN MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange == 0 && rankChange <= 1; } private boolean check_black_pawn_move(final char file0, final char rank0, final char file1, final char rank1) { // ADDED PAWN MOVE int fileChange = file0 - file1; int rankChange = rank0 - rank1; return fileChange == 0 && rankChange >= -1; } public boolean check_white_kingside_castling() { // only demonstration code: final char c = B.get_white_castling(); if (c == '-' || c == 'q') return false; if (B.get_active_colour() == 'b') return false; if (B.get('e','1') != 'K') return false; if (! black_not_attacking('e','1')) return false; if (! free_white('f','1')) return false; // XXX return true; } public boolean check_white_queenside_castling() { // only demonstration code: final char c = B.get_white_castling(); if (c == '-' || c == 'k') return false; if (B.get_active_colour() == 'b') return false; // ADDED BASED ON KINGSIDE CASTLING if (B.get('e','1') != 'Q') return false; if (! black_not_attacking('e','1')) return false; if (! free_white('f','1')) return false; // XXX return true; } public boolean check_black_kingside_castling() { // only demonstration code: final char c = B.get_black_castling(); if (c == '-' || c == 'q') return false; if (B.get_active_colour() == 'w') return false; // ADDED BASED ON CHECK WHITE if (B.get('e','8') != 'K') return false; if (! black_not_attacking('e','8')) return false; if (! free_white('f','8')) return false; // XXX return true; } public boolean check_black_queenside_castling() { // only demonstration code: final char c = B.get_black_castling(); if (c == '-' || c == 'k') return false; if (B.get_active_colour() == 'w') return false; // ADDED BASED ON KINGSIDE CASTLING if (B.get('e','8') != 'Q') return false; if (! black_not_attacking('e','8')) return false; if (! free_white('f','8')) return false; // XXX return true; } public boolean check_white_promotion(final char pawn_file, final char figure) { // XXX // ADDED CHECKING FOR CORRECT FIGURE AND POSITION - ALTHOUGH IT SEEMS AS THOUGH // PAWN_FILE SHOULD BE PAWN_RANK, AS IT IS THE REACHING OF THE END RANK THAT // CAUSES PROMOTION OF A PAWN, NOT FILE if (figure == P && pawn_file == 8) { return true; } else return false; } public boolean check_black_promotion(final char pawn_file, final char figure) { // XXX // ADDED CHECKING FOR CORRECT FIGURE AND POSITION if (figure == p && pawn_file == 1) { return true; } else return false; } // checks whether black doesn't attack the field: public boolean black_not_attacking(final char file, final char rank) { // XXX return true; } public boolean free_white(final char file, final char rank) { // XXX return black_not_attacking(file,rank) && B.is_empty(file,rank); } // checks whether white doesn't attack the field: public boolean white_not_attacking(final char file, final char rank) { // XXX return true; } public boolean free_black(final char file, final char rank) { // XXX return white_not_attacking(file,rank) && B.is_empty(file,rank); } public char[] white_king_position() { for (char file = 'a'; file <= 'h'; ++file) for (char rank = '1'; rank <= '8'; ++rank) if (B.get(file,rank) == Board.white_king) { char[] result = new char[2]; result[0] = file; result[1] = rank; return result; } return new char[0]; } public char[] black_king_position() { for (char file = 'a'; file <= 'h'; ++file) for (char rank = '1'; rank <= '8'; ++rank) if (B.get(file,rank) == Board.black_king) { char[] result = new char[2]; result[0] = file; result[1] = rank; return result; } return new char[0]; } public static void main(final String[] args) { // checking regular_position { Moves m = new Moves(new Board()); assert(m.regular_position()); m = new Moves(new Board("8/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("KK6/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("kk6/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/8/8/8/8/8/8/8 w - - 0 1")); assert(m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/8 w - - 0 1")); assert(m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/n7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/N7 w - - 0 1")); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/b7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/B7 w - - 0 1")); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/r7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/R7 w - - 0 1")); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/q7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/qqqqqqqq/QQQQQQQQ/Q7/q7/rrbbnn2/RRBBNN2/Q7 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kkp5/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("KkP5/8/8/8/8/8/8/8 w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/8/8/8/8/8/8/7p w - - 0 1")); assert(!m.regular_position()); m = new Moves(new Board("Kk6/8/8/8/8/8/8/7P w - - 0 1")); assert(!m.regular_position()); } // checking check_white/black_king/queenside_castling { Moves m = new Moves(new Board("4k2r/8/8/8/8/8/8/4K2R w Kk - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("4k2r/8/8/8/8/8/8/4K2R b Kk - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("4k2r/4pppp/8/8/8/8/4PPPP/4K2R w KQkq - 0 1")); assert(m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("4k2r/4pppp/8/8/8/8/4PPPP/4K2R b KQkq - 0 1")); assert(!m.check_white_kingside_castling()); assert(m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/8/8/8/8/8/8/R3K3 w Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/8/8/8/8/8/8/R3K3 b Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/p7/8/8/8/8/8/R3K3 w Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/p7/8/8/8/8/8/R3K3 b Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/p7/8/8/8/n7/8/R3K3 w Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); m = new Moves(new Board("r3k3/p7/B7/8/8/8/8/R3K3 b Qq - 0 1")); assert(!m.check_white_kingside_castling()); assert(!m.check_black_kingside_castling()); assert(!m.check_white_queenside_castling()); assert(!m.check_black_queenside_castling()); // XXX } } }

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >