Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

with ring to track

  • Loading branch information...
commit 1d861011d262481b43c9d1fec0b83a172d2723c8 1 parent 4d3a87c
@pcottle authored
Showing with 494 additions and 437 deletions.
  1. +10 −10 levels.txt
  2. +48 −4 liquidGraph.js
  3. +435 −422 liquidGraphAI.js
  4. +1 −1  liquidGraphUI.js
View
20 levels.txt
@@ -1,10 +1,10 @@
-{"polys":[{"fillColor":"107-hsb(0.7442261235788465,0.7,1)-hsb(0.9442261235788465,0.9,1)","vertices":[{"x":0.32105263157894737,"y":0.6798679867986799},{"x":0.31894736842105265,"y":0.17656765676567657},{"x":0.4515789473684211,"y":0.17656765676567657},{"x":0.4515789473684211,"y":0.12376237623762376},{"x":0.2694736842105263,"y":0.11716171617161716},{"x":0.27789473684210525,"y":0.7904290429042904},{"x":0.7431578947368421,"y":0.8003300330033003},{"x":0.728421052631579,"y":0.1419141914191419},{"x":0.5378947368421053,"y":0.14026402640264027},{"x":0.54,"y":0.24257425742574257},{"x":0.6684210526315789,"y":0.24587458745874588},{"x":0.6842105263157895,"y":0.7128712871287128}]}],"particles":[]}
-
-PC one:
-
-{"polys":[{"fillColor":"23-hsb(0.6095121571794153,0.7,1)-hsb(0.8095121571794153,0.9,1)","vertices":[{"x":0.43473684210526314,"y":0.4780780550027279},{"x":0.4305263157894737,"y":0.24049362604599697},{"x":0.6505263157894737,"y":0.24728175258761786},{"x":0.6484210526315789,"y":0.37043776269988243},{"x":0.5715789473684211,"y":0.39565080414018855},{"x":0.5189473684210526,"y":0.37528642451532584},{"x":0.5831578947368421,"y":0.355891777253552},{"x":0.6157894736842106,"y":0.3103143561883832},{"x":0.5357894736842105,"y":0.2695855969386579},{"x":0.47578947368421054,"y":0.29285917365278663},{"x":0.4789473684210526,"y":0.4693504637349295}]},{"fillColor":"36-hsb(0.10246130097657442,0.7,1)-hsb(0.3024613009765744,0.9,1)","vertices":[{"x":0.7578947368421053,"y":0.2579488085815935},{"x":0.6747368421052632,"y":0.33358793290251193},{"x":0.6621052631578948,"y":0.45286501356242176},{"x":0.7336842105263158,"y":0.4984424346275904},{"x":0.8115789473684211,"y":0.4722596608241957},{"x":0.7252631578947368,"y":0.4344400986637365},{"x":0.7189473684210527,"y":0.37625615687841457},{"x":0.7789473684210526,"y":0.29964730019440755}]},{"fillColor":"125-hsb(0.08628494553267957,0.7,1)-hsb(0.2862849455326796,0.9,1)","vertices":[{"x":0.21473684210526317,"y":0.5828091502163071},{"x":0.12842105263157894,"y":0.4169849161281399},{"x":0.3,"y":0.48874511099670354},{"x":0.16,"y":0.32873927108706846},{"x":0.3663157894736842,"y":0.4208638455804947},{"x":0.22421052631578947,"y":0.2278871053258439},{"x":0.35578947368421054,"y":0.28704077947425444},{"x":0.3231578947368421,"y":0.16873343117743336},{"x":0.17578947368421052,"y":0.17746102244523165},{"x":0.08210526315789474,"y":0.45965314010404257}]},{"fillColor":"107-hsb(0.4534639405086637,0.7,1)-hsb(0.6534639405086637,0.9,1)","vertices":[{"x":0.24526315789473685,"y":0.1609755722727238},{"x":0.2463157894736842,"y":0.10667055993975672},{"x":0.3094736842105263,"y":0.09891270103504714},{"x":0.34421052631578947,"y":0.15127824864183678},{"x":0.38105263157894737,"y":0.16388476936198987},{"x":0.4168421052631579,"y":0.11054948939211151},{"x":0.4789473684210526,"y":0.06206287123767664},{"x":0.5273684210526316,"y":0.09697323630886975},{"x":0.5273684210526316,"y":0.16388476936198987},{"x":0.5894736842105263,"y":0.18133995189758642},{"x":0.628421052631579,"y":0.11636788357064372},{"x":0.5947368421052631,"y":0.06497206832694273},{"x":0.4631578947368421,"y":0.032970900345015715},{"x":0.39052631578947367,"y":0.07369965959474102},{"x":0.33052631578947367,"y":0.07369965959474102},{"x":0.2431578947368421,"y":0.06400233596385405},{"x":0.19473684210526315,"y":0.12994413665388546}]},{"fillColor":"166-hsb(0.5172827944159508,0.7,1)-hsb(0.7172827944159508,0.9,1)","vertices":[{"x":0.29473684210526313,"y":0.5925064738471941},{"x":0.30526315789473685,"y":0.6351746978230969},{"x":0.2505263157894737,"y":0.6856007807037091},{"x":0.2,"y":0.6991770337869508},{"x":0.15789473684210525,"y":0.6545693450848707},{"x":0.14,"y":0.6613574716264916},{"x":0.16,"y":0.7030559632393056},{"x":0.2336842105263158,"y":0.7214808781379909},{"x":0.30105263157894735,"y":0.6856007807037091},{"x":0.3178947368421053,"y":0.6448720214539838},{"x":0.3105263157894737,"y":0.5944459385733715}]},{"fillColor":"106-hsb(0.2299270236864686,0.7,1)-hsb(0.4299270236864686,0.9,1)","vertices":[{"x":0.13473684210526315,"y":0.7001467661500396},{"x":0.10947368421052632,"y":0.7137230192332814},{"x":0.11473684210526315,"y":0.7534820461199179},{"x":0.15578947368421053,"y":0.7719069610186032},{"x":0.14736842105263157,"y":0.7913016082803771},{"x":0.10947368421052632,"y":0.7767556228340466},{"x":0.09157894736842105,"y":0.7389360606735874},{"x":0.10105263157894737,"y":0.69238890724533}]},{"fillColor":"58-hsb(0.7230999063700438,0.7,1)-hsb(0.9230999063700438,0.9,1)","vertices":[{"x":0.11473684210526315,"y":0.6254773741922098},{"x":0.061052631578947365,"y":0.5789302207639523},{"x":0.11263157894736842,"y":0.5420803909665819},{"x":0.14736842105263157,"y":0.5527474469605576},{"x":0.15789473684210525,"y":0.6070524592935246}]},{"fillColor":"116-hsb(0.26362585723400117,0.7,1)-hsb(0.4636258572340012,0.9,1)","vertices":[{"x":0.06421052631578947,"y":0.2967381031051414},{"x":0.12210526315789473,"y":0.22400817587348912},{"x":0.06526315789473684,"y":0.1929767402546508},{"x":0.12421052631578948,"y":0.15030851627874808},{"x":0.06631578947368422,"y":0.12315601011226458},{"x":0.1431578947368421,"y":0.09212457449342626},{"x":0.1568421052631579,"y":0.10667055993975672},{"x":0.10842105263157895,"y":0.12315601011226458},{"x":0.15263157894736842,"y":0.14545985446330462},{"x":0.09894736842105263,"y":0.1910372755284734},{"x":0.14421052631578948,"y":0.22303844351040042}]},{"fillColor":"73-hsb(0.4347502348944545,0.7,1)-hsb(0.6347502348944545,0.9,1)","vertices":[{"x":0.035789473684210524,"y":0.12509547483844197},{"x":0.05578947368421053,"y":0.06594180069003143},{"x":0.07578947368421053,"y":0.08630618031489407},{"x":0.10736842105263159,"y":0.0775785890470958},{"x":0.14105263157894737,"y":0.06303260360076533},{"x":0.16631578947368422,"y":0.07176019486856361},{"x":0.2,"y":0.07466939195782972},{"x":0.20105263157894737,"y":0.055274744696055755},{"x":0.10210526315789474,"y":0.05818394178532186},{"x":0.034736842105263156,"y":0.06109313887458794}]},{"fillColor":"90-hsb(0.49021040778607133,0.7,1)-hsb(0.6902104077860713,0.9,1)","vertices":[{"x":0.9,"y":0.707904625054749},{"x":0.8389473684210527,"y":0.672994259983556},{"x":0.8694736842105263,"y":0.6012340651149923},{"x":0.8852631578947369,"y":0.5818394178532185},{"x":0.8084210526315789,"y":0.5391711938773158},{"x":0.8326315789473684,"y":0.503291096443034},{"x":0.9105263157894737,"y":0.48680564627052614},{"x":0.86,"y":0.5314133349726062},{"x":0.8821052631578947,"y":0.5585658411390897},{"x":0.9252631578947368,"y":0.5624447705914445},{"x":0.9021052631578947,"y":0.618689247650589},{"x":0.8726315789473684,"y":0.6545693450848707},{"x":0.9273684210526316,"y":0.679782386525177}]},{"fillColor":"126-hsb(0.19209746588021517,0.7,1)-hsb(0.3920974658802152,0.9,1)","vertices":[{"x":0.7852631578947369,"y":0.5197765466155418},{"x":0.7578947368421053,"y":0.5643842353176219},{"x":0.78,"y":0.6080221916566133},{"x":0.8294736842105264,"y":0.6119011211089681},{"x":0.7936842105263158,"y":0.6623272039895806},{"x":0.828421052631579,"y":0.7088743574178379},{"x":0.8842105263157894,"y":0.7302084694057891},{"x":0.8642105263157894,"y":0.7651188344769823},{"x":0.8231578947368421,"y":0.7321479341319665},{"x":0.7778947368421053,"y":0.6458417538170725},{"x":0.74,"y":0.5343225320618723}]},{"fillColor":"96-hsb(0.4348005946725607,0.7,1)-hsb(0.6348005946725608,0.9,1)","vertices":[{"x":0.8863157894736842,"y":0.387892945235479},{"x":0.8115789473684211,"y":0.3568615096166407},{"x":0.8589473684210527,"y":0.33164846817633453},{"x":0.8957894736842106,"y":0.33552739762868933},{"x":0.8568421052631578,"y":0.2579488085815935},{"x":0.8105263157894737,"y":0.21043192279024736},{"x":0.8747368421052631,"y":0.18037021953449772},{"x":0.9242105263157895,"y":0.19976486679627165},{"x":0.9221052631578948,"y":0.27928292056954485},{"x":0.9463157894736842,"y":0.3064354267360284},{"x":0.9210526315789473,"y":0.326799806360891},{"x":0.9273684210526316,"y":0.3946810717770999}]},{"fillColor":"72-hsb(0.7120468942448497,0.7,1)-hsb(0.9120468942448496,0.9,1)","vertices":[{"x":0.8442105263157895,"y":0.4451071546577121},{"x":0.7526315789473684,"y":0.4325006339375591},{"x":0.7842105263157895,"y":0.40825732486034166},{"x":0.8315789473684211,"y":0.42668223975902686},{"x":0.8621052631578947,"y":0.42959143684829304},{"x":0.9052631578947369,"y":0.4179546484912286},{"x":0.9536842105263158,"y":0.45383474592551043},{"x":0.8789473684210526,"y":0.4683807313718409}]},{"fillColor":"65-hsb(0.6970407448709012,0.7,1)-hsb(0.8970407448709012,0.9,1)","vertices":[{"x":0.6168421052631579,"y":0.49262404044905833},{"x":0.5178947368421053,"y":0.48971484335979226},{"x":0.5231578947368422,"y":0.4489860841100669},{"x":0.5894736842105263,"y":0.47613859027655053},{"x":0.6273684210526316,"y":0.4664412666456635},{"x":0.6536842105263158,"y":0.4703201960980183},{"x":0.6568421052631579,"y":0.49456350517523573}]},{"fillColor":"57-hsb(0.35178847666829827,0.7,1)-hsb(0.5517884766682983,0.9,1)","vertices":[{"x":0.748421052631579,"y":0.20364379624862647},{"x":0.6673684210526316,"y":0.1929767402546508},{"x":0.6736842105263158,"y":0.15418744573110288},{"x":0.7105263157894737,"y":0.17649129008214293},{"x":0.7326315789473684,"y":0.17164262826669946},{"x":0.7063157894736842,"y":0.13188360138006286},{"x":0.7126315789473684,"y":0.09988243339813582},{"x":0.7389473684210527,"y":0.09697323630886975},{"x":0.7736842105263158,"y":0.14061119264786112},{"x":0.8021052631578948,"y":0.08824564504107146},{"x":0.8547368421052631,"y":0.10570082757666802},{"x":0.86,"y":0.15127824864183678},{"x":0.8347368421052631,"y":0.14545985446330462},{"x":0.8231578947368421,"y":0.12412574247535328},{"x":0.8021052631578948,"y":0.14061119264786112},{"x":0.8,"y":0.1609755722727238},{"x":0.78,"y":0.16776369881434466},{"x":0.7442105263157894,"y":0.13964146028477242},{"x":0.7536842105263157,"y":0.1823096842606751}]},{"fillColor":"114-hsb(0.6561342746019364,0.7,1)-hsb(0.8561342746019365,0.9,1)","vertices":[{"x":0.6747368421052632,"y":0.06206287123767664},{"x":0.7757894736842105,"y":0.04751688579134618},{"x":0.9210526315789473,"y":0.04751688579134618},{"x":0.9242105263157895,"y":0.08339698322562798},{"x":0.7978947368421052,"y":0.07563912432091839},{"x":0.7094736842105264,"y":0.0795180537732732}]},{"fillColor":"139-hsb(0.2991519523784518,0.7,1)-hsb(0.49915195237845184,0.9,1)","vertices":[{"x":0.003157894736842105,"y":0.001939464726177395},{"x":0.9926315789473684,"y":0.00387892945235479},{"x":0.988421052631579,"y":0.8979721682201338},{"x":0.48526315789473684,"y":0.8960327034939565},{"x":0.43894736842105264,"y":0.8126357202683284},{"x":0.52,"y":0.815845824411135},{"x":0.4968421052631579,"y":0.8776077885952713},{"x":0.9747368421052631,"y":0.8814867180476261},{"x":0.9768421052631578,"y":0.017455182535596553},{"x":0.021052631578947368,"y":0.014545985446330465},{"x":0.028421052631578948,"y":0.8795472533214487},{"x":0.26526315789473687,"y":0.8795472533214487},{"x":0.23894736842105263,"y":0.815845824411135},{"x":0.3463157894736842,"y":0.8145751849945059},{"x":0.28,"y":0.8950629711308676},{"x":0.01263157894736842,"y":0.8989419005832224}]},{"fillColor":"39-hsb(0.015674131363630297,0.7,1)-hsb(0.2156741313636303,0.9,1)","vertices":[{"x":0.32105263157894737,"y":0.7507529447224383},{"x":0.3494736842105263,"y":0.7216609738297773},{"x":0.3589473684210526,"y":0.7730567890734783},{"x":0.3989473684210526,"y":0.7672383948949462},{"x":0.39789473684210525,"y":0.7846935774305429},{"x":0.32,"y":0.7856633097936314}]},{"fillColor":"4-hsb(0.26714023351669314,0.7,1)-hsb(0.46714023351669315,0.9,1)","vertices":[{"x":0.32210526315789473,"y":0.5935771376587573},{"x":0.33263157894736844,"y":0.6624281354380548},{"x":0.3031578947368421,"y":0.7060660917770462},{"x":0.24105263157894738,"y":0.7409764568482394},{"x":0.17684210526315788,"y":0.7603711041100134},{"x":0.17894736842105263,"y":0.8001301309966498},{"x":0.2926315789473684,"y":0.7477645833898602},{"x":0.33789473684210525,"y":0.7021871623246915},{"x":0.34421052631578947,"y":0.6663070648904096}]},{"fillColor":"115-hsb(0.06026397552341223,0.7,1)-hsb(0.26026397552341224,0.9,1)","vertices":[{"x":0.22631578947368422,"y":0.6611556087295427},{"x":0.23789473684210527,"y":0.5583639782421409},{"x":0.2873684210526316,"y":0.6107295258489305}]},{"fillColor":"106-hsb(0.47533112131059174,0.7,1)-hsb(0.6753311213105917,0.9,1)","vertices":[{"x":0.34421052631578947,"y":0.5299785867237687},{"x":0.42210526315789476,"y":0.6846310483406205},{"x":0.46421052631578946,"y":0.5294738702464288},{"x":0.5484210526315789,"y":0.7059651603285717},{"x":0.5663157894736842,"y":0.5236554760678966},{"x":0.6652631578947369,"y":0.7108138221440153},{"x":0.7242105263157895,"y":0.5440198556927592},{"x":0.8021052631578948,"y":0.7408755253997649},{"x":0.3705263157894737,"y":0.7369965959474101}]}],"particles":[]}
-
-
-good one:
-
-{"polys":[{"fillColor":"136-hsb(0.06393695343285799,0.7,1)-hsb(0.263936953432858,0.9,1)","vertices":[{"x":0.5010526315789474,"y":0.1948608137044968},{"x":0.48210526315789476,"y":0.1841541755888651},{"x":0.4768421052631579,"y":0.1423982869379015},{"x":0.5168421052631579,"y":0.07815845824411134},{"x":0.6273684210526316,"y":0.048179871520342615},{"x":0.8031578947368421,"y":0.0867237687366167},{"x":0.9189473684210526,"y":0.15096359743040685},{"x":0.9368421052631579,"y":0.25910064239828695},{"x":0.9147368421052632,"y":0.3758029978586724},{"x":0.8357894736842105,"y":0.39721627408993576},{"x":0.7810526315789473,"y":0.34796573875803},{"x":0.7978947368421052,"y":0.2880085653104925},{"x":0.8547368421052631,"y":0.28693790149892934},{"x":0.8557894736842105,"y":0.25910064239828695},{"x":0.7926315789473685,"y":0.2644539614561028},{"x":0.7610526315789473,"y":0.34796573875803},{"x":0.8073684210526316,"y":0.4464668094218415},{"x":0.9126315789473685,"y":0.4282655246252677},{"x":0.9652631578947368,"y":0.278372591006424},{"x":0.92,"y":0.06423982869379015},{"x":0.7768421052631579,"y":0.031049250535331904},{"x":0.5231578947368422,"y":0.033190578158458245},{"x":0.48210526315789476,"y":0.06209850107066381},{"x":0.4673684210526316,"y":0.1006423982869379},{"x":0.4652631578947368,"y":0.2012847965738758}]},{"fillColor":"107-hsb(0.7442261235788465,0.7,1)-hsb(0.9442261235788465,0.9,1)","vertices":[{"x":0.3094736842105263,"y":0.7430406852248393},{"x":0.31894736842105265,"y":0.17656765676567654},{"x":0.4515789473684211,"y":0.17656765676567654},{"x":0.4515789473684211,"y":0.12376237623762376},{"x":0.2694736842105263,"y":0.11716171617161716},{"x":0.27789473684210525,"y":0.7904290429042904},{"x":0.7431578947368421,"y":0.8003300330033002},{"x":0.728421052631579,"y":0.1419141914191419},{"x":0.5378947368421053,"y":0.14026402640264027},{"x":0.54,"y":0.24257425742574257},{"x":0.6684210526315789,"y":0.24587458745874588},{"x":0.7094736842105264,"y":0.7569593147751607}]},{"fillColor":"37-hsb(0.5863502260297537,0.7,1)-hsb(0.7863502260297537,0.9,1)","vertices":[{"x":0.4926315789473684,"y":0.20985010706638116},{"x":0.37684210526315787,"y":0.21199143468950749},{"x":0.36,"y":0.6927194860813705},{"x":0.5863157894736842,"y":0.6488222698072805},{"x":0.5936842105263158,"y":0.5867237687366167},{"x":0.4242105263157895,"y":0.639186295503212},{"x":0.40842105263157896,"y":0.5513918629550322},{"x":0.5336842105263158,"y":0.5449678800856531},{"x":0.5210526315789473,"y":0.45610278372591007},{"x":0.5789473684210527,"y":0.45289079229122053},{"x":0.5715789473684211,"y":0.5449678800856531},{"x":0.6178947368421053,"y":0.550321199143469},{"x":0.5915789473684211,"y":0.3993576017130621},{"x":0.5168421052631579,"y":0.4079229122055675},{"x":0.48210526315789476,"y":0.5139186295503212},{"x":0.40210526315789474,"y":0.5096359743040685},{"x":0.4010526315789474,"y":0.36509635974304067},{"x":0.4494736842105263,"y":0.3683083511777302},{"x":0.44842105263157894,"y":0.4421841541755889},{"x":0.4726315789473684,"y":0.44967880085653106},{"x":0.47368421052631576,"y":0.33940042826552463},{"x":0.40842105263157896,"y":0.3297644539614561},{"x":0.41578947368421054,"y":0.2580299785867238},{"x":0.5242105263157895,"y":0.21734475374732334},{"x":0.5189473684210526,"y":0.19914346895074947}]},{"fillColor":"125-hsb(0.32713480163365605,0.7,1)-hsb(0.5271348016336561,0.9,1)","vertices":[{"x":0.5715789473684211,"y":0.3715203426124197},{"x":0.6578947368421053,"y":0.367237687366167},{"x":0.6652631578947369,"y":0.607066381156317},{"x":0.6378947368421053,"y":0.6102783725910065},{"x":0.6273684210526316,"y":0.39186295503211993}]},{"fillColor":"36-hsb(0.7977690029889346,0.7,1)-hsb(0.9977690029889346,0.9,1)","vertices":[{"x":0.47368421052631576,"y":0.29978586723768735},{"x":0.43157894736842106,"y":0.2880085653104925},{"x":0.5042105263157894,"y":0.2462526766595289},{"x":0.5126315789473684,"y":0.27944325481798715}]},{"fillColor":"157-hsb(0.29311543963849546,0.7,1)-hsb(0.49311543963849547,0.9,1)","vertices":[{"x":0.5631578947368421,"y":0.30406852248394006},{"x":0.5378947368421053,"y":0.27944325481798715},{"x":0.6536842105263158,"y":0.2676659528907923},{"x":0.6589473684210526,"y":0.3286937901498929},{"x":0.6147368421052631,"y":0.3351177730192719},{"x":0.6178947368421053,"y":0.2987152034261242},{"x":0.5894736842105263,"y":0.3019271948608137},{"x":0.5473684210526316,"y":0.35867237687366166},{"x":0.5368421052631579,"y":0.32762312633832974}]}],"particles":[]}
+{"polys":[{"fillColor":"107-hsb(0.7442261235788465,0.7,1)-hsb(0.9442261235788465,0.9,1)","vertices":[{"x":0.32105263157894737,"y":0.6798679867986799},{"x":0.31894736842105265,"y":0.17656765676567657},{"x":0.4515789473684211,"y":0.17656765676567657},{"x":0.4515789473684211,"y":0.12376237623762376},{"x":0.2694736842105263,"y":0.11716171617161716},{"x":0.27789473684210525,"y":0.7904290429042904},{"x":0.7431578947368421,"y":0.8003300330033003},{"x":0.728421052631579,"y":0.1419141914191419},{"x":0.5378947368421053,"y":0.14026402640264027},{"x":0.54,"y":0.24257425742574257},{"x":0.6684210526315789,"y":0.24587458745874588},{"x":0.6842105263157895,"y":0.7128712871287128}]}],"particles":[]}
+
+PC one:
+
+{"polys":[{"fillColor":"23-hsb(0.6095121571794153,0.7,1)-hsb(0.8095121571794153,0.9,1)","vertices":[{"x":0.43473684210526314,"y":0.4780780550027279},{"x":0.4305263157894737,"y":0.24049362604599697},{"x":0.6505263157894737,"y":0.24728175258761786},{"x":0.6484210526315789,"y":0.37043776269988243},{"x":0.5715789473684211,"y":0.39565080414018855},{"x":0.5189473684210526,"y":0.37528642451532584},{"x":0.5831578947368421,"y":0.355891777253552},{"x":0.6157894736842106,"y":0.3103143561883832},{"x":0.5357894736842105,"y":0.2695855969386579},{"x":0.47578947368421054,"y":0.29285917365278663},{"x":0.4789473684210526,"y":0.4693504637349295}]},{"fillColor":"36-hsb(0.10246130097657442,0.7,1)-hsb(0.3024613009765744,0.9,1)","vertices":[{"x":0.7578947368421053,"y":0.2579488085815935},{"x":0.6747368421052632,"y":0.33358793290251193},{"x":0.6621052631578948,"y":0.45286501356242176},{"x":0.7336842105263158,"y":0.4984424346275904},{"x":0.8115789473684211,"y":0.4722596608241957},{"x":0.7252631578947368,"y":0.4344400986637365},{"x":0.7189473684210527,"y":0.37625615687841457},{"x":0.7789473684210526,"y":0.29964730019440755}]},{"fillColor":"125-hsb(0.08628494553267957,0.7,1)-hsb(0.2862849455326796,0.9,1)","vertices":[{"x":0.21473684210526317,"y":0.5828091502163071},{"x":0.12842105263157894,"y":0.4169849161281399},{"x":0.3,"y":0.48874511099670354},{"x":0.16,"y":0.32873927108706846},{"x":0.3663157894736842,"y":0.4208638455804947},{"x":0.22421052631578947,"y":0.2278871053258439},{"x":0.35578947368421054,"y":0.28704077947425444},{"x":0.3231578947368421,"y":0.16873343117743336},{"x":0.17578947368421052,"y":0.17746102244523165},{"x":0.08210526315789474,"y":0.45965314010404257}]},{"fillColor":"107-hsb(0.4534639405086637,0.7,1)-hsb(0.6534639405086637,0.9,1)","vertices":[{"x":0.24526315789473685,"y":0.1609755722727238},{"x":0.2463157894736842,"y":0.10667055993975672},{"x":0.3094736842105263,"y":0.09891270103504714},{"x":0.34421052631578947,"y":0.15127824864183678},{"x":0.38105263157894737,"y":0.16388476936198987},{"x":0.4168421052631579,"y":0.11054948939211151},{"x":0.4789473684210526,"y":0.06206287123767664},{"x":0.5273684210526316,"y":0.09697323630886975},{"x":0.5273684210526316,"y":0.16388476936198987},{"x":0.5894736842105263,"y":0.18133995189758642},{"x":0.628421052631579,"y":0.11636788357064372},{"x":0.5947368421052631,"y":0.06497206832694273},{"x":0.4631578947368421,"y":0.032970900345015715},{"x":0.39052631578947367,"y":0.07369965959474102},{"x":0.33052631578947367,"y":0.07369965959474102},{"x":0.2431578947368421,"y":0.06400233596385405},{"x":0.19473684210526315,"y":0.12994413665388546}]},{"fillColor":"166-hsb(0.5172827944159508,0.7,1)-hsb(0.7172827944159508,0.9,1)","vertices":[{"x":0.29473684210526313,"y":0.5925064738471941},{"x":0.30526315789473685,"y":0.6351746978230969},{"x":0.2505263157894737,"y":0.6856007807037091},{"x":0.2,"y":0.6991770337869508},{"x":0.15789473684210525,"y":0.6545693450848707},{"x":0.14,"y":0.6613574716264916},{"x":0.16,"y":0.7030559632393056},{"x":0.2336842105263158,"y":0.7214808781379909},{"x":0.30105263157894735,"y":0.6856007807037091},{"x":0.3178947368421053,"y":0.6448720214539838},{"x":0.3105263157894737,"y":0.5944459385733715}]},{"fillColor":"106-hsb(0.2299270236864686,0.7,1)-hsb(0.4299270236864686,0.9,1)","vertices":[{"x":0.13473684210526315,"y":0.7001467661500396},{"x":0.10947368421052632,"y":0.7137230192332814},{"x":0.11473684210526315,"y":0.7534820461199179},{"x":0.15578947368421053,"y":0.7719069610186032},{"x":0.14736842105263157,"y":0.7913016082803771},{"x":0.10947368421052632,"y":0.7767556228340466},{"x":0.09157894736842105,"y":0.7389360606735874},{"x":0.10105263157894737,"y":0.69238890724533}]},{"fillColor":"58-hsb(0.7230999063700438,0.7,1)-hsb(0.9230999063700438,0.9,1)","vertices":[{"x":0.11473684210526315,"y":0.6254773741922098},{"x":0.061052631578947365,"y":0.5789302207639523},{"x":0.11263157894736842,"y":0.5420803909665819},{"x":0.14736842105263157,"y":0.5527474469605576},{"x":0.15789473684210525,"y":0.6070524592935246}]},{"fillColor":"116-hsb(0.26362585723400117,0.7,1)-hsb(0.4636258572340012,0.9,1)","vertices":[{"x":0.06421052631578947,"y":0.2967381031051414},{"x":0.12210526315789473,"y":0.22400817587348912},{"x":0.06526315789473684,"y":0.1929767402546508},{"x":0.12421052631578948,"y":0.15030851627874808},{"x":0.06631578947368422,"y":0.12315601011226458},{"x":0.1431578947368421,"y":0.09212457449342626},{"x":0.1568421052631579,"y":0.10667055993975672},{"x":0.10842105263157895,"y":0.12315601011226458},{"x":0.15263157894736842,"y":0.14545985446330462},{"x":0.09894736842105263,"y":0.1910372755284734},{"x":0.14421052631578948,"y":0.22303844351040042}]},{"fillColor":"73-hsb(0.4347502348944545,0.7,1)-hsb(0.6347502348944545,0.9,1)","vertices":[{"x":0.035789473684210524,"y":0.12509547483844197},{"x":0.05578947368421053,"y":0.06594180069003143},{"x":0.07578947368421053,"y":0.08630618031489407},{"x":0.10736842105263159,"y":0.0775785890470958},{"x":0.14105263157894737,"y":0.06303260360076533},{"x":0.16631578947368422,"y":0.07176019486856361},{"x":0.2,"y":0.07466939195782972},{"x":0.20105263157894737,"y":0.055274744696055755},{"x":0.10210526315789474,"y":0.05818394178532186},{"x":0.034736842105263156,"y":0.06109313887458794}]},{"fillColor":"90-hsb(0.49021040778607133,0.7,1)-hsb(0.6902104077860713,0.9,1)","vertices":[{"x":0.9,"y":0.707904625054749},{"x":0.8389473684210527,"y":0.672994259983556},{"x":0.8694736842105263,"y":0.6012340651149923},{"x":0.8852631578947369,"y":0.5818394178532185},{"x":0.8084210526315789,"y":0.5391711938773158},{"x":0.8326315789473684,"y":0.503291096443034},{"x":0.9105263157894737,"y":0.48680564627052614},{"x":0.86,"y":0.5314133349726062},{"x":0.8821052631578947,"y":0.5585658411390897},{"x":0.9252631578947368,"y":0.5624447705914445},{"x":0.9021052631578947,"y":0.618689247650589},{"x":0.8726315789473684,"y":0.6545693450848707},{"x":0.9273684210526316,"y":0.679782386525177}]},{"fillColor":"126-hsb(0.19209746588021517,0.7,1)-hsb(0.3920974658802152,0.9,1)","vertices":[{"x":0.7852631578947369,"y":0.5197765466155418},{"x":0.7578947368421053,"y":0.5643842353176219},{"x":0.78,"y":0.6080221916566133},{"x":0.8294736842105264,"y":0.6119011211089681},{"x":0.7936842105263158,"y":0.6623272039895806},{"x":0.828421052631579,"y":0.7088743574178379},{"x":0.8842105263157894,"y":0.7302084694057891},{"x":0.8642105263157894,"y":0.7651188344769823},{"x":0.8231578947368421,"y":0.7321479341319665},{"x":0.7778947368421053,"y":0.6458417538170725},{"x":0.74,"y":0.5343225320618723}]},{"fillColor":"96-hsb(0.4348005946725607,0.7,1)-hsb(0.6348005946725608,0.9,1)","vertices":[{"x":0.8863157894736842,"y":0.387892945235479},{"x":0.8115789473684211,"y":0.3568615096166407},{"x":0.8589473684210527,"y":0.33164846817633453},{"x":0.8957894736842106,"y":0.33552739762868933},{"x":0.8568421052631578,"y":0.2579488085815935},{"x":0.8105263157894737,"y":0.21043192279024736},{"x":0.8747368421052631,"y":0.18037021953449772},{"x":0.9242105263157895,"y":0.19976486679627165},{"x":0.9221052631578948,"y":0.27928292056954485},{"x":0.9463157894736842,"y":0.3064354267360284},{"x":0.9210526315789473,"y":0.326799806360891},{"x":0.9273684210526316,"y":0.3946810717770999}]},{"fillColor":"72-hsb(0.7120468942448497,0.7,1)-hsb(0.9120468942448496,0.9,1)","vertices":[{"x":0.8442105263157895,"y":0.4451071546577121},{"x":0.7526315789473684,"y":0.4325006339375591},{"x":0.7842105263157895,"y":0.40825732486034166},{"x":0.8315789473684211,"y":0.42668223975902686},{"x":0.8621052631578947,"y":0.42959143684829304},{"x":0.9052631578947369,"y":0.4179546484912286},{"x":0.9536842105263158,"y":0.45383474592551043},{"x":0.8789473684210526,"y":0.4683807313718409}]},{"fillColor":"65-hsb(0.6970407448709012,0.7,1)-hsb(0.8970407448709012,0.9,1)","vertices":[{"x":0.6168421052631579,"y":0.49262404044905833},{"x":0.5178947368421053,"y":0.48971484335979226},{"x":0.5231578947368422,"y":0.4489860841100669},{"x":0.5894736842105263,"y":0.47613859027655053},{"x":0.6273684210526316,"y":0.4664412666456635},{"x":0.6536842105263158,"y":0.4703201960980183},{"x":0.6568421052631579,"y":0.49456350517523573}]},{"fillColor":"57-hsb(0.35178847666829827,0.7,1)-hsb(0.5517884766682983,0.9,1)","vertices":[{"x":0.748421052631579,"y":0.20364379624862647},{"x":0.6673684210526316,"y":0.1929767402546508},{"x":0.6736842105263158,"y":0.15418744573110288},{"x":0.7105263157894737,"y":0.17649129008214293},{"x":0.7326315789473684,"y":0.17164262826669946},{"x":0.7063157894736842,"y":0.13188360138006286},{"x":0.7126315789473684,"y":0.09988243339813582},{"x":0.7389473684210527,"y":0.09697323630886975},{"x":0.7736842105263158,"y":0.14061119264786112},{"x":0.8021052631578948,"y":0.08824564504107146},{"x":0.8547368421052631,"y":0.10570082757666802},{"x":0.86,"y":0.15127824864183678},{"x":0.8347368421052631,"y":0.14545985446330462},{"x":0.8231578947368421,"y":0.12412574247535328},{"x":0.8021052631578948,"y":0.14061119264786112},{"x":0.8,"y":0.1609755722727238},{"x":0.78,"y":0.16776369881434466},{"x":0.7442105263157894,"y":0.13964146028477242},{"x":0.7536842105263157,"y":0.1823096842606751}]},{"fillColor":"114-hsb(0.6561342746019364,0.7,1)-hsb(0.8561342746019365,0.9,1)","vertices":[{"x":0.6747368421052632,"y":0.06206287123767664},{"x":0.7757894736842105,"y":0.04751688579134618},{"x":0.9210526315789473,"y":0.04751688579134618},{"x":0.9242105263157895,"y":0.08339698322562798},{"x":0.7978947368421052,"y":0.07563912432091839},{"x":0.7094736842105264,"y":0.0795180537732732}]},{"fillColor":"139-hsb(0.2991519523784518,0.7,1)-hsb(0.49915195237845184,0.9,1)","vertices":[{"x":0.003157894736842105,"y":0.001939464726177395},{"x":0.9926315789473684,"y":0.00387892945235479},{"x":0.988421052631579,"y":0.8979721682201338},{"x":0.48526315789473684,"y":0.8960327034939565},{"x":0.43894736842105264,"y":0.8126357202683284},{"x":0.52,"y":0.815845824411135},{"x":0.4968421052631579,"y":0.8776077885952713},{"x":0.9747368421052631,"y":0.8814867180476261},{"x":0.9768421052631578,"y":0.017455182535596553},{"x":0.021052631578947368,"y":0.014545985446330465},{"x":0.028421052631578948,"y":0.8795472533214487},{"x":0.26526315789473687,"y":0.8795472533214487},{"x":0.23894736842105263,"y":0.815845824411135},{"x":0.3463157894736842,"y":0.8145751849945059},{"x":0.28,"y":0.8950629711308676},{"x":0.01263157894736842,"y":0.8989419005832224}]},{"fillColor":"39-hsb(0.015674131363630297,0.7,1)-hsb(0.2156741313636303,0.9,1)","vertices":[{"x":0.32105263157894737,"y":0.7507529447224383},{"x":0.3494736842105263,"y":0.7216609738297773},{"x":0.3589473684210526,"y":0.7730567890734783},{"x":0.3989473684210526,"y":0.7672383948949462},{"x":0.39789473684210525,"y":0.7846935774305429},{"x":0.32,"y":0.7856633097936314}]},{"fillColor":"4-hsb(0.26714023351669314,0.7,1)-hsb(0.46714023351669315,0.9,1)","vertices":[{"x":0.32210526315789473,"y":0.5935771376587573},{"x":0.33263157894736844,"y":0.6624281354380548},{"x":0.3031578947368421,"y":0.7060660917770462},{"x":0.24105263157894738,"y":0.7409764568482394},{"x":0.17684210526315788,"y":0.7603711041100134},{"x":0.17894736842105263,"y":0.8001301309966498},{"x":0.2926315789473684,"y":0.7477645833898602},{"x":0.33789473684210525,"y":0.7021871623246915},{"x":0.34421052631578947,"y":0.6663070648904096}]},{"fillColor":"115-hsb(0.06026397552341223,0.7,1)-hsb(0.26026397552341224,0.9,1)","vertices":[{"x":0.22631578947368422,"y":0.6611556087295427},{"x":0.23789473684210527,"y":0.5583639782421409},{"x":0.2873684210526316,"y":0.6107295258489305}]},{"fillColor":"106-hsb(0.47533112131059174,0.7,1)-hsb(0.6753311213105917,0.9,1)","vertices":[{"x":0.34421052631578947,"y":0.5299785867237687},{"x":0.42210526315789476,"y":0.6846310483406205},{"x":0.46421052631578946,"y":0.5294738702464288},{"x":0.5484210526315789,"y":0.7059651603285717},{"x":0.5663157894736842,"y":0.5236554760678966},{"x":0.6652631578947369,"y":0.7108138221440153},{"x":0.7242105263157895,"y":0.5440198556927592},{"x":0.8021052631578948,"y":0.7408755253997649},{"x":0.3705263157894737,"y":0.7369965959474101}]}],"particles":[]}
+
+
+good one:
+
+{"polys":[{"fillColor":"136-hsb(0.06393695343285799,0.7,1)-hsb(0.263936953432858,0.9,1)","vertices":[{"x":0.5010526315789474,"y":0.1948608137044968},{"x":0.48210526315789476,"y":0.1841541755888651},{"x":0.4768421052631579,"y":0.1423982869379015},{"x":0.5168421052631579,"y":0.07815845824411134},{"x":0.6273684210526316,"y":0.048179871520342615},{"x":0.8031578947368421,"y":0.0867237687366167},{"x":0.9189473684210526,"y":0.15096359743040685},{"x":0.9368421052631579,"y":0.25910064239828695},{"x":0.9147368421052632,"y":0.3758029978586724},{"x":0.8357894736842105,"y":0.39721627408993576},{"x":0.7810526315789473,"y":0.34796573875803},{"x":0.7978947368421052,"y":0.2880085653104925},{"x":0.8547368421052631,"y":0.28693790149892934},{"x":0.8557894736842105,"y":0.25910064239828695},{"x":0.7926315789473685,"y":0.2644539614561028},{"x":0.7610526315789473,"y":0.34796573875803},{"x":0.8073684210526316,"y":0.4464668094218415},{"x":0.9126315789473685,"y":0.4282655246252677},{"x":0.9652631578947368,"y":0.278372591006424},{"x":0.92,"y":0.06423982869379015},{"x":0.7768421052631579,"y":0.031049250535331904},{"x":0.5231578947368422,"y":0.033190578158458245},{"x":0.48210526315789476,"y":0.06209850107066381},{"x":0.4673684210526316,"y":0.1006423982869379},{"x":0.4652631578947368,"y":0.2012847965738758}]},{"fillColor":"107-hsb(0.7442261235788465,0.7,1)-hsb(0.9442261235788465,0.9,1)","vertices":[{"x":0.3094736842105263,"y":0.7430406852248393},{"x":0.31894736842105265,"y":0.17656765676567654},{"x":0.4515789473684211,"y":0.17656765676567654},{"x":0.4515789473684211,"y":0.12376237623762376},{"x":0.2694736842105263,"y":0.11716171617161716},{"x":0.27789473684210525,"y":0.7904290429042904},{"x":0.7431578947368421,"y":0.8003300330033002},{"x":0.728421052631579,"y":0.1419141914191419},{"x":0.5378947368421053,"y":0.14026402640264027},{"x":0.54,"y":0.24257425742574257},{"x":0.6684210526315789,"y":0.24587458745874588},{"x":0.7094736842105264,"y":0.7569593147751607}]},{"fillColor":"37-hsb(0.5863502260297537,0.7,1)-hsb(0.7863502260297537,0.9,1)","vertices":[{"x":0.4926315789473684,"y":0.20985010706638116},{"x":0.37684210526315787,"y":0.21199143468950749},{"x":0.36,"y":0.6927194860813705},{"x":0.5863157894736842,"y":0.6488222698072805},{"x":0.5936842105263158,"y":0.5867237687366167},{"x":0.4242105263157895,"y":0.639186295503212},{"x":0.40842105263157896,"y":0.5513918629550322},{"x":0.5336842105263158,"y":0.5449678800856531},{"x":0.5210526315789473,"y":0.45610278372591007},{"x":0.5789473684210527,"y":0.45289079229122053},{"x":0.5715789473684211,"y":0.5449678800856531},{"x":0.6178947368421053,"y":0.550321199143469},{"x":0.5915789473684211,"y":0.3993576017130621},{"x":0.5168421052631579,"y":0.4079229122055675},{"x":0.48210526315789476,"y":0.5139186295503212},{"x":0.40210526315789474,"y":0.5096359743040685},{"x":0.4010526315789474,"y":0.36509635974304067},{"x":0.4494736842105263,"y":0.3683083511777302},{"x":0.44842105263157894,"y":0.4421841541755889},{"x":0.4726315789473684,"y":0.44967880085653106},{"x":0.47368421052631576,"y":0.33940042826552463},{"x":0.40842105263157896,"y":0.3297644539614561},{"x":0.41578947368421054,"y":0.2580299785867238},{"x":0.5242105263157895,"y":0.21734475374732334},{"x":0.5189473684210526,"y":0.19914346895074947}]},{"fillColor":"125-hsb(0.32713480163365605,0.7,1)-hsb(0.5271348016336561,0.9,1)","vertices":[{"x":0.5715789473684211,"y":0.3715203426124197},{"x":0.6578947368421053,"y":0.367237687366167},{"x":0.6652631578947369,"y":0.607066381156317},{"x":0.6378947368421053,"y":0.6102783725910065},{"x":0.6273684210526316,"y":0.39186295503211993}]},{"fillColor":"36-hsb(0.7977690029889346,0.7,1)-hsb(0.9977690029889346,0.9,1)","vertices":[{"x":0.47368421052631576,"y":0.29978586723768735},{"x":0.43157894736842106,"y":0.2880085653104925},{"x":0.5042105263157894,"y":0.2462526766595289},{"x":0.5126315789473684,"y":0.27944325481798715}]},{"fillColor":"157-hsb(0.29311543963849546,0.7,1)-hsb(0.49311543963849547,0.9,1)","vertices":[{"x":0.5631578947368421,"y":0.30406852248394006},{"x":0.5378947368421053,"y":0.27944325481798715},{"x":0.6536842105263158,"y":0.2676659528907923},{"x":0.6589473684210526,"y":0.3286937901498929},{"x":0.6147368421052631,"y":0.3351177730192719},{"x":0.6178947368421053,"y":0.2987152034261242},{"x":0.5894736842105263,"y":0.3019271948608137},{"x":0.5473684210526316,"y":0.35867237687366166},{"x":0.5368421052631579,"y":0.32762312633832974}]}],"particles":[]}
View
52 liquidGraph.js
@@ -20,7 +20,7 @@ function Vertex(x,y,rPoint,parentPoly) {
Vertex.prototype.highlight = function() {
this.rPoint.animate({
- 'r':6,
+ 'r':5,
'stroke':'#000',
'stroke-width':3,
},800,'easeInOut');
@@ -1164,6 +1164,12 @@ KineticTransitionPath.prototype.animate = function(doneFunction) {
this.vel = startVel;
this.particleBody = cuteSmallCircle(startPoint.x,startPoint.y);
+ this.ring = p.circle(startPoint.x,startPoint.y,40,40);
+ this.ring.attr({
+ 'stroke':'rgba(1,1,1,0.5)',
+ 'fill':'rgba(0,0,0,0)',
+ 'stroke-width':5
+ });
this.vArrow = new rArrow(startPoint,startVel);
//add ourselves to the bAnimator
@@ -1185,6 +1191,10 @@ KineticTransitionPath.prototype.animateStep = function() {
'cx':this.pos.x,
'cy':this.pos.y
});
+ this.ring.attr({
+ 'cx':this.pos.x,
+ 'cy':this.pos.y
+ });
this.vArrow.update(this.pos,this.vel);
@@ -1195,6 +1205,7 @@ KineticTransitionPath.prototype.animateStep = function() {
else
{
this.particleBody.remove();
+ this.ring.remove();
this.vArrow.path.remove();
if(this.doneFunction)
{
@@ -1206,6 +1217,7 @@ KineticTransitionPath.prototype.animateStep = function() {
//kind of depreciated since we have bAnimator
KineticTransitionPath.prototype.clearAnimation = function() {
if(this.particleBody) { this.particleBody.remove(); }
+ if(this.ring) { this.ring.remove(); }
if(this.vArrow) { this.vArrow.remove(); }
this.animateTime = 0;
@@ -1252,6 +1264,7 @@ function KineticPath(parabola,endTime) {
this.endTime = parabola.getEndTimeValue(endTime);
this.particleBody = null;
+ this.ring = null;
this.vArrow = null;
this.animateTime = 0;
@@ -1259,7 +1272,7 @@ function KineticPath(parabola,endTime) {
this.doneFunction = null;
};
-KineticPath.prototype.animate = function(doneFunction) {
+KineticPath.prototype.animate = function(doneFunction,wantsRing) {
this.doneFunction = doneFunction;
this.animateSpeed = globalAnimateSpeed;
@@ -1274,6 +1287,16 @@ KineticPath.prototype.animate = function(doneFunction) {
this.vel = startVel;
this.particleBody = cuteSmallCircle(startPoint.x,startPoint.y);
+
+ if(wantsRing) {
+ this.ring = p.circle(startPoint.x,startPoint.y,40,40);
+ this.ring.attr({
+ 'stroke':'rgba(1,1,1,0.5)',
+ 'fill':'rgba(0,0,0,0)',
+ 'stroke-width':5
+ });
+ }
+
this.vArrow = new rArrow(startPoint,startVel);
//start animation with timeout
@@ -1309,6 +1332,14 @@ KineticPath.prototype.animateStep = function() {
'cy':this.pos.y
});
+ if(this.ring)
+ {
+ this.ring.attr({
+ 'cx':this.pos.x,
+ 'cy':this.pos.y
+ });
+ }
+
this.vArrow.update(this.pos,this.vel);
//set another?
@@ -1323,6 +1354,11 @@ KineticPath.prototype.animateStep = function() {
//also remove our body and arrow
this.particleBody.remove();
this.vArrow.path.remove();
+
+ if(this.ring)
+ {
+ this.ring.remove();
+ }
this.doneFunction();
}
};
@@ -2098,7 +2134,7 @@ Particle.prototype.animateStep = function(i) {
var doneClosure = this.getDoneClosure(i+1);
//animate this kPath and call us when done
- this.kPaths[i].animate(doneClosure);
+ this.kPaths[i].animate(doneClosure,this.wantsRing);
};
Particle.prototype.getDoneClosure = function(num) {
@@ -2110,10 +2146,18 @@ Particle.prototype.getDoneClosure = function(num) {
return toReturn;
};
-Particle.prototype.animate = function(doneFunction) {
+Particle.prototype.animate = function(doneFunction,wantsRing) {
//ok so the tricky here is that we need to animate each path in succession. so when a path finishes,
//it must call it's parent particle to animate the next one. this is all done with closures and
//timeouts.... aka reasons to absolutely love JS
+ if(wantsRing)
+ {
+ this.wantsRing = true;
+ }
+ else
+ {
+ this.wantsRing = false;
+ }
if(doneFunction)
{
View
857 liquidGraphAI.js
@@ -1,422 +1,435 @@
-/*********** The file for all the AI work. It's ironic that the AI code will be only a few
- hundred lines, while all the physics / graphics / UI are huge.
-
- ********/
-
-
-/********* Classes **********/
-
-function Node(locationObj,accelDirection) {
- if(!accelDirection) { throw new Error("need field accel at this node!"); }
-
- this.locationObj = locationObj;
- if(this.locationObj != 'offScreen')
- {
- this.locationName = this.locationObj.id;
- }
- else
- {
- this.locationName = 'offScreen';
- }
-
- if(locationObj == 'offScreen')
- {
- this.isGoal = true;
- this.cvs = null;
- return;
- }
-
- this.cvs = new ConcaveVertexSampler(locationObj,accelDirection);
- this.isGoal = false;
-}
-
-Node.prototype.expand = function() {
- this.cvs.sampleConnectivity();
- //DEBUG / OPTIONAL -- animate connectivity
- //this.cvs.animateConnectivity();
-
- var connectedObjects = [];
- for(var i = 0; i < this.cvs.connectedNodeNames.length; i++)
- {
- connectedObjects.push(this.cvs.nameToObject[this.cvs.connectedNodeNames[i]]);
- }
-
- return connectedObjects;
-}
-
-
-
-function PartialPlan(parentPlan,node) {
- if(!parentPlan)
- {
- this.nodes = [];
- }
- else
- {
- this.nodes = parentPlan.nodes.slice(0);
- }
-
- this.nodes.push(node);
-
- var totalTime = 0;
- for(var i = 0; i < this.nodes.length - 1; i++)
- {
- //for every node -> node connection in our partial plan,
- //calculate the time and add it
- var sourceNode = this.nodes[i];
- var destNode = this.nodes[i+1];
-
- var name = destNode.locationName;
-
- var time = sourceNode.cvs.animationInfo[name].totalTime;
- //console.log('found ',time,'between s',sourceNode,'and dest',destNode);
-
- totalTime += time;
- }
-
- this.totalTime = totalTime;
-};
-
-PartialPlan.prototype.lastNode = function() {
- return this.nodes[this.nodes.length - 1];
-};
-
-
-function GraphSearcher(initialConcaveVertex) {
-
- //the initial accel will just be negated sum of
- //the two edge outward normals, scaled to the length of the field
- //accel
- var iv = initialConcaveVertex;
-
- var gDirection = vecNormalize(vecAdd(iv.inEdge.outwardNormal,iv.outEdge.outwardNormal));
- var startAccel = vecScale(vecNegate(gDirection),vecLength(globalAccel));
- this.startAccel = startAccel;
-
- //this is the standard UCS. aka have a priority queue of partial plans,
- //a closed set for visited graphs, etc.
-
- this.poppedPlans = [];
- this.visitedStates = {};
-
- this.planPriorityQueue = [];
- this.sortFunction = function(a,b) {
- return a.totalTime - b.totalTime;
- };
-
- var n = new Node(initialConcaveVertex,startAccel);
- var plan = new PartialPlan(null,n);
-
- this.planPriorityQueue.push(plan);
- this.planPriorityQueue.sort(this.sortFunction);
-
-};
-
-GraphSearcher.prototype.printPlan = function(plan) {
- var str = '';
-
- console.log("THIS PLAN IS:");
-
- for(var i = 0; i < plan.nodes.length; i++)
- {
- var n = plan.nodes[i];
- str = str + n.locationName + '->';
- }
-
- console.log(str);
-};
-
-GraphSearcher.prototype.searchStep = function() {
- //pop off the top plan
- var planToExpand = this.planPriorityQueue.shift();
-
- var topNode = planToExpand.lastNode();
- var topNodeName = topNode.locationName;
-
- if(this.visitedStates[topNodeName])
- {
- //call ourselves when in async mode
- //this.searchStep();
- return;
- }
- this.visitedStates[topNodeName] = true;
-
- this.poppedPlans.push(planToExpand);
- this.printPlan(planToExpand);
- //expand this top node to get a bunch of other nodes
- var nodeToExpand = planToExpand.nodes[planToExpand.nodes.length - 1];
-
- if(!nodeToExpand)
- {
- //no solution found :(
- return "NoSolution";
- }
-
-
- if(nodeToExpand.isGoal)
- {
- this.solution = planToExpand;
- this.buildSolutionAnimation();
-
- return "FoundSolution";
- }
-
- var newLocationObjects = nodeToExpand.expand();
- for(var i = 0; i < newLocationObjects.length; i++)
- {
- var newNode = new Node(newLocationObjects[i],this.startAccel);
- var newPlan = new PartialPlan(planToExpand,newNode);
- this.planPriorityQueue.push(newPlan);
- }
-
- //maintain the priorty queue
- this.planPriorityQueue.sort(this.sortFunction);
-
- var times = [];
- for(var i = 0; i < this.planPriorityQueue.length; i++)
- {
- times.push(this.planPriorityQueue[i].totalTime);
- }
-
- //console.log("SORTED LIST OF TIMES IS");
- //console.log(times.join(','));
-
- //not at goal yet
- return "StillSearching";
-};
-
-GraphSearcher.prototype.search = function() {
-
- this.searchStepAsync();
-};
-
-GraphSearcher.prototype.searchStepAsync = function() {
- var results = this.searchStep();
- if(debug)
- {
- gs = this;
- console.log(this);
- return;
- }
-
- var poppedPlan = this.poppedPlans[this.poppedPlans.length - 1];
-
- if(results == "FoundSolution")
- {
- topNotify("Found a solution!");
- //console.log("Found a solution!");
- var _this = this;
-
- setTimeout(function() {
- _this.animateSolution();
- },3000);
- }
- else if(results == "NoSolution")
- {
- topNotify("No Solution Found");
- }
- else
- {
- var _this = this;
- var f = function() {
- _this.searchStepAsync();
- };
- bAnimator.add(f);
- }
-};
-
-GraphSearcher.prototype.buildSolutionAnimation = function() {
- //ok so this is the deal. we need to build a ton of functions that will animate
- //between two arbitrary things. these are the types of functions we will have:
-
- // gravityTransition:
- // animates between two different gravity directions. useful for
- // the initial transition and when "rotating" the board with a
- // trapped particle
-
- // gravityParticleTransition:
- // this one is kinda intense. we will animate a gravity transition WHILE
- // animating a particle.
-
- // nodeNodeAnimation:
- //
- // this one is easy. just take two nodes in our plan solution,
- // get the transition particle, and animate that sucker.
-
- this.animateStepFunctions = [];
-
- //first, pop on a function that takes in the global accel and rotates to the starting accel
-
- var _this = this;
- var initialAccel = globalAccel;
- var lastG = globalAccel;
-
- var startPos = this.solution.nodes[0].cvs.concaveVertex;
- this.pBody = cuteSmallCircle(startPos.x,startPos.y);
-
- //now loop through nodes
- for(var i = 0; i < this.solution.nodes.length -1; i++)
- {
- //get information
- var sourceNode = this.solution.nodes[i];
- var destNode = this.solution.nodes[i+1];
- var name = destNode.locationName;
- var animation = sourceNode.cvs.animationInfo[name];
-
- var startingG = animation.startG;
- var realEndG = animation.realEndAccel;
- var transParticle = animation.transParticle;
-
- var transPos = sourceNode.cvs.concaveVertex;
- var timeToTransition = animation.timeToTransition;
-
- var time = 15;
- if(i == 0) { time = time * 3; }
-
- var gravTransition = this.makeGravityClosure(transPos,lastG,startingG,time,i);
-
- //ok so to animate a solution, first transition between these gravity directions
- this.animateStepFunctions.push(gravTransition);
-
- //then animate between the startingG, the realEndG, WHILE animating the particle
- var gravParticleTransition = this.makeGravityParticleTransitionClosure(startingG,realEndG,
- transParticle,timeToTransition);
- this.animateStepFunctions.push(gravParticleTransition);
-
- lastG = realEndG;
-
- //then animate the actual node node animation
- var particleAnimation = this.makeNodeNodeClosure(i);
- this.animateStepFunctions.push(particleAnimation);
- }
-
- //push one to return to our original position
- gravTransition = this.makeGravityClosure(null,lastG,initialAccel,time,"end");
- this.animateStepFunctions.push(gravTransition);
-};
-
-GraphSearcher.prototype.animateSolution = function() {
- if(!this.solution)
- {
- throw new Error("no solution to animate!");
- }
- partController.clearAll();
-
- solveController.isAnimating = true;
-
- solveController.UIbutton.hideAllButtons();
-
- this.animateStepNum = 0;
-
- this.animateStep();
-};
-
-GraphSearcher.prototype.animateStep = function() {
- if(this.animateStepNum >= this.animateStepFunctions.length)
- {
- //we are done, clean up after ourselves
- topNotifyClear();
- this.pBody.remove();
-
- solveController.UIbutton.anchorClick();
- solveController.UIbutton.showMainButtons();
-
- //also tell the solve UI that we are done
- solveController.isAnimating = false;
-
- return;
- }
-
- //animating!!
- this.animateStepFunctions[this.animateStepNum]();
-
- this.animateStepNum++;
-};
-
-GraphSearcher.prototype.makeGravityParticleTransitionClosure = function(startingG,realEndG,transParticle,timeToTransition) {
- var _this = this;
- var gravParticleTransition = function() {
- _this.gravityAnimation(null,startingG,realEndG,timeToTransition);
- transParticle.animate();
- };
- return gravParticleTransition;
-};
-
-GraphSearcher.prototype.makeGravityClosure = function(transPos,startG,endG,time,index) {
-
- var _this = this;
-
- var gravTransition = function() {
- //do a cross hair on the first
- if(index == 0)
- {
- _this.pBody.attr({
- r:200
- });
- _this.pBody.animate({
- r:4
- },4000,'easeIn');
- }
-
- _this.gravityAnimation(transPos,startG,endG,time);
- };
- return gravTransition;
-};
-
-GraphSearcher.prototype.gravityAnimation = function(transPos,gStart,gEnd,time) {
- if(transPos)
- {
- this.pBody.attr({
- cx:transPos.x,
- cy:transPos.y
- });
- this.pBody.show();
- }
-
- var _this = this;
- var doneFunction = function() {
- _this.animateStep();
- _this.pBody.hide();
- };
-
- var gt = new GravityTweener(gStart,gEnd,time,doneFunction);
- gt.start();
-};
-
-GraphSearcher.prototype.makeNodeNodeClosure = function(nodeIndex) {
- var _this = this;
- var particleAnimation = function() {
- _this.nodeNodeAnimation(nodeIndex);
- };
- return particleAnimation;
-};
-
-GraphSearcher.prototype.nodeNodeAnimation = function(nodeIndex) {
-
- if(nodeIndex >= this.solution.nodes.length -1)
- {
- console.warn("called particle animation for a node that didn't exist");
- //we are done!
- return;
- }
-
- var i = nodeIndex;
-
- var nodes = this.solution.nodes;
- var sourceNode = nodes[i];
- var destNode = nodes[i+1];
- var name = destNode.locationName;
-
- var animation = sourceNode.cvs.animationInfo[name];
-
- //ok we would like to animate this particle and then have it call ourselves
- //when it's done
-
- var _this = this;
- var done = function() {
- _this.animateStep();
- };
-
- animation.particle.animate(done);
-};
-
+/*********** The file for all the AI work. It's ironic that the AI code will be only a few
+ hundred lines, while all the physics / graphics / UI are huge.
+
+ ********/
+
+
+/********* Classes **********/
+
+function Node(locationObj,accelDirection) {
+ if(!accelDirection) { throw new Error("need field accel at this node!"); }
+
+ this.locationObj = locationObj;
+ if(this.locationObj != 'offScreen')
+ {
+ this.locationName = this.locationObj.id;
+ }
+ else
+ {
+ this.locationName = 'offScreen';
+ }
+
+ if(locationObj == 'offScreen')
+ {
+ this.isGoal = true;
+ this.cvs = null;
+ return;
+ }
+
+ this.cvs = new ConcaveVertexSampler(locationObj,accelDirection);
+ this.isGoal = false;
+}
+
+Node.prototype.expand = function() {
+ this.cvs.sampleConnectivity();
+ //DEBUG / OPTIONAL -- animate connectivity
+ //this.cvs.animateConnectivity();
+
+ var connectedObjects = [];
+ for(var i = 0; i < this.cvs.connectedNodeNames.length; i++)
+ {
+ connectedObjects.push(this.cvs.nameToObject[this.cvs.connectedNodeNames[i]]);
+ }
+
+ return connectedObjects;
+}
+
+
+
+function PartialPlan(parentPlan,node) {
+ if(!parentPlan)
+ {
+ this.nodes = [];
+ }
+ else
+ {
+ this.nodes = parentPlan.nodes.slice(0);
+ }
+
+ this.nodes.push(node);
+
+ var totalTime = 0;
+ for(var i = 0; i < this.nodes.length - 1; i++)
+ {
+ //for every node -> node connection in our partial plan,
+ //calculate the time and add it
+ var sourceNode = this.nodes[i];
+ var destNode = this.nodes[i+1];
+
+ var name = destNode.locationName;
+
+ var time = sourceNode.cvs.animationInfo[name].totalTime;
+ //console.log('found ',time,'between s',sourceNode,'and dest',destNode);
+
+ totalTime += time;
+ }
+
+ this.totalTime = totalTime;
+};
+
+PartialPlan.prototype.lastNode = function() {
+ return this.nodes[this.nodes.length - 1];
+};
+
+
+function GraphSearcher(initialConcaveVertex) {
+
+ //the initial accel will just be negated sum of
+ //the two edge outward normals, scaled to the length of the field
+ //accel
+ var iv = initialConcaveVertex;
+
+ var gDirection = vecNormalize(vecAdd(iv.inEdge.outwardNormal,iv.outEdge.outwardNormal));
+ var startAccel = vecScale(vecNegate(gDirection),vecLength(globalAccel));
+ this.startAccel = startAccel;
+
+ //this is the standard UCS. aka have a priority queue of partial plans,
+ //a closed set for visited graphs, etc.
+
+ this.poppedPlans = [];
+ this.visitedStates = {};
+
+ this.planPriorityQueue = [];
+ this.sortFunction = function(a,b) {
+ return a.totalTime - b.totalTime;
+ };
+
+ var n = new Node(initialConcaveVertex,startAccel);
+ var plan = new PartialPlan(null,n);
+
+ this.planPriorityQueue.push(plan);
+ this.planPriorityQueue.sort(this.sortFunction);
+
+};
+
+GraphSearcher.prototype.printPlan = function(plan) {
+ var str = '';
+
+ console.log("THIS PLAN IS:");
+
+ for(var i = 0; i < plan.nodes.length; i++)
+ {
+ var n = plan.nodes[i];
+ str = str + n.locationName + '->';
+ }
+
+ console.log(str);
+};
+
+GraphSearcher.prototype.searchStep = function() {
+ //pop off the top plan
+ var planToExpand = this.planPriorityQueue.shift();
+
+ var topNode = planToExpand.lastNode();
+ var topNodeName = topNode.locationName;
+
+ if(this.visitedStates[topNodeName])
+ {
+ //call ourselves when in async mode
+ //this.searchStep();
+ return;
+ }
+ this.visitedStates[topNodeName] = true;
+
+ this.poppedPlans.push(planToExpand);
+ this.printPlan(planToExpand);
+ //expand this top node to get a bunch of other nodes
+ var nodeToExpand = planToExpand.nodes[planToExpand.nodes.length - 1];
+
+ if(!nodeToExpand)
+ {
+ //no solution found :(
+ return "NoSolution";
+ }
+
+
+ if(nodeToExpand.isGoal)
+ {
+ this.solution = planToExpand;
+ this.buildSolutionAnimation();
+
+ return "FoundSolution";
+ }
+
+ var newLocationObjects = nodeToExpand.expand();
+ for(var i = 0; i < newLocationObjects.length; i++)
+ {
+ var newNode = new Node(newLocationObjects[i],this.startAccel);
+ var newPlan = new PartialPlan(planToExpand,newNode);
+ this.planPriorityQueue.push(newPlan);
+ }
+
+ //maintain the priorty queue
+ this.planPriorityQueue.sort(this.sortFunction);
+
+ var times = [];
+ for(var i = 0; i < this.planPriorityQueue.length; i++)
+ {
+ times.push(this.planPriorityQueue[i].totalTime);
+ }
+
+ //console.log("SORTED LIST OF TIMES IS");
+ //console.log(times.join(','));
+
+ //not at goal yet
+ return "StillSearching";
+};
+
+GraphSearcher.prototype.search = function() {
+
+ this.searchStepAsync();
+};
+
+GraphSearcher.prototype.searchStepAsync = function() {
+ var results = this.searchStep();
+ if(debug)
+ {
+ gs = this;
+ console.log(this);
+ return;
+ }
+
+ var poppedPlan = this.poppedPlans[this.poppedPlans.length - 1];
+
+ if(results == "FoundSolution")
+ {
+ topNotify("Found a solution!");
+ //console.log("Found a solution!");
+ var _this = this;
+
+ setTimeout(function() {
+ _this.animateSolution();
+ },3000);
+ }
+ else if(results == "NoSolution")
+ {
+ topNotify("No Solution Found");
+ }
+ else
+ {
+ var _this = this;
+ var f = function() {
+ _this.searchStepAsync();
+ };
+ bAnimator.add(f);
+ }
+};
+
+GraphSearcher.prototype.buildSolutionAnimation = function() {
+ //ok so this is the deal. we need to build a ton of functions that will animate
+ //between two arbitrary things. these are the types of functions we will have:
+
+ // gravityTransition:
+ // animates between two different gravity directions. useful for
+ // the initial transition and when "rotating" the board with a
+ // trapped particle
+
+ // gravityParticleTransition:
+ // this one is kinda intense. we will animate a gravity transition WHILE
+ // animating a particle.
+
+ // nodeNodeAnimation:
+ //
+ // this one is easy. just take two nodes in our plan solution,
+ // get the transition particle, and animate that sucker.
+
+ this.animateStepFunctions = [];
+
+ //first, pop on a function that takes in the global accel and rotates to the starting accel
+
+ var _this = this;
+ var initialAccel = globalAccel;
+ var lastG = globalAccel;
+
+ var startPos = this.solution.nodes[0].cvs.concaveVertex;
+ this.pBody = cuteSmallCircle(startPos.x,startPos.y);
+ this.ring = p.circle(startPos.x,startPos.y,40,40);
+ this.ring.attr({
+ 'stroke-width':5,
+ 'stroke':'rgba(1,1,1,0.5)',
+ 'fill':'rgba(0,0,0,0)'
+ });
+
+ //now loop through nodes
+ for(var i = 0; i < this.solution.nodes.length -1; i++)
+ {
+ //get information
+ var sourceNode = this.solution.nodes[i];
+ var destNode = this.solution.nodes[i+1];
+ var name = destNode.locationName;
+ var animation = sourceNode.cvs.animationInfo[name];
+
+ var startingG = animation.startG;
+ var realEndG = animation.realEndAccel;
+ var transParticle = animation.transParticle;
+
+ var transPos = sourceNode.cvs.concaveVertex;
+ var timeToTransition = animation.timeToTransition;
+
+ var time = 15;
+ if(i == 0) { time = time * 3; }
+
+ var gravTransition = this.makeGravityClosure(transPos,lastG,startingG,time,i);
+
+ //ok so to animate a solution, first transition between these gravity directions
+ this.animateStepFunctions.push(gravTransition);
+
+ //then animate between the startingG, the realEndG, WHILE animating the particle
+ var gravParticleTransition = this.makeGravityParticleTransitionClosure(startingG,realEndG,
+ transParticle,timeToTransition);
+ this.animateStepFunctions.push(gravParticleTransition);
+
+ lastG = realEndG;
+
+ //then animate the actual node node animation
+ var particleAnimation = this.makeNodeNodeClosure(i);
+ this.animateStepFunctions.push(particleAnimation);
+ }
+
+ //push one to return to our original position
+ gravTransition = this.makeGravityClosure(null,lastG,initialAccel,time,"end");
+ this.animateStepFunctions.push(gravTransition);
+};
+
+GraphSearcher.prototype.animateSolution = function() {
+ if(!this.solution)
+ {
+ throw new Error("no solution to animate!");
+ }
+ partController.clearAll();
+
+ solveController.isAnimating = true;
+
+ solveController.UIbutton.hideAllButtons();
+
+ this.animateStepNum = 0;
+
+ this.animateStep();
+};
+
+GraphSearcher.prototype.animateStep = function() {
+ if(this.animateStepNum >= this.animateStepFunctions.length)
+ {
+ //we are done, clean up after ourselves
+ topNotifyClear();
+ this.pBody.remove();
+ this.ring.remove();
+
+ solveController.UIbutton.anchorClick();
+ solveController.UIbutton.showMainButtons();
+
+ //also tell the solve UI that we are done
+ solveController.isAnimating = false;
+
+ return;
+ }
+
+ //animating!!
+ this.animateStepFunctions[this.animateStepNum]();
+
+ this.animateStepNum++;
+};
+
+GraphSearcher.prototype.makeGravityParticleTransitionClosure = function(startingG,realEndG,transParticle,timeToTransition) {
+ var _this = this;
+ var gravParticleTransition = function() {
+ _this.gravityAnimation(null,startingG,realEndG,timeToTransition);
+ transParticle.animate();
+ };
+ return gravParticleTransition;
+};
+
+GraphSearcher.prototype.makeGravityClosure = function(transPos,startG,endG,time,index) {
+
+ var _this = this;
+
+ var gravTransition = function() {
+ //do a cross hair on the first
+ if(index == 0)
+ {
+ _this.pBody.attr({
+ r:200
+ });
+ _this.pBody.animate({
+ r:4
+ },4000,'easeIn');
+ }
+
+ _this.gravityAnimation(transPos,startG,endG,time);
+ };
+ return gravTransition;
+};
+
+GraphSearcher.prototype.gravityAnimation = function(transPos,gStart,gEnd,time) {
+ if(transPos)
+ {
+ this.pBody.attr({
+ cx:transPos.x,
+ cy:transPos.y
+ });
+ this.ring.attr({
+ cx:transPos.x,
+ cy:transPos.y
+ });
+ this.ring.show();
+ this.pBody.show();
+ }
+
+ var _this = this;
+ var doneFunction = function() {
+ _this.animateStep();
+ _this.pBody.hide();
+ _this.ring.hide();
+ };
+
+ var gt = new GravityTweener(gStart,gEnd,time,doneFunction);
+ gt.start();
+};
+
+GraphSearcher.prototype.makeNodeNodeClosure = function(nodeIndex) {
+ var _this = this;
+ var particleAnimation = function() {
+ _this.nodeNodeAnimation(nodeIndex);
+ };
+ return particleAnimation;
+};
+
+GraphSearcher.prototype.nodeNodeAnimation = function(nodeIndex) {
+
+ if(nodeIndex >= this.solution.nodes.length -1)
+ {
+ console.warn("called particle animation for a node that didn't exist");
+ //we are done!
+ return;
+ }
+
+ var i = nodeIndex;
+
+ var nodes = this.solution.nodes;
+ var sourceNode = nodes[i];
+ var destNode = nodes[i+1];
+ var name = destNode.locationName;
+
+ var animation = sourceNode.cvs.animationInfo[name];
+
+ //ok we would like to animate this particle and then have it call ourselves
+ //when it's done
+
+ var _this = this;
+ var done = function() {
+ _this.animateStep();
+ };
+
+ animation.particle.animate(done,true);
+};
+
View
2  liquidGraphUI.js
@@ -946,7 +946,7 @@ TraceUIControl.prototype.mouseMove = function(x,y,e) {
function cuteSmallCircle(x,y,wantsSameColor) {
var c = p.circle(x,y,4,4);
- if(wantsSameColor)
+ if(!wantsSameColor)
{
c.attr("fill","hsba(0.5,0.8,0.7,1)");
}
Please sign in to comment.
Something went wrong with that request. Please try again.